alamb commented on a change in pull request #844:
URL: https://github.com/apache/arrow-rs/pull/844#discussion_r734413629
##########
File path: arrow/src/compute/kernels/comparison.rs
##########
@@ -1252,6 +1354,67 @@ mod tests {
);
}
+ #[test]
+ fn test_boolean_array_eq() {
Review comment:
Normally since there is special case handling for processing these at 64
bits at a time, I would suggest tests that have at least 65 entries to test the
boundary conditions. However, in this case as it is using a pre-existing helper
method `bitwise_bin_op_helper` I am not sure such extra coverage is needed
##########
File path: arrow/src/compute/kernels/comparison.rs
##########
@@ -623,6 +624,107 @@ pub fn eq_utf8_scalar<OffsetSize: StringOffsetSizeTrait>(
compare_op_scalar!(left, right, |a, b| a == b)
}
+/// Perform `left == right` operation on [`BooleanArray`]
+fn eq_bool(left: &BooleanArray, right: &BooleanArray) -> Result<BooleanArray> {
+ binary_boolean_kernel(
+ left,
+ right,
+ |left: &Buffer,
+ left_offset_in_bits: usize,
+ right: &Buffer,
+ right_offset_in_bits: usize,
+ len_in_bits: usize| {
+ bitwise_bin_op_helper(
+ left,
+ left_offset_in_bits,
+ right,
+ right_offset_in_bits,
+ len_in_bits,
+ |a, b| !(a ^ b),
+ )
+ },
+ )
+}
+
+/// Perform `left != right` operation on [`BooleanArray`]
+fn neq_bool(left: &BooleanArray, right: &BooleanArray) -> Result<BooleanArray>
{
+ binary_boolean_kernel(
+ left,
+ right,
+ |left: &Buffer,
+ left_offset_in_bits: usize,
+ right: &Buffer,
+ right_offset_in_bits: usize,
+ len_in_bits: usize| {
+ bitwise_bin_op_helper(
+ left,
+ left_offset_in_bits,
+ right,
+ right_offset_in_bits,
+ len_in_bits,
+ |a, b| (a ^ b),
+ )
+ },
+ )
+}
+
+/// Perform `left == right` operation on [`BooleanArray`] and a scalar
+fn eq_bool_scalar(left: &BooleanArray, right: bool) -> Result<BooleanArray> {
+ let len = left.len();
+ let left_offset = left.offset();
+
+ let values = if right {
+ left.values().bit_slice(left_offset, len)
+ } else {
+ buffer_unary_not(left.values(), left.offset(), left.len())
+ };
+
+ let data = unsafe {
+ ArrayData::new_unchecked(
+ DataType::Boolean,
+ len,
+ None,
+ left.data_ref()
+ .null_bitmap()
+ .as_ref()
+ .map(|b| b.bits.bit_slice(left_offset, len)),
+ 0,
+ vec![values],
+ vec![],
+ )
+ };
+
+ Ok(BooleanArray::from(data))
+}
+
+/// Perform `left != right` operation on [`BooleanArray`] and a scalar
+fn neq_bool_scalar(left: &BooleanArray, right: bool) -> Result<BooleanArray> {
+ let len = left.len();
Review comment:
I wonder if this could simply be a call to `eq_bool_scalar(left,
!right)`?
--
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]