MCPcopy Create free account
hub / github.com/apache/arrow-rs / create_primitive_array_with_seed

Function create_primitive_array_with_seed

arrow/src/util/bench_util.rs:81–101  ·  view source on GitHub ↗

Creates a [`PrimitiveArray`] of a given `size` and `null_density` filling it with random numbers generated using the provided `seed`.

(
    size: usize,
    null_density: f32,
    seed: u64,
)

Source from the content-addressed store, hash-verified

79/// Creates a [`PrimitiveArray`] of a given `size` and `null_density`
80/// filling it with random numbers generated using the provided `seed`.
81pub fn create_primitive_array_with_seed<T>(
82 size: usize,
83 null_density: f32,
84 seed: u64,
85) -> PrimitiveArray<T>
86where
87 T: ArrowPrimitiveType,
88 StandardUniform: Distribution<T::Native>,
89{
90 let mut rng = StdRng::seed_from_u64(seed);
91
92 (0..size)
93 .map(|_| {
94 if rng.random::<f32>() < null_density {
95 None
96 } else {
97 Some(rng.random())
98 }
99 })
100 .collect()
101}
102
103/// Creates a [`PrimitiveArray`] of a given `size` and `null_density`
104/// filling it with random [`IntervalMonthDayNano`] generated using the provided `seed`.

Callers

nothing calls this directly

Calls 2

collectMethod · 0.80
randomMethod · 0.80

Tested by

no test coverage detected