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



##########
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:
       An offset is just a shift of where we consider reading a buffer. The 
easiest way to motivate it: suppose that we want to slice a primitive array of 
100 elements over the range `[25..75]`. The expensive way of doing this is a 
`memcopy` of 50 elements. The cheap way is to declare a new array with len=50 
elements starting at 25 and increase the refcount of buffer (`Arc::clone` in 
Rust).
   
   The "starting at 25" is an offset of 25 "slots", or `25 * size_of::<T>()` 
bytes for a specific type T.
   
   For bit buffers (nullability), the offset is measured in bits, not bytes. 
Feel free to ping e.g. @vertexclique, @alamb or @jhorstmann , that lately have 
been working (a lot) on bits - they likely know exactly the API you need for 
this. :)




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