Skip to main content

Stamp

Struct Stamp 

Source
pub struct Stamp<T> { /* private fields */ }
Expand description

A multiset of timestamps affixed to a message, stored sorted.

The elements are stored in increasing order under Ord so that Eq, Ord, and Hash are structural. Stamps built by insertion are minimal antichains; stamps mapped across scope boundaries may contain comparable or duplicate elements, whose multiplicities are significant for progress accounting.

Equality compares multisets, not the sets of times they contain: {a} and {a, a} are different stamps, as they are accounted differently.

As with Antichain, the storage holds a single element inline, so the overwhelmingly common zero- and one-element stamps require no allocation.

Implementations§

Source§

impl<T> Stamp<T>

Source

pub fn new() -> Self

An empty stamp, making no progress claims.

Source

pub fn from_elem(element: T) -> Self

A stamp containing a single element.

Source

pub fn elements(&self) -> &[T]

The elements of the stamp, in increasing Ord order.

Source

pub fn iter(&self) -> Iter<'_, T> ⓘ

An iterator over the elements of the stamp.

Source

pub fn is_empty(&self) -> bool

True iff the stamp contains no elements.

Source

pub fn len(&self) -> usize

The number of elements in the stamp.

Source

pub fn into_elements(self) -> Vec<T>

The elements of the stamp, by value, in increasing Ord order.

Source

pub fn as_singleton(&self) -> Option<&T>

The sole element of the stamp, if the stamp is a singleton.

Source

pub fn expect_singleton(&self) -> &T
where T: Debug,

The sole element of the stamp; panics if the stamp is not a singleton.

This supports pre-stamp interfaces that insist on a single timestamp per message; such interfaces cannot be used with multi- or zero-element stamps.

Source§

impl<T: TotalOrder> Stamp<T>

Source

pub fn least(&self) -> Option<&T>

The least element of the stamp, if the stamp is non-empty.

Only totally ordered stamps have a least element. A non-empty stamp over a total order has one however many elements it contains, and it is the time at which the message may first result in downstream work.

Elements are stored in Ord order, but TotalOrder speaks only of PartialOrder and need not agree with Ord, so this is a reduction rather than first().

Source§

impl<T: PartialOrder + Ord> Stamp<T>

Source

pub fn insert(&mut self, element: T) -> bool

Inserts element unless it is redundant, removing elements it dominates.

Returns true iff the element was inserted.

Source

pub fn less_equal(&self, time: &T) -> bool

True iff some element of the stamp is less or equal to time.

Source

pub fn map_into<T2: PartialOrder + Ord>( &self, logic: impl FnMut(&T) -> Option<T2>, ) -> Stamp<T2>

Maps each element through logic, discarding None results and restoring minimality and canonical order.

This is the shape required when timestamps traverse path summaries (feedback edges), where elements may fail to traverse, or may become comparable after mapping. It may only be used by operators that account for their own consumed and produced messages, as it changes the number of pointstamps a message is accounted at.

Source

pub fn map_pointwise<T2: Ord>(&self, logic: impl FnMut(&T) -> T2) -> Stamp<T2>

Maps each element through logic, preserving the number of elements and restoring sorted order, but not minimality.

This is the shape required at scope boundaries (enter and leave), whose produced and consumed accounting is inferred independently at either end of the channel from the stamp itself: the counts must agree element-wise, so the map must not collapse elements that become comparable or equal after mapping (as when leaving a scope projects away a timestamp coordinate). The resulting stamp may contain comparable or duplicate elements; this weakens no guarantee, as the stamp promises only that message contents are greater or equal to some element.

Trait Implementations§

Source§

impl<T: Clone> Clone for Stamp<T>

Source§

fn clone(&self) -> Stamp<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T> Columnar for Stamp<T>

Source§

type Container = StampContainer<<SmallVec<[T; 1]> as Columnar>::Container>

The type that stores the columnar representation. Read more
Source§

fn copy_from<'a>(&mut self, other: Ref<'a, Self>)

Repopulates self from a reference. Read more
Source§

fn into_owned<'a>(other: Ref<'a, Self>) -> Self

Produce an instance of Self from Self::Ref<'a>.
Source§

fn as_columns<'a, I>(selves: I) -> Self::Container
where I: IntoIterator<Item = &'a Self>, Self: 'a,

Converts a sequence of the references to the type into columnar form.
Source§

fn into_columns<I>(selves: I) -> Self::Container
where I: IntoIterator<Item = Self>, Self: Sized,

Converts a sequence of the type into columnar form. Read more
Source§

fn reborrow<'b, 'a>( thing: <Self::Container as Borrow>::Ref<'a>, ) -> <Self::Container as Borrow>::Ref<'b>
where 'a: 'b,

Reborrows the reference type to a shorter lifetime. Read more
Source§

impl<T: Debug> Debug for Stamp<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for Stamp<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de, T: Deserialize<'de> + Ord> Deserialize<'de> for Stamp<T>

Deserialization sorts the elements, as the bytes need not come from a valid Stamp.

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T: Eq> Eq for Stamp<T>

Source§

impl<T: PartialOrder + Ord + Clone> From<Antichain<T>> for Stamp<T>

Source§

fn from(antichain: Antichain<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: PartialOrder + Ord + Clone> From<Stamp<T>> for Antichain<T>

Source§

fn from(stamp: Stamp<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: PartialOrder + Ord> FromIterator<T> for Stamp<T>

Source§

fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<T: Hash> Hash for Stamp<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a, T> IntoIterator for &'a Stamp<T>

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T: Ord> Ord for Stamp<T>

Source§

fn cmp(&self, other: &Stamp<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl<T: PartialEq> PartialEq for Stamp<T>

Source§

fn eq(&self, other: &Stamp<T>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T, R0> PartialEq<Stamp<T>> for StampReference<R0>

Source§

fn eq(&self, other: &Stamp<T>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T: PartialOrd> PartialOrd for Stamp<T>

Source§

fn partial_cmp(&self, other: &Stamp<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'columnar, T, C0> Push<&'columnar Stamp<T>> for StampContainer<C0>
where C0: Push<&'columnar SmallVec<[T; 1]>>,

Source§

fn push(&mut self, item: &'columnar Stamp<T>)

Pushes an item onto self.
Source§

fn extend(&mut self, iter: impl IntoIterator<Item = T>)

Pushes elements of an iterator onto self.
Source§

impl<T, C0> Push<Stamp<T>> for StampContainer<C0>
where C0: Push<SmallVec<[T; 1]>>,

Source§

fn push(&mut self, item: Stamp<T>)

Pushes an item onto self.
Source§

fn extend(&mut self, iter: impl IntoIterator<Item = T>)

Pushes elements of an iterator onto self.
Source§

impl<T> Serialize for Stamp<T>
where T: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: PartialEq> StructuralPartialEq for Stamp<T>

Auto Trait Implementations§

§

impl<T> Freeze for Stamp<T>

§

impl<T> RefUnwindSafe for Stamp<T>

§

impl<T> Send for Stamp<T>

§

impl<T> Sync for Stamp<T>

§

impl<T> Unpin for Stamp<T>

§

impl<T> UnsafeUnpin for Stamp<T>

§

impl<T> UnwindSafe for Stamp<T>

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§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

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

impl<T> Data for T
where T: Send + Any + Serialize + for<'a> Deserialize<'a>,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

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>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.