Skip to main content

reduce_trace

Function reduce_trace 

Source
pub fn reduce_trace<'scope, Tr1, Bu, Tr2, L, P>(
    trace: Arranged<'scope, Tr1>,
    name: &str,
    logic: L,
    push: P,
) -> Arranged<'scope, TraceAgent<Tr2>>
where Tr1: TraceReader + Clone + 'static, Tr2: for<'a> Trace<Key<'a> = Tr1::Key<'a>, ValOwn: Data, Time = Tr1::Time> + 'static, Bu: Builder<Time = Tr2::Time, Output = Tr2::Batch, Input: Default>, L: FnMut(Tr1::Key<'_>, &[(Tr1::Val<'_>, Tr1::Diff)], &mut Vec<(Tr2::ValOwn, Tr2::Diff)>, &mut Vec<(Tr2::ValOwn, Tr2::Diff)>) + 'static, P: FnMut(&mut Bu::Input, Tr1::Key<'_>, &mut Vec<(Tr2::ValOwn, Tr2::Time, Tr2::Diff)>) + 'static,
Expand description

A key-wise reduction of values in an input trace.

This method exists to provide reduce functionality without opinions about qualifying trace types.

The logic closure is expected to take a key, accumulated input, and tentative accumulated output, and populate its final argument with whatever it feels to be appopriate updates. The behavior and correctness of the implementation rely on this making sense, and e.g. ideally the updates would if applied to the tentative output bring it in line with some function applied to the input.

The push closure is expected to clear its first argument, then populate it with the key and drain the value updates, as appropriate for the container. It is critical that it clear the container as the operator has no ability to do this otherwise, and failing to do so represents a leak from one key’s computation to another, and will likely introduce non-determinism.