Trait timely::dataflow::operators::core::inspect::Inspect

source ·
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§

source

fn inspect_core<F>(&self, func: F) -> Self
where F: FnMut(Result<(&G::Timestamp, &C), &[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§

source

fn inspect<F>(&self, func: F) -> Self
where F: for<'a> FnMut(C::ItemRef<'a>) + 'static,

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));
});
source

fn inspect_time<F>(&self, func: F) -> Self
where F: for<'a> FnMut(&G::Timestamp, C::ItemRef<'a>) + 'static,

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));
});
source

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.

Implementors§

source§

impl<G: Scope, C: Container + Data> Inspect<G, C> for StreamCore<G, C>