Trait timely::dataflow::operators::partition::Partition

source ·
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§

source

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));
});

Implementors§

source§

impl<G: Scope, D: Data, D2: Data, F: Fn(D) -> (u64, D2) + 'static> Partition<G, D, D2, F> for Stream<G, D>