You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/05/10 12:53:19 UTC

[GitHub] [arrow-rs] Dandandan commented on a change in pull request #275: add nullity function and some unit tests

Dandandan commented on a change in pull request #275:
URL: https://github.com/apache/arrow-rs/pull/275#discussion_r629333194



##########
File path: arrow/src/compute/kernels/arity.rs
##########
@@ -72,3 +72,40 @@ where
     let data = into_primitive_array_data::<_, O>(array, buffer);
     PrimitiveArray::<O>::from(data)
 }
+
+/// Applies a nullary and infalible function to generate a primitive array.
+/// You should use this instead of the vectorized version when each generated value is different.
+pub fn nullary<F, O>(size: usize, op: F) -> PrimitiveArray<O>
+where
+    O: ArrowPrimitiveType,
+    F: Fn() -> O::Native,
+{
+    let values = (0..size).map(|_| op());

Review comment:
       This could use `std::iter::repeat`




-- 
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.

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