Skip to content

Support BinaryView in bit_length kernel #9351

@Jefffrey

Description

@Jefffrey

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

Looks like we're missing BinaryView

match array.data_type() {
DataType::List(_) => {
let list = array.as_list::<i32>();
Ok(bit_length_impl::<Int32Type>(list.offsets(), list.nulls()))
}
DataType::LargeList(_) => {
let list = array.as_list::<i64>();
Ok(bit_length_impl::<Int64Type>(list.offsets(), list.nulls()))
}
DataType::Utf8 => {
let list = array.as_string::<i32>();
Ok(bit_length_impl::<Int32Type>(list.offsets(), list.nulls()))
}
DataType::LargeUtf8 => {
let list = array.as_string::<i64>();
Ok(bit_length_impl::<Int64Type>(list.offsets(), list.nulls()))
}
DataType::Utf8View => {
let list = array.as_string_view();
let values = list
.views()
.iter()
.map(|view| (*view as i32).wrapping_mul(8))
.collect();
Ok(Arc::new(Int32Array::try_new(
values,
array.nulls().cloned(),
)?))
}
DataType::Binary => {
let list = array.as_binary::<i32>();
Ok(bit_length_impl::<Int32Type>(list.offsets(), list.nulls()))
}
DataType::LargeBinary => {
let list = array.as_binary::<i64>();
Ok(bit_length_impl::<Int64Type>(list.offsets(), list.nulls()))
}
DataType::FixedSizeBinary(len) => Ok(Arc::new(Int32Array::try_new(
vec![*len * 8; array.len()].into(),
array.nulls().cloned(),
)?)),
other => Err(ArrowError::ComputeError(format!(
"bit_length not supported for {other:?}"
))),

Describe the solution you'd like

Describe alternatives you've considered

Additional context

Metadata

Metadata

Labels

enhancementAny new improvement worthy of a entry in the changelog

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions