tustvold commented on code in PR #4718:
URL: https://github.com/apache/arrow-rs/pull/4718#discussion_r1305430438


##########
arrow-string/src/length.rs:
##########
@@ -194,28 +98,42 @@ pub fn length(array: &dyn Array) -> Result<ArrayRef, 
ArrowError> {
 /// * bit_length of null is null.
 /// * bit_length is in number of bits
 pub fn bit_length(array: &dyn Array) -> Result<ArrayRef, ArrowError> {
+    if let Some(d) = array.as_any_dictionary_opt() {
+        let lengths = bit_length(d.values().as_ref())?;
+        return Ok(d.with_values(lengths));
+    }
+
     match array.data_type() {
-        DataType::Dictionary(kt, _) => {
-            kernel_dict!(
-                array,
-                |a| { bit_length(a) },
-                kt,
-                Int8: Int8Type,
-                Int16: Int16Type,
-                Int32: Int32Type,
-                Int64: Int64Type,
-                UInt8: UInt8Type,
-                UInt16: UInt16Type,
-                UInt32: UInt32Type,
-                UInt64: UInt64Type
-            )
+        DataType::List(_) => {
+            let list = array.as_list::<i32>();
+            Ok(bit_length_impl::<Int32Type>(list.offsets(), list.nulls()))
         }
-        DataType::Utf8 => Ok(bit_length_string::<i32, Int32Type>(array)),
-        DataType::LargeUtf8 => Ok(bit_length_string::<i64, Int64Type>(array)),
-        DataType::Binary => Ok(bit_length_binary::<i32, Int32Type>(array)),
-        DataType::LargeBinary => Ok(bit_length_binary::<i64, 
Int64Type>(array)),
+        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::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::new(
+            vec![*len * 8; array.len()].into(),
+            array.nulls().cloned(),
+        ))),
         other => Err(ArrowError::ComputeError(format!(
-            "bit_length not supported for {other:?}"
+            "length not supported for {other:?}"

Review Comment:
   Yeah this was a copypasta



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to