Skip to main content

ReduceTactic

Trait ReduceTactic 

Source
pub trait ReduceTactic<B1: BatchReader, B2: BatchReader<Time = B1::Time>> {
    // Required method
    fn retire(
        &mut self,
        source_batches: Vec<B1>,
        output_batches: Vec<B2>,
        input_batches: Vec<B1>,
        lower: &Antichain<B1::Time>,
        upper: &Antichain<B1::Time>,
        held: &Antichain<B1::Time>,
    ) -> (Vec<(B1::Time, B2)>, Antichain<B1::Time>);
}
Expand description

A type that resolves a key-wise reduction over batches arriving on the input.

Unlike join, reduce does not suspend: its output is at most linear in its input, so a single retire runs the whole [lower, upper) interval to completion rather than yielding under a fuel budget.

Required Methods§

Source

fn retire( &mut self, source_batches: Vec<B1>, output_batches: Vec<B2>, input_batches: Vec<B1>, lower: &Antichain<B1::Time>, upper: &Antichain<B1::Time>, held: &Antichain<B1::Time>, ) -> (Vec<(B1::Time, B2)>, Antichain<B1::Time>)

Retire the interval [lower, upper), producing the output batches it informs.

It is presented with the pre-existing input batches and output batches (those before lower), the new input batches, and held: the times the operator currently holds capabilities for. It reasons only about times, returning the output batches to ship — each tagged with the time at which to ship it — and the new frontier of interesting times for the operator to hold.

§Contract

The driver (reduce_with_tactic) relies on the following; the first two are cheap to check and are debug_assert!ed there.

  • Ordered, tiling output. The returned (time, batch) pairs are in ascending order and their descriptions tile [lower, upper): the first batch’s lower is lower, each batch’s upper is the next batch’s lower, and the last batch’s upper is upper — no gaps, no overlaps. Sub-intervals with no updates are skipped; the next batch’s lower simply picks up where the last left off. Producing in order is a requirement, not a convenience — it is what lets the driver check the tiling with a single linear scan.
  • Shipped at a held time. Each batch’s time tag is an element of held; the driver mints a capability at it, which is only valid for a held time.
  • Frontier bounds withheld work, and collapses to empty when there is none. The returned frontier must be at-or-below every time the tactic defers, so the driver knows what is safe to release. In particular, with no work to defer it must be the empty antichain. Derive it from the actual withheld set rather than constructing it and this holds for free; returning a non-empty frontier with nothing pending holds capabilities forever and deadlocks recursive scopes. (Not driver-checkable — the withheld set is tactic-internal — so tactics self-enforce.)

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<B1, B2, Bk> ReduceTactic<B1, B2> for ProxyReduceTactic<B1::Time, Bk>
where B1: BatchReader, B2: BatchReader<Time = B1::Time>, Bk: ProxyReduceBackend<B1, B2>,