Skip to main content

Partition

Trait Partition 

Source
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§

Source

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

Implementors§

Source§

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