pub trait Inspect<G: Scope, C: Container>: InspectCore<G, C> + Sized {
// Required method
fn inspect_core<F>(&self, func: F) -> Self
where F: FnMut(Result<(&G::Timestamp, &C), &[G::Timestamp]>) + 'static;
// Provided methods
fn inspect<F>(&self, func: F) -> Self
where F: for<'a> FnMut(C::ItemRef<'a>) + 'static { ... }
fn inspect_time<F>(&self, func: F) -> Self
where F: for<'a> FnMut(&G::Timestamp, C::ItemRef<'a>) + 'static { ... }
fn inspect_batch(
&self,
func: impl FnMut(&G::Timestamp, &C) + 'static,
) -> Self { ... }
}
Expand description
Methods to inspect records and batches of records on a stream.
Required Methods§
sourcefn inspect_core<F>(&self, func: F) -> Self
fn inspect_core<F>(&self, func: F) -> Self
Runs a supplied closure on each observed data batch, and each frontier advancement.
Rust’s Result
type is used to distinguish the events, with Ok
for time and data,
and Err
for frontiers. Frontiers are only presented when they change.
§Examples
use timely::dataflow::operators::{ToStream, Map, Inspect};
timely::example(|scope| {
(0..10).to_stream(scope)
.inspect_core(|event| {
match event {
Ok((time, data)) => println!("seen at: {:?}\t{:?} records", time, data.len()),
Err(frontier) => println!("frontier advanced to {:?}", frontier),
}
});
});
Provided Methods§
sourcefn inspect<F>(&self, func: F) -> Self
fn inspect<F>(&self, func: F) -> Self
Runs a supplied closure on each observed data element.
§Examples
use timely::dataflow::operators::{ToStream, Map, Inspect};
timely::example(|scope| {
(0..10).to_stream(scope)
.inspect(|x| println!("seen: {:?}", x));
});
sourcefn inspect_time<F>(&self, func: F) -> Self
fn inspect_time<F>(&self, func: F) -> Self
Runs a supplied closure on each observed data element and associated time.
§Examples
use timely::dataflow::operators::{ToStream, Map, Inspect};
timely::example(|scope| {
(0..10).to_stream(scope)
.inspect_time(|t, x| println!("seen at: {:?}\t{:?}", t, x));
});
sourcefn inspect_batch(&self, func: impl FnMut(&G::Timestamp, &C) + 'static) -> Self
fn inspect_batch(&self, func: impl FnMut(&G::Timestamp, &C) + 'static) -> Self
Runs a supplied closure on each observed data batch (time and data slice).
§Examples
use timely::dataflow::operators::{ToStream, Map, Inspect};
timely::example(|scope| {
(0..10).to_stream(scope)
.inspect_batch(|t,xs| println!("seen at: {:?}\t{:?} records", t, xs.len()));
});
Object Safety§
This trait is not object safe.