pub trait Partition<G: Scope, C: Container> {
// Required method
fn partition<CB, D2, F>(
&self,
parts: u64,
route: F,
) -> Vec<StreamCore<G, CB::Container>>
where CB: ContainerBuilder,
CB::Container: SizableContainer + PushInto<D2> + Data,
F: FnMut(C::Item<'_>) -> (u64, D2) + 'static;
}
Expand description
Partition a stream of records into multiple streams.
Required Methods§
sourcefn partition<CB, D2, F>(
&self,
parts: u64,
route: F,
) -> Vec<StreamCore<G, CB::Container>>where
CB: ContainerBuilder,
CB::Container: SizableContainer + PushInto<D2> + Data,
F: FnMut(C::Item<'_>) -> (u64, D2) + 'static,
fn partition<CB, D2, F>(
&self,
parts: u64,
route: F,
) -> Vec<StreamCore<G, CB::Container>>where
CB: ContainerBuilder,
CB::Container: SizableContainer + PushInto<D2> + Data,
F: FnMut(C::Item<'_>) -> (u64, D2) + 'static,
Produces parts
output streams, containing records produced and assigned by route
.
§Examples
use timely::dataflow::operators::ToStream;
use timely::dataflow::operators::core::{Partition, Inspect};
timely::example(|scope| {
let streams = (0..10).to_stream(scope)
.partition(3, |x| (x % 3, x));
for (idx, stream) in streams.into_iter().enumerate() {
stream
.container::<Vec<_>>()
.inspect(move |x| println!("seen {idx}: {x:?}"));
}
});
Object Safety§
This trait is not object safe.