diff --git a/differential-dataflow/src/trace/cursor/mod.rs b/differential-dataflow/src/trace/cursor/mod.rs index 4c893de22..2b563ea37 100644 --- a/differential-dataflow/src/trace/cursor/mod.rs +++ b/differential-dataflow/src/trace/cursor/mod.rs @@ -6,6 +6,7 @@ //! supports efficient seeking (via the `seek_key` and `seek_val` methods). pub mod cursor_list; +pub mod wrappers; pub use self::cursor_list::CursorList; diff --git a/differential-dataflow/src/trace/cursor/wrappers/enter.rs b/differential-dataflow/src/trace/cursor/wrappers/enter.rs new file mode 100644 index 000000000..dec50e2bc --- /dev/null +++ b/differential-dataflow/src/trace/cursor/wrappers/enter.rs @@ -0,0 +1,81 @@ +//! Cursor for the `enter` batch wrapper. + +use timely::progress::timestamp::Refines; + +use crate::lattice::Lattice; +use crate::trace::implementations::BatchContainer; +use crate::trace::wrappers::enter::BatchEnter; +use crate::trace::{BatchReader, Navigable}; +use crate::trace::cursor::Cursor; + +impl Navigable for BatchEnter +where + B: BatchReader + Navigable, + TInner: Refines+Lattice, + TInner: Refines<::Time>, +{ + type Cursor = BatchCursorEnter; + + fn cursor(&self) -> Self::Cursor { + BatchCursorEnter::new(self.inner().cursor()) + } +} + +/// Wrapper to provide cursor to nested scope. +pub struct BatchCursorEnter { + phantom: ::std::marker::PhantomData, + cursor: C, +} + +impl BatchCursorEnter { + fn new(cursor: C) -> Self { + BatchCursorEnter { + phantom: ::std::marker::PhantomData, + cursor, + } + } +} + +impl Cursor for BatchCursorEnter +where + TInner: Refines+Lattice, +{ + type Storage = BatchEnter; + + type Key<'a> = C::Key<'a>; + type ValOwn = C::ValOwn; + type Val<'a> = C::Val<'a>; + type KeyContainer = C::KeyContainer; + type ValContainer = C::ValContainer; + type DiffContainer = C::DiffContainer; + type Diff = C::Diff; + type DiffGat<'a> = C::DiffGat<'a>; + type TimeContainer = Vec; + type Time = as BatchContainer>::Owned; + type TimeGat<'a> = as BatchContainer>::ReadItem<'a>; + + #[inline] fn key_valid(&self, storage: &Self::Storage) -> bool { self.cursor.key_valid(storage.inner()) } + #[inline] fn val_valid(&self, storage: &Self::Storage) -> bool { self.cursor.val_valid(storage.inner()) } + + #[inline] fn key<'a>(&self, storage: &'a Self::Storage) -> Self::Key<'a> { self.cursor.key(storage.inner()) } + #[inline] fn val<'a>(&self, storage: &'a Self::Storage) -> Self::Val<'a> { self.cursor.val(storage.inner()) } + + #[inline] fn get_key<'a>(&self, storage: &'a Self::Storage) -> Option> { self.cursor.get_key(storage.inner()) } + #[inline] fn get_val<'a>(&self, storage: &'a Self::Storage) -> Option> { self.cursor.get_val(storage.inner()) } + + #[inline] + fn map_times)>(&mut self, storage: &Self::Storage, mut logic: L) { + self.cursor.map_times(storage.inner(), |time, diff| { + logic(&TInner::to_inner(C::owned_time(time)), diff) + }) + } + + #[inline] fn step_key(&mut self, storage: &Self::Storage) { self.cursor.step_key(storage.inner()) } + #[inline] fn seek_key(&mut self, storage: &Self::Storage, key: Self::Key<'_>) { self.cursor.seek_key(storage.inner(), key) } + + #[inline] fn step_val(&mut self, storage: &Self::Storage) { self.cursor.step_val(storage.inner()) } + #[inline] fn seek_val(&mut self, storage: &Self::Storage, val: Self::Val<'_>) { self.cursor.seek_val(storage.inner(), val) } + + #[inline] fn rewind_keys(&mut self, storage: &Self::Storage) { self.cursor.rewind_keys(storage.inner()) } + #[inline] fn rewind_vals(&mut self, storage: &Self::Storage) { self.cursor.rewind_vals(storage.inner()) } +} diff --git a/differential-dataflow/src/trace/cursor/wrappers/frontier.rs b/differential-dataflow/src/trace/cursor/wrappers/frontier.rs new file mode 100644 index 000000000..26d2e28ae --- /dev/null +++ b/differential-dataflow/src/trace/cursor/wrappers/frontier.rs @@ -0,0 +1,74 @@ +//! Cursor for the `frontier` batch wrapper. + +use crate::trace::implementations::BatchContainer; +use crate::trace::wrappers::frontier::BatchFrontier; +use crate::trace::{BatchReader, Navigable}; +use crate::trace::cursor::Cursor; + +impl Navigable for BatchFrontier +where + B: BatchReader + Navigable, + B::Cursor: Cursor