[−][src]Trait timely::dataflow::operators::count::Accumulate
Accumulates records within a timestamp.
Required methods
fn accumulate<A: Data>(
&self,
default: A,
logic: impl Fn(&mut A, RefOrMut<Vec<D>>) + 'static
) -> Stream<G, A>
&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
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])]);