You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "Ted-Jiang (via GitHub)" <gi...@apache.org> on 2023/02/13 14:55:03 UTC

[GitHub] [arrow-rs] Ted-Jiang commented on a diff in pull request #3709: [feat] Support `unary_dyn_mut` in arrow-arth.

Ted-Jiang commented on code in PR #3709:
URL: https://github.com/apache/arrow-rs/pull/3709#discussion_r1104582980


##########
arrow-arith/src/arity.rs:
##########
@@ -152,6 +152,37 @@ where
     }
 }
 
+/// Applies an infallible unary function to an [`ArrayRef`] with primitive values.
+/// If the buffer of ArrayRef is not shared with other arrays, then func will
+/// mutate the buffer directly without allocating new buffer.
+pub fn unary_dyn_mut<F, T>(array: ArrayRef, op: F) -> Result<ArrayRef, ArrayRef>
+where
+    T: ArrowPrimitiveType,
+    F: Fn(T::Native) -> T::Native,
+{
+    let array_ref = array.as_ref();
+    downcast_dictionary_array! {
+        array_ref => unary_dict::<_, F, T>(array_ref, op).map_err(|_| array),
+        t => {
+            //Todo support unary_dict_mut

Review Comment:
   File a ticket https://github.com/apache/arrow-rs/issues/3710



-- 
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-unsubscribe@arrow.apache.org

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