pub struct TraceAgent<Tr>
where Tr: TraceReader,
{ /* private fields */ }
Expand description

A TraceReader wrapper which can be imported into other dataflows.

The TraceAgent is the default trace type produced by arranged, and it can be extracted from the dataflow in which it was defined, and imported into other dataflows.

Implementations§

source§

impl<Tr: TraceReader> TraceAgent<Tr>

source

pub fn new( trace: Tr, operator: OperatorInfo, logging: Option<Logger>, ) -> (Self, TraceWriter<Tr>)
where Tr: Trace, Tr::Batch: Batch,

Creates a new agent from a trace reader.

source

pub fn new_listener( &mut self, activator: Activator, ) -> Rc<(Activator, RefCell<VecDeque<TraceReplayInstruction<Tr>>>)>

Attaches a new shared queue to the trace.

The queue is first populated with existing batches from the trace, The queue will be immediately populated with existing historical batches from the trace, and until the reference is dropped the queue will receive new batches as produced by the source arrange operator.

source

pub fn operator(&self) -> &OperatorInfo

The OperatorInfo of the underlying Timely operator

source

pub fn trace_box_unstable(&self) -> Rc<RefCell<TraceBox<Tr>>>

Obtain a reference to the inner TraceBox. It is the caller’s obligation to maintain the trace box and this trace agent’s invariants. Specifically, it is undefined behavior to mutate the trace box. Keeping strong references can prevent resource reclamation.

This method is subject to changes and removal and should not be considered part of a stable interface.

source§

impl<Tr> TraceAgent<Tr>
where Tr: TraceReader + 'static,

source

pub fn import<G>(&mut self, scope: &G) -> Arranged<G, TraceAgent<Tr>>
where G: Scope<Timestamp = Tr::Time>,

Copies an existing collection into the supplied scope.

This method creates an Arranged collection that should appear indistinguishable from applying arrange directly to the source collection brought into the local scope. The only caveat is that the initial state of the collection is its current state, and updates occur from this point forward. The historical changes the collection experienced in the past are accumulated, and the distinctions from the initial collection are no longer evident.

The current behavior is that the introduced collection accumulates updates to some times less or equal to self.get_logical_compaction(). There is not currently a guarantee that the updates are accumulated to the frontier, and the resulting collection history may be weirdly partial until this point. In particular, the historical collection may move through configurations that did not actually occur, even if eventually arriving at the correct collection. This is probably a bug; although we get to the right place in the end, the intermediate computation could do something that the original computation did not, like diverge.

I would expect the semantics to improve to “updates are advanced to self.get_logical_compaction()”, which means the computation will run as if starting from exactly this frontier. It is not currently clear whose responsibility this should be (the trace/batch should only reveal these times, or an operator should know to advance times before using them).

§Examples
use timely::Config;
use differential_dataflow::input::Input;
use differential_dataflow::operators::arrange::ArrangeBySelf;
use differential_dataflow::operators::reduce::Reduce;
use differential_dataflow::trace::Trace;

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

    // create a first dataflow
    let mut trace = worker.dataflow::<u32,_,_>(|scope| {
        // create input handle and collection.
        scope.new_collection_from(0 .. 10).1
             .arrange_by_self()
             .trace
    });

    // do some work.
    worker.step();
    worker.step();

    // create a second dataflow
    worker.dataflow(move |scope| {
        trace.import(scope)
             .reduce(move |_key, src, dst| dst.push((*src[0].0, 1)));
    });

}).unwrap();
source

pub fn import_named<G>( &mut self, scope: &G, name: &str, ) -> Arranged<G, TraceAgent<Tr>>
where G: Scope<Timestamp = Tr::Time>,

Same as import, but allows to name the source.

source

pub fn import_core<G>( &mut self, scope: &G, name: &str, ) -> (Arranged<G, TraceAgent<Tr>>, ShutdownButton<CapabilitySet<Tr::Time>>)
where G: Scope<Timestamp = Tr::Time>,

Imports an arrangement into the supplied scope.

§Examples
use timely::Config;
use timely::dataflow::ProbeHandle;
use timely::dataflow::operators::Probe;
use differential_dataflow::input::InputSession;
use differential_dataflow::operators::arrange::ArrangeBySelf;
use differential_dataflow::operators::reduce::Reduce;
use differential_dataflow::trace::Trace;

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

    let mut input = InputSession::<_,(),isize>::new();
    let mut probe = ProbeHandle::new();

    // create a first dataflow
    let mut trace = worker.dataflow::<u32,_,_>(|scope| {
        // create input handle and collection.
        input.to_collection(scope)
             .arrange_by_self()
             .trace
    });

    // do some work.
    worker.step();
    worker.step();

    // create a second dataflow
    let mut shutdown = worker.dataflow(|scope| {
        let (arrange, button) = trace.import_core(scope, "Import");
        arrange.stream.probe_with(&mut probe);
        button
    });

    worker.step();
    worker.step();
    assert!(!probe.done());

    shutdown.press();

    worker.step();
    worker.step();
    assert!(probe.done());

}).unwrap();
source

pub fn import_frontier<G>( &mut self, scope: &G, name: &str, ) -> (Arranged<G, TraceFrontier<TraceAgent<Tr>>>, ShutdownButton<CapabilitySet<Tr::Time>>)
where G: Scope<Timestamp = Tr::Time>, Tr: TraceReader,

Imports an arrangement into the supplied scope.

This variant of import uses the get_logical_compaction to forcibly advance timestamps in updates.

§Examples
use timely::Config;
use timely::progress::frontier::AntichainRef;
use timely::dataflow::ProbeHandle;
use timely::dataflow::operators::Probe;
use timely::dataflow::operators::Inspect;
use differential_dataflow::input::InputSession;
use differential_dataflow::operators::arrange::ArrangeBySelf;
use differential_dataflow::operators::reduce::Reduce;
use differential_dataflow::trace::Trace;
use differential_dataflow::trace::TraceReader;
use differential_dataflow::input::Input;

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

    let mut probe = ProbeHandle::new();

    // create a first dataflow
    let (mut handle, mut trace) = worker.dataflow::<u32,_,_>(|scope| {
        // create input handle and collection.
        let (handle, stream) = scope.new_collection();
        let trace = stream.arrange_by_self().trace;
        (handle, trace)
    });

    handle.insert(0); handle.advance_to(1); handle.flush(); worker.step();
    handle.remove(0); handle.advance_to(2); handle.flush(); worker.step();
    handle.insert(1); handle.advance_to(3); handle.flush(); worker.step();
    handle.remove(1); handle.advance_to(4); handle.flush(); worker.step();
    handle.insert(0); handle.advance_to(5); handle.flush(); worker.step();

    trace.set_logical_compaction(AntichainRef::new(&[5]));

    // create a second dataflow
    let mut shutdown = worker.dataflow(|scope| {
        let (arrange, button) = trace.import_frontier(scope, "Import");
        arrange
            .as_collection(|k,v| (*k,*v))
            .inner
            .inspect(|(d,t,r)| {
                assert!(t >= &5);
            })
            .probe_with(&mut probe);

        button
    });

    worker.step();
    worker.step();
    assert!(!probe.done());

    shutdown.press();

    worker.step();
    worker.step();
    assert!(probe.done());

}).unwrap();
source

pub fn import_frontier_core<G>( &mut self, scope: &G, name: &str, since: Antichain<Tr::Time>, until: Antichain<Tr::Time>, ) -> (Arranged<G, TraceFrontier<TraceAgent<Tr>>>, ShutdownButton<CapabilitySet<Tr::Time>>)
where G: Scope<Timestamp = Tr::Time>, Tr: TraceReader,

Import a trace restricted to a specific time interval [since, until).

All updates present in the input trace will be first advanced to since, and then either emitted, or if greater or equal to until, suppressed. Once all times are certain to be greater or equal to until the operator capability will be dropped.

Invoking this method with an until of Antichain::new() will perform no filtering, as the empty frontier indicates the end of times.

Trait Implementations§

source§

impl<Tr> Clone for TraceAgent<Tr>
where Tr: TraceReader,

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Tr> Drop for TraceAgent<Tr>
where Tr: TraceReader,

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<Tr> TraceReader for TraceAgent<Tr>
where Tr: TraceReader,

§

type Key<'a> = <Tr as TraceReader>::Key<'a>

Key by which updates are indexed.
§

type Val<'a> = <Tr as TraceReader>::Val<'a>

Values associated with keys.
§

type Time = <Tr as TraceReader>::Time

Timestamps associated with updates
§

type TimeGat<'a> = <Tr as TraceReader>::TimeGat<'a>

Borrowed form of timestamp.
§

type Diff = <Tr as TraceReader>::Diff

Owned form of update difference.
§

type DiffGat<'a> = <Tr as TraceReader>::DiffGat<'a>

Borrowed form of update difference.
§

type Batch = <Tr as TraceReader>::Batch

The type of an immutable collection of updates.
§

type Storage = <Tr as TraceReader>::Storage

Storage type for Self::Cursor. Likely related to Self::Batch.
§

type Cursor = <Tr as TraceReader>::Cursor

The type used to enumerate the collections contents.
source§

fn set_logical_compaction(&mut self, frontier: AntichainRef<'_, Tr::Time>)

Advances the frontier that constrains logical compaction. Read more
source§

fn get_logical_compaction(&mut self) -> AntichainRef<'_, Tr::Time>

Reports the logical compaction frontier. Read more
source§

fn set_physical_compaction(&mut self, frontier: AntichainRef<'_, Tr::Time>)

Advances the frontier that constrains physical compaction. Read more
source§

fn get_physical_compaction(&mut self) -> AntichainRef<'_, Tr::Time>

Reports the physical compaction frontier. Read more
source§

fn cursor_through( &mut self, frontier: AntichainRef<'_, Tr::Time>, ) -> Option<(Self::Cursor, Self::Storage)>

Acquires a cursor to the restriction of the collection’s contents to updates at times not greater or equal to an element of upper. Read more
source§

fn map_batches<F: FnMut(&Self::Batch)>(&self, f: F)

Maps logic across the non-empty sequence of batches in the trace. Read more
source§

fn cursor(&mut self) -> (Self::Cursor, Self::Storage)

Provides a cursor over updates contained in the trace.
source§

fn advance_by(&mut self, frontier: AntichainRef<'_, Self::Time>)

👎Deprecated since 0.11: please use set_logical_compaction
Deprecated form of set_logical_compaction.
source§

fn advance_frontier(&mut self) -> AntichainRef<'_, Self::Time>

👎Deprecated since 0.11: please use get_logical_compaction
Deprecated form of get_logical_compaction.
source§

fn distinguish_since(&mut self, frontier: AntichainRef<'_, Self::Time>)

👎Deprecated since 0.11: please use set_physical_compaction
Deprecated form of set_physical_compaction.
source§

fn distinguish_frontier(&mut self) -> AntichainRef<'_, Self::Time>

👎Deprecated since 0.11: please use get_physical_compaction
Deprecated form of get_physical_compaction.
source§

fn read_upper(&mut self, target: &mut Antichain<Self::Time>)

Reads the upper frontier of committed times.
source§

fn advance_upper(&mut self, upper: &mut Antichain<Self::Time>)

Advances upper by any empty batches. Read more

Auto Trait Implementations§

§

impl<Tr> Freeze for TraceAgent<Tr>
where <Tr as TraceReader>::Time: Freeze,

§

impl<Tr> !RefUnwindSafe for TraceAgent<Tr>

§

impl<Tr> !Send for TraceAgent<Tr>

§

impl<Tr> !Sync for TraceAgent<Tr>

§

impl<Tr> Unpin for TraceAgent<Tr>
where <Tr as TraceReader>::Time: Unpin,

§

impl<Tr> !UnwindSafe for TraceAgent<Tr>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> CopyAs<T> for T

source§

fn copy_as(self) -> T

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<'a, S, T> Semigroup<&'a S> for T
where T: Semigroup<S>,

source§

fn plus_equals(&mut self, rhs: &&'a S)

The method of std::ops::AddAssign, for types that do not implement AddAssign.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> Data for T
where T: Clone + 'static,