|
1 | 1 | //! Types and operators to feed outputs into external systems. |
2 | 2 |
|
3 | | -use std::time::Duration; |
| 3 | +use std::fs::File; |
| 4 | +use std::io::{LineWriter, Write}; |
| 5 | +use std::time::{Duration, Instant}; |
4 | 6 |
|
5 | 7 | use timely::dataflow::channels::pact::ParallelizationContract; |
6 | 8 | use timely::dataflow::operators::generic::builder_rc::OperatorBuilder; |
|
40 | 42 | #[derive(Hash, PartialEq, Eq, PartialOrd, Ord, Clone, Debug, Serialize, Deserialize)] |
41 | 43 | pub enum Sink { |
42 | 44 | /// /dev/null, used for benchmarking |
43 | | - TheVoid, |
| 45 | + TheVoid(String), |
44 | 46 | /// CSV files |
45 | 47 | #[cfg(feature = "csv-source")] |
46 | 48 | CsvFile(CsvFile), |
@@ -75,18 +77,28 @@ impl Sinkable<Duration> for Sink { |
75 | 77 | P: ParallelizationContract<S::Timestamp, ResultDiff<Duration>>, |
76 | 78 | { |
77 | 79 | match *self { |
78 | | - Sink::TheVoid => { |
79 | | - let mut builder = OperatorBuilder::new("TheVoid".to_owned(), stream.scope()); |
| 80 | + Sink::TheVoid(ref name) => { |
| 81 | + let file = File::create(name).unwrap(); |
| 82 | + let mut writer = LineWriter::new(file); |
| 83 | + |
| 84 | + let mut builder = OperatorBuilder::new(name.to_owned(), stream.scope()); |
80 | 85 | let mut input = builder.new_input(stream, pact); |
81 | 86 | let (_output, sunk) = builder.new_output(); |
82 | 87 |
|
83 | 88 | builder.build(|_capabilities| { |
| 89 | + let mut t0 = Instant::now(); |
| 90 | + let mut last = Duration::from_millis(0); |
| 91 | + |
84 | 92 | move |frontiers| { |
85 | | - let mut input_handle = |
86 | | - FrontieredInputHandle::new(&mut input, &frontiers[0]); |
| 93 | + let input_handle = FrontieredInputHandle::new(&mut input, &frontiers[0]); |
87 | 94 |
|
88 | 95 | if input_handle.frontier.is_empty() { |
89 | | - println!("Inputs to void sink have ceased."); |
| 96 | + println!("[{:?}] inputs to void sink ceased", t0.elapsed()); |
| 97 | + } else if !input_handle.frontier.frontier().less_equal(&last) { |
| 98 | + write!(writer, "{},{:?}\n", t0.elapsed().as_millis(), last).unwrap(); |
| 99 | + |
| 100 | + last = input_handle.frontier.frontier()[0].clone(); |
| 101 | + t0 = Instant::now(); |
90 | 102 | } |
91 | 103 | } |
92 | 104 | }); |
|
0 commit comments