MCPcopy Create free account
hub / github.com/apache/datafusion / gen_data

Method gen_data

test-utils/src/array_gen/binary.rs:41–61  ·  view source on GitHub ↗

Creates a BinaryArray or LargeBinaryArray with random binary data.

(&mut self)

Source from the content-addressed store, hash-verified

39impl BinaryArrayGenerator {
40 /// Creates a BinaryArray or LargeBinaryArray with random binary data.
41 pub fn gen_data<O: OffsetSizeTrait>(&mut self) -> ArrayRef {
42 let distinct_binaries: GenericBinaryArray<O> = (0..self.num_distinct_binaries)
43 .map(|_| Some(random_binary(&mut self.rng, self.max_len)))
44 .collect();
45
46 // Pick num_binaries randomly from the distinct binary table
47 let indices: UInt32Array = (0..self.num_binaries)
48 .map(|_| {
49 if self.rng.random::<f64>() < self.null_pct {
50 None
51 } else if self.num_distinct_binaries > 1 {
52 let range = 0..(self.num_distinct_binaries as u32);
53 Some(self.rng.random_range(range))
54 } else {
55 Some(0)
56 }
57 })
58 .collect();
59
60 compute::take(&distinct_binaries, &indices, None).unwrap()
61 }
62
63 /// Creates a BinaryViewArray with random binary data.
64 pub fn gen_binary_view(&mut self) -> ArrayRef {

Callers

nothing calls this directly

Calls 3

random_binaryFunction · 0.85
collectMethod · 0.80
mapMethod · 0.45

Tested by

no test coverage detected