Adds a random number of empty record batches into the stream
(
batches: Vec<RecordBatch>,
rng: &mut StdRng,
)
| 57 | |
| 58 | /// Adds a random number of empty record batches into the stream |
| 59 | pub fn add_empty_batches( |
| 60 | batches: Vec<RecordBatch>, |
| 61 | rng: &mut StdRng, |
| 62 | ) -> Vec<RecordBatch> { |
| 63 | let schema = batches[0].schema(); |
| 64 | |
| 65 | batches |
| 66 | .into_iter() |
| 67 | .flat_map(|batch| { |
| 68 | // insert 0, or 1 empty batches before and after the current batch |
| 69 | let empty_batch = RecordBatch::new_empty(schema.clone()); |
| 70 | std::iter::repeat_n(empty_batch.clone(), rng.random_range(0..2)) |
| 71 | .chain(std::iter::once(batch)) |
| 72 | .chain(std::iter::repeat_n(empty_batch, rng.random_range(0..2))) |
| 73 | }) |
| 74 | .collect() |
| 75 | } |
| 76 | |
| 77 | /// "stagger" batches: split the batches into random sized batches |
| 78 | /// |
searching dependent graphs…