Skip to main content

merge_chains

Function merge_chains 

Source
pub fn merge_chains<D, T, R, Sink>(
    list1: FetchIter<'_, D, T, R>,
    list2: FetchIter<'_, D, T, R>,
    sink: Sink,
    stash: &mut Vec<Column<(D, T, R)>>,
)
where D: Columnar, for<'a> Ref<'a, D>: Copy + Ord, T: Columnar + Default + Clone + PartialOrder, for<'a> Ref<'a, T>: Copy + Ord, R: Columnar + Default + Semigroup + for<'a> Semigroup<Ref<'a, R>>, Sink: FnMut(PagedColumn<(D, T, R)>),
Expand description

Two-way merge driver. Reuses today’s per-chunk gallop / ship-threshold logic from Column::merge_from, but pulls heads from FetchIter and emits finished output chunks through sink after routing them through the pager exposed by FetchIter::pager.

stash is a pool of empty Column::Typed chunks. Drained heads and shipped result buffers get recycled into it; the next result chunk is pulled from it instead of starting from a zero-capacity default. This matches the recycling discipline the upstream differential_dataflow merge-batcher carries via Merger::merge’s stash parameter.

Whole-chunk passthrough mirrors the fast path in super::batcher’s Merger::merge: a head that sorts entirely before the other side’s current record ships wholesale.