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

Function add_empty_batches

test-utils/src/lib.rs:59–75  ·  view source on GitHub ↗

Adds a random number of empty record batches into the stream

(
    batches: Vec<RecordBatch>,
    rng: &mut StdRng,
)

Source from the content-addressed store, hash-verified

57
58/// Adds a random number of empty record batches into the stream
59pub 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///

Callers 4

stagger_batch_with_seedFunction · 0.85
make_staggered_batchesFunction · 0.85
make_staggered_batchesFunction · 0.85
make_staggered_batchesFunction · 0.85

Calls 4

collectMethod · 0.80
schemaMethod · 0.45
into_iterMethod · 0.45
cloneMethod · 0.45

Tested by 3

make_staggered_batchesFunction · 0.68
make_staggered_batchesFunction · 0.68
make_staggered_batchesFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…