Skip to main content

emit_snapshot_diff

Function emit_snapshot_diff 

Source
pub(crate) fn emit_snapshot_diff<K, V, CB, P, F>(
    session: &mut Session<'_, '_, Timestamp, CB, P>,
    packer: &mut PermutedRowPacker,
    prev: &BTreeMap<K, V>,
    current: &BTreeMap<K, V>,
    ts: Timestamp,
    pack: F,
)
where K: Ord, V: PartialEq, CB: ContainerBuilder + for<'a> PushInto<((&'a RowRef, &'a RowRef), Timestamp, Diff)>, P: CapabilityTrait<Timestamp>, F: for<'a> Fn(&'a mut PermutedRowPacker, &K, &V) -> (&'a RowRef, &'a RowRef),
Expand description

Emit the difference between two snapshots of a sampled source as updates at ts.

A sampled source reports its whole state on every read, so a changed value has to be expressed as a retraction of the previous one paired with an insertion of the new one. A key absent from current is retracted without a replacement, so a source that stops being readable drops out of the collection rather than lingering at its last value.

pack takes the packer as an argument instead of closing over it, because it hands back rows borrowed from it.