pub fn batch_windows(
insert_range: TimeRange,
slice: TimeDelta,
bucket_counts: &[(DateTime<Utc>, i64)],
target_rows_per_query: i64,
) -> impl Iterator<Item = TimeRange>Expand description
Packs consecutive insert-time buckets of [insert_range.begin, insert_range.end) (stepping by
slice, so every bucket edge is slice-aligned to insert_range.begin) into batch query
windows, greedily closing a window just before it would exceed target_rows_per_query.
bucket_counts holds one (bucket_start, nb_blocks) pair per non-empty bucket, ascending;
any bucket missing from it is treated as holding zero blocks (and so never forces a close on
its own). A bucket whose own count already exceeds target_rows_per_query still forms one
batch on its own – the loop never splits a bucket.
Batch edges are always bucket-aligned and batches tile insert_range with no gaps or overlaps,
so which width is picked cannot change the specs group_blocks_into_partitions later emits
per bucket – only how many SQL queries it takes to gather them.