Last active
August 11, 2017 10:18
-
-
Save milibopp/7c7959ac58e2d3575af9487d75ec2f22 to your computer and use it in GitHub Desktop.
While-loop in timely dataflow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate timely; | |
use timely::*; | |
use timely::dataflow::operators::*; | |
use std::iter::once; | |
fn main() { | |
execute_from_args(std::env::args(), |worker| { | |
let index = worker.index(); | |
worker.dataflow(|scope| { | |
let (helper, state) = scope.loop_variable(std::u64::MAX, 1); | |
let state = once(0).to_stream(scope) | |
.concat(&state) | |
.map(|i| i + 1) | |
.filter(|i| *i < 5); | |
state | |
.inspect(move |i| println!("{}: state {}", index, i)); | |
state | |
.connect_loop(helper); | |
}); | |
}).unwrap(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment