Creates a BinaryArray or LargeBinaryArray with random binary data.
(&mut self)
| 39 | impl 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 { |
nothing calls this directly
no test coverage detected