pub trait Partition<G: Scope, D: Data, D2: Data, F: Fn(D) -> (u64, D2)> {
// Required method
fn partition(&self, parts: u64, route: F) -> Vec<Stream<G, D2>>;
}
Expand description
Partition a stream of records into multiple streams.
Required Methods§
sourcefn partition(&self, parts: u64, route: F) -> Vec<Stream<G, D2>>
fn partition(&self, parts: u64, route: F) -> Vec<Stream<G, D2>>
Produces parts
output streams, containing records produced and assigned by route
.
§Examples
use timely::dataflow::operators::{ToStream, Partition, Inspect};
timely::example(|scope| {
let streams = (0..10).to_stream(scope)
.partition(3, |x| (x % 3, x));
streams[0].inspect(|x| println!("seen 0: {:?}", x));
streams[1].inspect(|x| println!("seen 1: {:?}", x));
streams[2].inspect(|x| println!("seen 2: {:?}", x));
});