Trait timely::dataflow::operators::branch::Branch[][src]

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

Extension trait for Stream.

Required methods

fn branch(
    &self,
    condition: impl Fn(&S::Timestamp, &D) -> bool + 'static
) -> (Stream<S, D>, Stream<S, D>)
[src]

Takes one input stream and splits it into two output streams. For each record, the supplied closure is called with a reference to the data and its time. If it returns true, the record will be sent to the second returned stream, otherwise it will be sent to the first.

If the result of the closure only depends on the time, not the data, branch_when should be used instead.

Examples

use timely::dataflow::operators::{ToStream, Branch, Inspect};

timely::example(|scope| {
    let (odd, even) = (0..10)
        .to_stream(scope)
        .branch(|_time, x| *x % 2 == 0);

    even.inspect(|x| println!("even numbers: {:?}", x));
    odd.inspect(|x| println!("odd numbers: {:?}", x));
});
Loading content...

Implementors

impl<S: Scope, D: Data> Branch<S, D> for Stream<S, D>[src]

Loading content...