Skip to main content

Timestamp

Trait Timestamp 

Source
pub trait Timestamp:
    DBData
    + PartialOrder
    + Lattice {
    type Nested: Timestamp;
    type TimedBatch<B: Batch<Time = ()>>: Batch<Key = B::Key, Val = B::Val, Time = Self, R = B::R>;

    const NESTING_DEPTH: usize;

    // Required methods
    fn minimum() -> Self;
    fn advance(&self, scope: Scope) -> Self;
    fn checked_recede(&self, scope: Scope) -> Option<Self>;
    fn epoch_start(&self, scope: Scope) -> Self;
    fn epoch_end(&self, scope: Scope) -> Self;

    // Provided methods
    fn clock_start() -> Self { ... }
    fn recede(&self, scope: Scope) -> Self { ... }
}
Expand description

Logical timestamp.

See crate documentation for an overview of logical time in DBSP.

Required Associated Constants§

Source

const NESTING_DEPTH: usize

Nesting depth of the circuit running this clock.

0 - for the top-level clock, 1 - first-level nested circuit, etc.

Required Associated Types§

Source

type Nested: Timestamp

Source

type TimedBatch<B: Batch<Time = ()>>: Batch<Key = B::Key, Val = B::Val, Time = Self, R = B::R>

A version of a batch type B with Self used as a timestamp.

If Self = (), then TimedBatch<B> is B. Otherwise, TimedBatch<B> = B::Timed<Self>.

Required Methods§

Source

fn minimum() -> Self

Source

fn advance(&self, scope: Scope) -> Self

Advance the timestamp by one clock tick.

Advance self by one clock tick by incrementing the clock at the specified nesting level by one, while resetting all clocks at deeper nesting levels to 0. scope identifies the nesting level of the circuit whose clock is ticking. 0 refers to the innermost circuit. 1 is its parent circuit, etc. Returns the most accurate approximation of the new timestamp value supported by this time representation.

§Example

Assume a two-dimensional time modeled as (parent time, child time) tuple.

assert_eq!((2, 3).advance(0), (2, 4));
assert_eq!((2, 3).advance(1), (3, 0));
Source

fn checked_recede(&self, scope: Scope) -> Option<Self>

Like recede, but returns None if the clock at level scope is equal to zero (i.e., we are running the first clock cycle) and hence cannot be decremented.

Source

fn epoch_start(&self, scope: Scope) -> Self

Returns the first time stamp of the current clock epoch in scope.

Source

fn epoch_end(&self, scope: Scope) -> Self

Advance self to the end of the current clock epoch in scope.

Provided Methods§

Source

fn clock_start() -> Self

The value of the timestamp when the clock starts ticking.

This is typically but not always equal to Self::minimum. For example, we use 1-bit timestamp that starts at value 1 (current clock epoch), value 0 (previous epochs) can only be obtained by calling recede.

Source

fn recede(&self, scope: Scope) -> Self

Push the timestamp back by one clock tick.

Push self back by one clock cycle by decrementing the clock at the specified nesting level by one. scope identifies the nesting level of the circuit whose clock is ticking. 0 refers to the innermost circuit. 1 is its parent circuit, etc.

§Panics

Panics if the clock at the scope nesting level is equal to zero (i.e., we are running the first clock cycle) and hence cannot be decremented.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Timestamp for u32

Source§

const NESTING_DEPTH: usize = 0

Source§

type Nested = Product<u32, u32>

Source§

type TimedBatch<B: Batch<Time = ()>> = <B as Batch>::Timed<u32>

Source§

fn minimum() -> Self

Source§

fn advance(&self, _scope: Scope) -> Self

Source§

fn recede(&self, _scope: Scope) -> Self

Source§

fn checked_recede(&self, _scope: Scope) -> Option<Self>

Source§

fn epoch_start(&self, _scope: Scope) -> Self

Source§

fn epoch_end(&self, _scope: Scope) -> Self

Source§

impl Timestamp for ()

Source§

const NESTING_DEPTH: usize = 0

Source§

type TimedBatch<B: Batch<Time = ()>> = B

Source§

type Nested = Product<u32, u32>

Source§

fn minimum() -> Self

Source§

fn advance(&self, _scope: Scope) -> Self

Source§

fn recede(&self, _scope: Scope) -> Self

Source§

fn checked_recede(&self, _scope: Scope) -> Option<Self>

Source§

fn epoch_start(&self, _scope: Scope) -> Self

Source§

fn epoch_end(&self, _scope: Scope) -> Self

Implementors§

Source§

impl Timestamp for UnitTimestamp

Source§

impl<TOuter, TInner> Timestamp for Product<TOuter, TInner>
where TOuter: Timestamp, TInner: Timestamp,

Source§

const NESTING_DEPTH: usize

Source§

type Nested = Product<Product<TOuter, TInner>, u32>

Source§

type TimedBatch<B: Batch<Time = ()>> = <B as Batch>::Timed<Product<TOuter, TInner>>