pub trait Accumulate<G: Scope, D: Data> {
// Required method
fn accumulate<A: Data>(
&self,
default: A,
logic: impl Fn(&mut A, &mut Vec<D>) + 'static,
) -> Stream<G, A>;
// Provided method
fn count(&self) -> Stream<G, usize> { ... }
}
Expand description
Accumulates records within a timestamp.
Required Methods§
sourcefn accumulate<A: Data>(
&self,
default: A,
logic: impl Fn(&mut A, &mut Vec<D>) + 'static,
) -> Stream<G, A>
fn accumulate<A: Data>( &self, default: A, logic: impl Fn(&mut A, &mut 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§
sourcefn count(&self) -> Stream<G, usize>
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.