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::Item]), &[G::Timestamp]>) + 'static;
// Provided methods
fn inspect(&self, func: impl FnMut(&C::Item) + 'static) -> Self { ... }
fn inspect_time(
&self,
func: impl FnMut(&G::Timestamp, &C::Item) + 'static
) -> Self { ... }
fn inspect_batch(
&self,
func: impl FnMut(&G::Timestamp, &[C::Item]) + 'static
) -> Self { ... }
}
Expand description
Methods to inspect records and batches of records on a stream.
Required Methods§
sourcefn inspect_core<F>(&self, func: F) -> Selfwhere
F: FnMut(Result<(&G::Timestamp, &[C::Item]), &[G::Timestamp]>) + 'static,
fn inspect_core<F>(&self, func: F) -> Selfwhere F: FnMut(Result<(&G::Timestamp, &[C::Item]), &[G::Timestamp]>) + 'static,
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(&self, func: impl FnMut(&C::Item) + 'static) -> Self
fn inspect(&self, func: impl FnMut(&C::Item) + 'static) -> 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(
&self,
func: impl FnMut(&G::Timestamp, &C::Item) + 'static
) -> Self
fn inspect_time( &self, func: impl FnMut(&G::Timestamp, &C::Item) + 'static ) -> 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::Item]) + 'static
) -> Self
fn inspect_batch( &self, func: impl FnMut(&G::Timestamp, &[C::Item]) + '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()));
});