jhorstmann commented on a change in pull request #1151:
URL: https://github.com/apache/arrow-rs/pull/1151#discussion_r782096256
##########
File path: arrow/src/compute/kernels/arithmetic.rs
##########
@@ -1010,6 +1073,28 @@ where
return math_op(left, right, |a, b| a + b);
}
+/// Add every value in an array by a scalar. If any value in the array is null
then the
+/// result is also null.
+pub fn add_scalar<T>(
+ array: &PrimitiveArray<T>,
+ scalar: T::Native,
+) -> Result<PrimitiveArray<T>>
+where
+ T: datatypes::ArrowNumericType,
+ T::Native: Add<Output = T::Native>
+ + Sub<Output = T::Native>
+ + Mul<Output = T::Native>
+ + Div<Output = T::Native>
+ + Rem<Output = T::Native>
+ + Zero
+ + One,
+{
+ #[cfg(feature = "simd")]
+ return simd_add_scalar(&array, scalar);
Review comment:
I think you could reuse `simd_float_unary_math_op` here with a small
modification, that method should work for any primitive types without the
restriction on `T: datatypes::ArrowFloatNumericType`
--
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]