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

Function create_primitive_array

arrow/src/util/bench_util.rs:36–52  ·  view source on GitHub ↗

Creates an random (but fixed-seeded) array of a given size and null density

(size: usize, null_density: f32)

Source from the content-addressed store, hash-verified

34
35/// Creates an random (but fixed-seeded) array of a given size and null density
36pub fn create_primitive_array<T>(size: usize, null_density: f32) -> PrimitiveArray<T>
37where
38 T: ArrowPrimitiveType,
39 StandardUniform: Distribution<T::Native>,
40{
41 let mut rng = seedable_rng();
42
43 (0..size)
44 .map(|_| {
45 if rng.random::<f32>() < null_density {
46 None
47 } else {
48 Some(rng.random())
49 }
50 })
51 .collect()
52}
53
54/// Creates an random (but fixed-seeded) array of a given size and null density,
55/// all the values located in the given range

Callers

nothing calls this directly

Calls 3

collectMethod · 0.80
randomMethod · 0.80
seedable_rngFunction · 0.70

Tested by

no test coverage detected