Creates a BinaryViewArray with random binary data.
(&mut self)
| 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 |