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