Skip to main content

iter_diff_pairs

Function iter_diff_pairs 

Source
pub fn iter_diff_pairs<B, C>(
    batch: &B,
    lower: Option<Antichain<C::Time>>,
    upper: Option<Antichain<C::Time>>,
) -> impl Iterator<Item = (<C::KeyContainer as BatchContainer>::Owned, impl Iterator<Item = (C::Time, DiffPair<C::ValOwn>)>)>
where B: BatchReader<Time = C::Time> + Navigable<Cursor = C>, C: Cursor<Storage = B, Diff = Diff>, C::Time: Copy, C::ValOwn: 'static,
Expand description

Walks batch and emits, for each key, an iterator of the DiffPairs at each timestamp.

Ignores updates outside the specified time range. Inclusive ‘lower’, exclusive ‘upper’.

Within a key, diffs are partitioned by sign into retractions (befores) and insertions (afters), sorted by timestamp, and zipped into DiffPairs via a merge-join. Pairs are emitted in ascending timestamp order for a given key; no ordering is guaranteed across keys. Callers are responsible for tracking (key, timestamp) boundaries themselves if they need to detect groups with more than one pair (e.g., for primary-key violation checks).

The per-key iterator owns its data, so it can be held or consumed after the outer iterator has advanced. An update with multiplicity n fans out into n pairs lazily, cloning the value as pairs are consumed. Memory held per key is proportional to the number of distinct updates, not the fan-out.