findepi commented on code in PR #6671:
URL: https://github.com/apache/arrow-rs/pull/6671#discussion_r1826850573


##########
arrow-string/src/length.rs:
##########
@@ -440,7 +465,7 @@ mod tests {
                 let array = StringArray::from(input);
                 let result = bit_length(&array).unwrap();
                 assert_eq!(len, result.len());
-                let result = 
result.as_any().downcast_ref::<Int32Array>().unwrap();
+                let result = 
result.as_any().downcast_ref::<UInt32Array>().unwrap();

Review Comment:
   I agree that bit_length should not beed to return signed integer, but it 
seems better not to change this within this PR.



##########
arrow-string/src/length.rs:
##########
@@ -137,6 +140,26 @@ pub fn bit_length(array: &dyn Array) -> Result<ArrayRef, 
ArrowError> {
             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()
+                .enumerate()
+                .map(|(i, _)| {

Review Comment:
   Why iterate over values, only to ignore them with `_`?
   use `0..(list.len())` if iterating only the indexes is desired.



##########
arrow-string/src/length.rs:
##########
@@ -115,6 +116,8 @@ 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> {
+    println!("In Array bit_length()");

Review Comment:
   perhaps to remove?



##########
arrow-string/src/length.rs:
##########
@@ -137,6 +140,26 @@ pub fn bit_length(array: &dyn Array) -> Result<ArrayRef, 
ArrowError> {
             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()
+                .enumerate()
+                .map(|(i, _)| {
+                    if list.is_valid(i) {
+                        list.views()[i] as u32 * 8
+                    } else {
+                        0

Review Comment:
   In https://github.com/apache/arrow-rs/pull/6662#discussion_r1826175583 it 
was suggested to use from_unary.
   It this applicable here?



##########
arrow-string/src/length.rs:
##########
@@ -462,6 +487,21 @@ mod tests {
             })
     }
 
+    #[test]
+    fn bit_length_test_utf8view() {
+        bit_length_cases()

Review Comment:
   We should have tests with arrays that contain null values.
   `bit_length_cases` doesn't seem to produce such.



-- 
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