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

Method gen_binary_view

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

Creates a BinaryViewArray with random binary data.

(&mut self)

Source from the content-addressed store, hash-verified

62
63 /// Creates a BinaryViewArray with random binary data.
64 pub fn gen_binary_view(&mut self) -> ArrayRef {
65 let distinct_binary_views: BinaryViewArray = (0..self.num_distinct_binaries)
66 .map(|_| Some(random_binary(&mut self.rng, self.max_len)))
67 .collect();
68
69 let indices: UInt32Array = (0..self.num_binaries)
70 .map(|_| {
71 if self.rng.random::<f64>() < self.null_pct {
72 None
73 } else if self.num_distinct_binaries > 1 {
74 let range = 0..(self.num_distinct_binaries as u32);
75 Some(self.rng.random_range(range))
76 } else {
77 Some(0)
78 }
79 })
80 .collect();
81
82 compute::take(&distinct_binary_views, &indices, None).unwrap()
83 }
84}
85
86/// Return a binary vector of random bytes of length 1..=max_len

Callers 1

Calls 3

random_binaryFunction · 0.85
collectMethod · 0.80
mapMethod · 0.45

Tested by 1