vertexclique commented on a change in pull request #8688:
URL: https://github.com/apache/arrow/pull/8688#discussion_r526511029



##########
File path: rust/arrow/src/compute/kernels/boolean.rs
##########
@@ -457,4 +517,42 @@ mod tests {
         assert_eq!(true, res.value(2));
         assert_eq!(false, res.value(3));
     }
+
+    fn assert_array_eq<T: ArrowNumericType>(
+        expected: PrimitiveArray<T>,
+        actual: ArrayRef,
+    ) {
+        let actual = actual
+            .as_any()
+            .downcast_ref::<PrimitiveArray<T>>()
+            .expect("Actual array should unwrap to type of expected array");
+
+        for i in 0..expected.len() {
+            if expected.is_null(i) {
+                assert!(actual.is_null(i));
+            } else {
+                assert_eq!(expected.value(i), actual.value(i));
+            }
+        }
+    }
+

Review comment:
       In my PR if you use `slicing` method and then write a method to align 
bit slices with smth along the lines:
   ```
           unsafe {
               let (_, data, _) = self.bit_slice.align_to::<u8>();
               let dest = data.as_slice();
            }
   ```
   you will get two aligned middle bit domains. then you can check bit slices 
however you want to.
   
   slicing method:
   
https://github.com/apache/arrow/pull/8664/files#diff-715ddfbc534281523a73117d3bf4986d69d8a375dd320bc19f83298d3ba7ebd6R52
   
   Reference for that method: 
https://docs.rs/bitvec/0.19.4/bitvec/slice/struct.BitSlice.html#method.align_to

##########
File path: rust/arrow/src/compute/kernels/boolean.rs
##########
@@ -457,4 +517,42 @@ mod tests {
         assert_eq!(true, res.value(2));
         assert_eq!(false, res.value(3));
     }
+
+    fn assert_array_eq<T: ArrowNumericType>(
+        expected: PrimitiveArray<T>,
+        actual: ArrayRef,
+    ) {
+        let actual = actual
+            .as_any()
+            .downcast_ref::<PrimitiveArray<T>>()
+            .expect("Actual array should unwrap to type of expected array");
+
+        for i in 0..expected.len() {
+            if expected.is_null(i) {
+                assert!(actual.is_null(i));
+            } else {
+                assert_eq!(expected.value(i), actual.value(i));
+            }
+        }
+    }
+

Review comment:
       In my PR if you use `slicing` method and then write a method to align 
bit slices with smth along the lines:
   ```
           unsafe {
               let (_, data, _) = self.bit_slice.align_to::<u8>();
               let dest = data.as_slice();
            }
   ```
   you will get two aligned middle bit domains. then you can check bit slices 
however you want to.
   
   slicing method:
   
https://github.com/apache/arrow/pull/8664/files#diff-715ddfbc534281523a73117d3bf4986d69d8a375dd320bc19f83298d3ba7ebd6R52
   
   Reference for that method in backing library: 
https://docs.rs/bitvec/0.19.4/bitvec/slice/struct.BitSlice.html#method.align_to




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to