Trait timely::dataflow::operators::core::capture::extract::Extract

source ·
pub trait Extract<T, C> {
    // Required method
    fn extract(self) -> Vec<(T, C)>;
Expand description

Supports extracting a sequence of timestamp and data.

Required Methods§


fn extract(self) -> Vec<(T, C)>

Converts self into a sequence of timestamped data.

Currently this is only implemented for Receiver<Event<T, C>>, and is used only to easily pull data out of a timely dataflow computation once it has completed.

use std::rc::Rc;
use std::sync::{Arc, Mutex};
use timely::dataflow::Scope;
use timely::dataflow::operators::{Capture, ToStream, Inspect};
use timely::dataflow::operators::capture::{EventLink, Replay, Extract};

// get send and recv endpoints, wrap send to share
let (send, recv) = ::std::sync::mpsc::channel();
let send = Arc::new(Mutex::new(send));

timely::execute(timely::Config::thread(), move |worker| {

    // this is only to validate the output.
    let send = send.lock().unwrap().clone();

    // these are to capture/replay the stream.
    let handle1 = Rc::new(EventLink::new());
    let handle2 = Some(handle1.clone());


    worker.dataflow(|scope2| {

assert_eq!(recv.extract().into_iter().flat_map(|x| x.1).collect::<Vec<_>>(), (0..10).collect::<Vec<_>>());

Implementations on Foreign Types§


impl<T: Ord, C> Extract<T, C> for Receiver<Event<T, C>>
where for<'a> C: PushInto<C::Item<'a>> + SizableContainer, for<'a> C::Item<'a>: Ord,