viirya commented on code in PR #3134:
URL: https://github.com/apache/arrow-rs/pull/3134#discussion_r1029027250
##########
arrow-array/src/array/primitive_array.rs:
##########
@@ -469,6 +469,42 @@ impl<T: ArrowPrimitiveType> PrimitiveArray<T> {
})
}
+ /// Applies an unary and fallible function to all valid values in a
mutable primitive array.
+ /// Mutable primitive array means that the buffer is not shared with other
arrays.
+ /// As a result, this mutates the buffer directly without allocating new
buffer.
+ ///
+ /// This is unlike [`Self::unary_mut`] which will apply an infallible
function to all rows
+ /// regardless of validity, in many cases this will be significantly
faster and should
+ /// be preferred if `op` is infallible.
+ ///
+ /// This returns an `Err` for two cases. First is input array is shared
buffer with other
+ /// array. In the case, returned `Err` wraps a `Ok` of input array.
Second, if the function
+ /// encounters an error during applying on values. In the case, returned
`Err` wraps an
+ /// `Err` of the actual error.
+ ///
+ /// Note: LLVM is currently unable to effectively vectorize fallible
operations
+ pub fn try_unary_mut<F, E>(
+ self,
+ op: F,
+ ) -> Result<PrimitiveArray<T>, Result<PrimitiveArray<T>, E>>
Review Comment:
Makes sense.
--
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]