Trait timely::dataflow::operators::count::Accumulate

source ·
pub trait Accumulate<G: Scope, D: Data> {
    // Required method
    fn accumulate<A: Data>(
        &self,
        default: A,
        logic: impl Fn(&mut A, RefOrMut<'_, Vec<D>>) + 'static
    ) -> Stream<G, A>;

    // Provided method
    fn count(&self) -> Stream<G, usize> { ... }
}
Expand description

Accumulates records within a timestamp.

Required Methods§

source

fn accumulate<A: Data>( &self, default: A, logic: impl Fn(&mut A, RefOrMut<'_, Vec<D>>) + 'static ) -> Stream<G, A>

Accumulates records within a timestamp.

§Examples
use timely::dataflow::operators::{ToStream, Accumulate, Capture};
use timely::dataflow::operators::capture::Extract;

let captured = timely::example(|scope| {
    (0..10).to_stream(scope)
           .accumulate(0, |sum, data| { for &x in data.iter() { *sum += x; } })
           .capture()
});

let extracted = captured.extract();
assert_eq!(extracted, vec![(0, vec![45])]);

Provided Methods§

source

fn count(&self) -> Stream<G, usize>

Counts the number of records observed at each time.

§Examples
use timely::dataflow::operators::{ToStream, Accumulate, Capture};
use timely::dataflow::operators::capture::Extract;

let captured = timely::example(|scope| {
    (0..10).to_stream(scope)
           .count()
           .capture()
});

let extracted = captured.extract();
assert_eq!(extracted, vec![(0, vec![10])]);

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<G: Scope, D: Data> Accumulate<G, D> for Stream<G, D>