forked from TimelyDataflow/differential-dataflow
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmod.rs
56 lines (48 loc) · 2.1 KB
/
mod.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! Traits and types for navigating order sequences of update tuples.
//!
//! The `Cursor` trait contains several methods for efficiently navigating ordered collections
//! of tuples of the form `(key, val, time, diff)`. The cursor is different from an iterator
//! both because it allows navigation on multiple levels (key and val), but also because it
//! supports efficient seeking (via the `seek_key` and `seek_val` methods).
pub mod viewers;
pub mod cursor_list;
// pub mod cursor_pair;
/// A cursor for navigating ordered `(key, val, time, diff)` updates.
pub trait Cursor {
/// Type of key used by cursor.
type Key: Ord;
/// Type of value used by cursor.
type Val: Ord;
/// Time of timestamp used by cursor.
type Time: Ord;
/// Indicates if the current key is valid.
///
/// A value of `false` indicates that the cursor has exhausted all keys.
fn key_valid(&self) -> bool;
/// Indicates if the current value is valid.
///
/// A value of `false` indicates that the cursor has exhausted all values for this key.
fn val_valid(&self) -> bool;
/// A reference to the current key. Asserts if invalid.
fn key(&self) -> &Self::Key;
/// A reference to the current value. Asserts if invalid.
fn val(&self) -> &Self::Val;
/// Applies `logic` to each pair of time and difference.
fn map_times<L: FnMut(&Self::Time, isize)>(&self, logic: L);
/// Advances the cursor to the next key. Indicates if the key is valid.
fn step_key(&mut self);
/// Advances the cursor to the specified key. Indicates if the key is valid.
fn seek_key(&mut self, key: &Self::Key);
/// Reveals the next key, if it is valid.
fn peek_key(&self) -> Option<&Self::Key>;
/// Advances the cursor to the next value. Indicates if the value is valid.
fn step_val(&mut self);
/// Advances the cursor to the specified value. Indicates if the value is valid.
fn seek_val(&mut self, val: &Self::Val);
/// Reveals the next value, if it is valid.
fn peek_val(&self) -> Option<&Self::Val>;
/// Rewinds the cursor to the first key.
fn rewind_keys(&mut self);
/// Rewinds the cursor to the first value for current key.
fn rewind_vals(&mut self);
}