pub trait BranchWhen<S: Scope, D: Data> {
    fn branch_when(
        &self,
        condition: impl Fn(&S::Timestamp) -> bool + 'static
    ) -> (Stream<S, D>, Stream<S, D>); }
Expand description

Extension trait for Stream.

Required Methods

Takes one input stream and splits it into two output streams. For each time, the supplied closure is called. If it returns true, the records for that will be sent to the second returned stream, otherwise they will be sent to the first.

Examples
use timely::dataflow::operators::{ToStream, BranchWhen, Inspect, Delay};

timely::example(|scope| {
    let (before_five, after_five) = (0..10)
        .to_stream(scope)
        .delay(|x,t| *x) // data 0..10 at time 0..10
        .branch_when(|time| time >= &5);

    before_five.inspect(|x| println!("Times 0-4: {:?}", x));
    after_five.inspect(|x| println!("Times 5 and later: {:?}", x));
});

Implementors