tyrelr commented on a change in pull request #9440:
URL: https://github.com/apache/arrow/pull/9440#discussion_r571710980
##########
File path: rust/arrow/src/compute/kernels/comparison.rs
##########
@@ -33,56 +33,66 @@ use crate::datatypes::{ArrowNumericType, DataType};
use crate::error::{ArrowError, Result};
use crate::util::bit_util;
-/// Helper function to perform boolean lambda function on values from two
arrays, this
-/// version does not attempt to use SIMD.
-macro_rules! compare_op {
- ($left: expr, $right:expr, $op:expr) => {{
- if $left.len() != $right.len() {
+fn infallible_compare_operation_scalar<'a,A,S,F>(left:&'a A, right: S,
predicate:F) -> Result<BooleanArray>
+where &'a A : TypedArray,
+ A: Array,
+ S: Copy,
+ F: FnMut(
+ <&'a A as TypedArray>::ValueRef,
+ S
+ )->bool
+{
+ let null_bit_buffer = left.data().null_buffer().cloned();
+
+ let bool_buf = {
+ let mut predicate_ref = predicate;
+ left.iter_values().map(|left|predicate_ref(left,right)).collect()
+ };
+
+ let data = ArrayData::new(
+ DataType::Boolean,
+ left.len(),
+ None,
+ null_bit_buffer,
+ 0,
+ vec![bool_buf],
+ vec![],
+ );
+ Ok(BooleanArray::from(Arc::new(data)))
+}
+
+fn infallible_compare_operation<'a,A,F>(left:&'a A, right:&'a A, predicate:F)
-> Result<BooleanArray>
Review comment:
same as above
----------------------------------------------------------------
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]