sdf-jkl commented on code in PR #11928:
URL: https://github.com/apache/arrow-rs/pull/11928#discussion_r4390846558
##########
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:
share logic with the original `create_fsb_array`?
##########
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:
Could we reuse `create_primitive_array_range::<UInt32Type>(size,
null_density, 0..max_value as u32)` here, either directly at the call sites or
inside this helper? It already uses the same seed, random draws, null handling,
and index range, so we could avoid maintaining another generation loop.
--
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]