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 + PushInto<D2>,
CB::Container: 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>>
fn partition<CB, D2, F>( &self, parts: u64, route: F, ) -> Vec<StreamCore<G, CB::Container>>
Produces parts
output streams, containing records produced and assigned by route
.
§Examples
use timely::dataflow::operators::ToStream;
use timely::dataflow::operators::core::{Partition, Inspect};
use timely_container::CapacityContainerBuilder;
timely::example(|scope| {
let streams = (0..10).to_stream(scope)
.partition::<CapacityContainerBuilder<Vec<_>>, _, _>(3, |x| (x % 3, x));
for (idx, stream) in streams.into_iter().enumerate() {
stream
.inspect(move |x| println!("seen {idx}: {x:?}"));
}
});
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.