tustvold commented on code in PR #3502:
URL: https://github.com/apache/arrow-rs/pull/3502#discussion_r1067029020


##########
arrow-string/src/like.rs:
##########
@@ -25,9 +25,55 @@ use arrow_select::take::take;
 use regex::Regex;
 use std::collections::HashMap;
 
+/// Helper function to perform boolean lambda function on values from two 
array accessors, this
+/// version does not attempt to use SIMD.
+pub fn compare_op<T: ArrayAccessor, S: ArrayAccessor, F>(
+    left: T,
+    right: S,
+    op: F,
+) -> Result<BooleanArray, ArrowError>
+where
+    F: Fn(T::Item, S::Item) -> bool,
+{
+    if left.len() != right.len() {
+        return Err(ArrowError::ComputeError(
+            "Cannot perform comparison operation on arrays of different length"
+                .to_string(),
+        ));
+    }
+
+    Ok(BooleanArray::from_binary(left, right, op))
+}
+
+/// Helper function to perform boolean lambda function on values from array 
accessor, this
+/// version does not attempt to use SIMD.
+pub fn compare_op_scalar<T: ArrayAccessor, F>(

Review Comment:
   ```suggestion
   fn compare_op_scalar<T: ArrayAccessor, F>(
   ```
   



##########
arrow-string/src/like.rs:
##########
@@ -25,9 +25,55 @@ use arrow_select::take::take;
 use regex::Regex;
 use std::collections::HashMap;
 
+/// Helper function to perform boolean lambda function on values from two 
array accessors, this
+/// version does not attempt to use SIMD.
+pub fn compare_op<T: ArrayAccessor, S: ArrayAccessor, F>(

Review Comment:
   ```suggestion
   fn compare_op<T: ArrayAccessor, S: ArrayAccessor, F>(
   ```
   



##########
arrow-ord/src/comparison.rs:
##########
@@ -35,6 +35,8 @@ use arrow_select::take::take;
 
 /// Helper function to perform boolean lambda function on values from two 
array accessors, this
 /// version does not attempt to use SIMD.
+///
+/// Duplicated from `arrow_ord::comparison`

Review Comment:
   Is this comment in the right location



##########
arrow-string/src/like.rs:
##########
@@ -25,9 +25,55 @@ use arrow_select::take::take;
 use regex::Regex;
 use std::collections::HashMap;
 
+/// Helper function to perform boolean lambda function on values from two 
array accessors, this
+/// version does not attempt to use SIMD.
+pub fn compare_op<T: ArrayAccessor, S: ArrayAccessor, F>(
+    left: T,
+    right: S,
+    op: F,
+) -> Result<BooleanArray, ArrowError>
+where
+    F: Fn(T::Item, S::Item) -> bool,
+{
+    if left.len() != right.len() {
+        return Err(ArrowError::ComputeError(
+            "Cannot perform comparison operation on arrays of different length"
+                .to_string(),
+        ));
+    }
+
+    Ok(BooleanArray::from_binary(left, right, op))
+}
+
+/// Helper function to perform boolean lambda function on values from array 
accessor, this
+/// version does not attempt to use SIMD.
+pub fn compare_op_scalar<T: ArrayAccessor, F>(
+    left: T,
+    op: F,
+) -> Result<BooleanArray, ArrowError>
+where
+    F: Fn(T::Item) -> bool,
+{
+    Ok(BooleanArray::from_unary(left, op))
+}
+
+/// Evaluate `op(left, right)` for [`PrimitiveArray`]s using a specified
+/// comparison function.
+pub fn no_simd_compare_op<T, F>(

Review Comment:
   ```suggestion
   fn no_simd_compare_op<T, F>(
   ```
   



##########
arrow-string/src/like.rs:
##########
@@ -25,9 +25,55 @@ use arrow_select::take::take;
 use regex::Regex;
 use std::collections::HashMap;
 
+/// Helper function to perform boolean lambda function on values from two 
array accessors, this
+/// version does not attempt to use SIMD.
+pub fn compare_op<T: ArrayAccessor, S: ArrayAccessor, F>(
+    left: T,
+    right: S,
+    op: F,
+) -> Result<BooleanArray, ArrowError>
+where
+    F: Fn(T::Item, S::Item) -> bool,
+{
+    if left.len() != right.len() {
+        return Err(ArrowError::ComputeError(
+            "Cannot perform comparison operation on arrays of different length"
+                .to_string(),
+        ));
+    }
+
+    Ok(BooleanArray::from_binary(left, right, op))
+}
+
+/// Helper function to perform boolean lambda function on values from array 
accessor, this
+/// version does not attempt to use SIMD.
+pub fn compare_op_scalar<T: ArrayAccessor, F>(
+    left: T,
+    op: F,
+) -> Result<BooleanArray, ArrowError>
+where
+    F: Fn(T::Item) -> bool,
+{
+    Ok(BooleanArray::from_unary(left, op))
+}
+
+/// Evaluate `op(left, right)` for [`PrimitiveArray`]s using a specified
+/// comparison function.
+pub fn no_simd_compare_op<T, F>(
+    left: &PrimitiveArray<T>,
+    right: &PrimitiveArray<T>,
+    op: F,
+) -> Result<BooleanArray, ArrowError>
+where
+    T: ArrowPrimitiveType,
+    F: Fn(T::Native, T::Native) -> bool,
+{
+    compare_op(left, right, op)

Review Comment:
   Is this function even needed? Could we just use compare_op directly?



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to