viirya commented on code in PR #1990:
URL: https://github.com/apache/arrow-rs/pull/1990#discussion_r914464137
##########
arrow/src/compute/kernels/arity.rs:
##########
@@ -78,10 +82,120 @@ where
PrimitiveArray::<O>::from(data)
}
+macro_rules! unary_dict_op {
+ ($array: expr, $op: expr, $value_ty: ty) => {{
+ // Safety justification: Since the inputs are valid Arrow arrays, all
values are
+ // valid indexes into the dictionary (which is verified during
construction)
+
+ let array_iter = unsafe {
+ $array
+ .values()
+ .as_any()
+ .downcast_ref::<$value_ty>()
+ .unwrap()
+ .take_iter_unchecked($array.keys_iter())
+ };
+
+ let values = array_iter.map(|v| v.map(|value| $op(value))).collect();
+
+ Ok(values)
+ }};
+}
+
+/// A helper function that applies an unary function to a dictionary array
with primitive value type.
+fn unary_dict<K, F, T>(array: &DictionaryArray<K>, op: F) ->
Result<PrimitiveArray<T>>
Review Comment:
They will use `unary_dyn` 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]