Rich-T-kid commented on code in PR #11928:
URL: https://github.com/apache/arrow-rs/pull/11928#discussion_r4391457171
##########
arrow/src/util/bench_util.rs:
##########
@@ -193,6 +193,54 @@ where
.collect()
}
+/// Creates a random (but fixed-seeded) [`UInt32Array`] of indices in
`0..max_value`.
+///
+/// Intended for use as the `indices` argument to take kernels. `null_density`
+/// controls the fraction of null indices.
+pub fn create_random_index(size: usize, null_density: f32, max_value: usize)
-> UInt32Array {
+ let mut rng = seedable_rng();
+ let mut builder = UInt32Builder::with_capacity(size);
+ for _ in 0..size {
+ if rng.random::<f32>() < null_density {
+ builder.append_null();
+ } else {
+ builder.append_value(rng.random_range::<u32, _>(0u32..max_value as
u32));
Review Comment:
Done - create_random_index now delegates to
create_primitive_array_range::<UInt32Type> with the same range.
##########
arrow/src/util/bench_util.rs:
##########
@@ -801,6 +849,33 @@ pub fn create_fsb_array(size: usize, null_density: f32,
value_len: usize) -> Fix
.unwrap()
}
+/// Creates a random [`FixedSizeBinaryArray`] of a given size and null density
+/// generated using the provided seed.
+pub fn create_fsb_array_with_seed(
+ size: usize,
+ null_density: f32,
+ value_len: usize,
+ seed: u64,
+) -> FixedSizeBinaryArray {
+ let rng = &mut StdRng::seed_from_u64(seed);
+
+ FixedSizeBinaryArray::try_from_sparse_iter_with_size(
Review Comment:
Done - create_fsb_array now delegates to create_fsb_array_with_seed using
the existing default seed of 42.
--
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]