alamb commented on a change in pull request #275:
URL: https://github.com/apache/arrow-rs/pull/275#discussion_r632068820
##########
File path: arrow/src/compute/kernels/arity.rs
##########
@@ -72,3 +73,37 @@ 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>
Review comment:
I don't really understand this need for this function either -- `unary`
applies a function to an existing array to make a new array.
Given the implementation now, it seems like writing
```
let arr = Int32Array::from_iter_values(iter::repeat_with(op).take(size)
```
would be just as clear.
Maybe I am confused about its name. A more specific name might be
'make_constant_array`
I think it takes time to get used to / discover creating `Array`s from
iterators -- maybe we can work on adding some more examples to our
documentation to help
--
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:
[email protected]