[][src]Struct actyxos_sdk::event::OffsetMap

pub struct OffsetMap(_);

Multi-dimensional cursor for event streams: an OffsetMap describes the set of events given by the event streams of each included source up to the associated Offset.

All stream delivery modes supported by the Event Service respect the order of offsets of the events published by each single ActyxOS node. This order is consistent with the Lamport timestamp order because both numbers are assigned to published events in strictly monotonically increasing fashion, i.e. greater Offset implies greater Lamport timestamp and vice versa.

Note that if the OffsetMap contains offset 42 for SourceID "abc" it denotes that events with offsets 0 through 42 (inclusive) are included within the OffsetMap.

A common usage pattern is to store the OffsetMap describing the events already consumed from an event stream together with the computation results from processing those events (preferably within the same database transaction, if applicable). When restarting the process, this OffsetMap can be read and the stream can be resumed from where the process left off previously.

Arithmetics

OffsetMap has a partial order: when the set of events described by one is a strict subset of the set of events described by another, then one is said to be smaller than the other. It may be that one OffsetMap contains events that the other does not and vice versa, in which case they are incomparable (partial_cmp will return None).

An event may be added into an OffsetMap to denote that from the event’s source all events up to this one shall be included in the OffsetMap.

let mut offsets: OffsetMap = OffsetMap::empty();
let event: Event<Payload> = Event::mk_test("semantics", "name", "42").unwrap();

// keeping track of having seen this event:
offsets += &event;
assert!(offsets.contains(&event));

The difference of two offset maps yields the number of events contained within the first but not within the second one (i.e. it counts the size of the difference set).

Implementations

impl OffsetMap[src]

pub fn empty() -> Self[src]

The empty OffsetMap is equivalent to the beginning of time, it does not contain any event.

pub fn contains<T>(&self, event: &Event<T>) -> bool[src]

Check whether the given Event’s offset and source ID are contained within this OffsetMap.

pub fn size(&self) -> u64[src]

Counts the number of offsets spanned by this OffsetMap.

pub fn union_with<'a>(&'a mut self, other: &OffsetMap) -> &'a mut Self[src]

Merge the other OffsetMap into this one, taking the union of their event sets.

pub fn union(&self, other: &OffsetMap) -> OffsetMap[src]

Compute the union of two sets of events described by OffsetMaps

pub fn intersection(&self, other: &OffsetMap) -> OffsetMap[src]

Compute the intersection of two sets of events described by OffsetMaps

pub fn into_inner(self) -> HashMap<SourceId, Offset>[src]

Trait Implementations

impl<'_, T> AddAssign<&'_ Event<T>> for OffsetMap[src]

impl AsRef<HashMap<SourceId, Offset, RandomState>> for OffsetMap[src]

impl<'_> BitAnd<&'_ OffsetMap> for &'_ OffsetMap[src]

type Output = OffsetMap

The resulting type after applying the & operator.

impl BitAnd<OffsetMap> for OffsetMap[src]

type Output = OffsetMap

The resulting type after applying the & operator.

impl BitAndAssign<OffsetMap> for OffsetMap[src]

impl<'_> BitOr<&'_ OffsetMap> for &'_ OffsetMap[src]

type Output = OffsetMap

The resulting type after applying the | operator.

impl BitOr<OffsetMap> for OffsetMap[src]

type Output = OffsetMap

The resulting type after applying the | operator.

impl BitOrAssign<OffsetMap> for OffsetMap[src]

impl Clone for OffsetMap[src]

impl Debug for OffsetMap[src]

impl Default for OffsetMap[src]

impl<'de> Deserialize<'de> for OffsetMap[src]

impl Eq for OffsetMap[src]

impl From<HashMap<SourceId, Offset, RandomState>> for OffsetMap[src]

impl PartialEq<OffsetMap> for OffsetMap[src]

impl PartialOrd<OffsetMap> for OffsetMap[src]

impl Serialize for OffsetMap[src]

impl StructuralEq for OffsetMap[src]

impl StructuralPartialEq for OffsetMap[src]

impl<'_, '_> Sub<&'_ OffsetMap> for &'_ OffsetMap[src]

type Output = u64

The resulting type after applying the - operator.

impl Sub<OffsetMap> for OffsetMap[src]

type Output = u64

The resulting type after applying the - operator.

impl<'_, T> SubAssign<&'_ Event<T>> for OffsetMap[src]

fn sub_assign(&mut self, other: &Event<T>)[src]

Ensure that the given event is no longer contained within this OffsetMap.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<Src, Dst> LosslessTryInto<Dst> for Src where
    Dst: LosslessTryFrom<Src>, 
[src]

impl<Src, Dst> LossyInto<Dst> for Src where
    Dst: LossyFrom<Src>, 
[src]

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.