viirya commented on code in PR #2157:
URL: https://github.com/apache/arrow-rs/pull/2157#discussion_r928451736


##########
arrow/src/compute/kernels/comparison.rs:
##########
@@ -40,168 +39,72 @@ use regex::{escape, Regex};
 use std::any::type_name;
 use std::collections::HashMap;
 
-/// Helper function to perform boolean lambda function on values from two 
arrays, this
+/// Helper function to perform boolean lambda function on values from two 
array accessors, this
 /// version does not attempt to use SIMD.
-macro_rules! compare_op {
-    ($left: expr, $right:expr, $op:expr) => {{
-        if $left.len() != $right.len() {
-            return Err(ArrowError::ComputeError(
-                "Cannot perform comparison operation on arrays of different 
length"
-                    .to_string(),
-            ));
-        }
-
-        let null_bit_buffer =
-            combine_option_bitmap(&[$left.data_ref(), $right.data_ref()], 
$left.len())?;
-
-        // Safety:
-        // `i < $left.len()` and $left.len() == $right.len()
-        let comparison = (0..$left.len())
-            .map(|i| unsafe { $op($left.value_unchecked(i), 
$right.value_unchecked(i)) });
-        // same size as $left.len() and $right.len()
-        let buffer = unsafe { 
MutableBuffer::from_trusted_len_iter_bool(comparison) };
-
-        let data = unsafe {
-            ArrayData::new_unchecked(
-                DataType::Boolean,
-                $left.len(),
-                None,
-                null_bit_buffer,
-                0,
-                vec![Buffer::from(buffer)],
-                vec![],
-            )
-        };
-        Ok(BooleanArray::from(data))
-    }};
-}
+fn compare_op<T: ArrayAccessor, F>(left: T, right: T, op: F) -> 
Result<BooleanArray>

Review Comment:
   `ArrayAccessor` allows us to replace macro with generic function like 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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to