jhorstmann commented on a change in pull request #8688:
URL: https://github.com/apache/arrow/pull/8688#discussion_r528302736
##########
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:
@velvia Thanks, I got it now. It was already quite late when I looked at
this yesterday :)
Reusing the input array including its offset is a tricky problem, it's also
not always beneficial from a performance standpoint, the offset might start at
a much larger number and you probably do not want to create a null buffer with
that much unused space in front. I see two possible solutions then:
- Use the `buffer.slice(offset_bytes)` method for also getting a data slice
that can then be used with an offset of 0. Requires a special case for
primitive type boolean, for which you'd need to use `bit_slice(offset_in_bits)`.
- Create a copy of the input data if the offset is not 0.
----------------------------------------------------------------
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:
[email protected]