Creates a StringArray or LargeStringArray with random strings according to the parameters of the BatchGenerator
(&mut self)
| 40 | /// Creates a StringArray or LargeStringArray with random strings according |
| 41 | /// to the parameters of the BatchGenerator |
| 42 | pub fn gen_data<O: OffsetSizeTrait>(&mut self) -> ArrayRef { |
| 43 | // table of strings from which to draw |
| 44 | let distinct_strings: GenericStringArray<O> = (0..self.num_distinct_strings) |
| 45 | .map(|_| Some(random_string(&mut self.rng, self.max_len))) |
| 46 | .collect(); |
| 47 | |
| 48 | // pick num_strings randomly from the distinct string table |
| 49 | let indices: UInt32Array = (0..self.num_strings) |
| 50 | .map(|_| { |
| 51 | if self.rng.random::<f64>() < self.null_pct { |
| 52 | None |
| 53 | } else if self.num_distinct_strings > 1 { |
| 54 | let range = 1..(self.num_distinct_strings as u32); |
| 55 | Some(self.rng.random_range(range)) |
| 56 | } else { |
| 57 | Some(0) |
| 58 | } |
| 59 | }) |
| 60 | .collect(); |
| 61 | |
| 62 | let options = None; |
| 63 | arrow::compute::take(&distinct_strings, &indices, options).unwrap() |
| 64 | } |
| 65 | |
| 66 | /// Creates a StringViewArray with random strings. |
| 67 | pub fn gen_string_view(&mut self) -> ArrayRef { |
nothing calls this directly
no test coverage detected