[−][src]Struct actyxos_sdk::event::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 theOffsetMap
.
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]
fn add_assign(&mut self, other: &Event<T>)
[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.
fn bitand(self, rhs: Self) -> Self::Output
[src]
impl BitAnd<OffsetMap> for OffsetMap
[src]
type Output = OffsetMap
The resulting type after applying the &
operator.
fn bitand(self, rhs: Self) -> Self::Output
[src]
impl BitAndAssign<OffsetMap> for OffsetMap
[src]
fn bitand_assign(&mut self, rhs: Self)
[src]
impl<'_> BitOr<&'_ OffsetMap> for &'_ OffsetMap
[src]
type Output = OffsetMap
The resulting type after applying the |
operator.
fn bitor(self, rhs: Self) -> Self::Output
[src]
impl BitOr<OffsetMap> for OffsetMap
[src]
type Output = OffsetMap
The resulting type after applying the |
operator.
fn bitor(self, rhs: Self) -> Self::Output
[src]
impl BitOrAssign<OffsetMap> for OffsetMap
[src]
fn bitor_assign(&mut self, rhs: Self)
[src]
impl Clone for OffsetMap
[src]
impl Debug for OffsetMap
[src]
impl Default for OffsetMap
[src]
impl<'de> Deserialize<'de> for OffsetMap
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
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]
fn partial_cmp(&self, rhs: &Self) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl Serialize for OffsetMap
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
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.
fn sub(self, other: &OffsetMap) -> u64
[src]
impl Sub<OffsetMap> for OffsetMap
[src]
type Output = u64
The resulting type after applying the -
operator.
fn sub(self, other: Self) -> u64
[src]
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
impl RefUnwindSafe for OffsetMap
impl Send for OffsetMap
impl Sync for OffsetMap
impl Unpin for OffsetMap
impl UnwindSafe for OffsetMap
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<Src, Dst> LosslessTryInto<Dst> for Src where
Dst: LosslessTryFrom<Src>,
[src]
Dst: LosslessTryFrom<Src>,
fn lossless_try_into(self) -> Option<Dst>
[src]
impl<Src, Dst> LossyInto<Dst> for Src where
Dst: LossyFrom<Src>,
[src]
Dst: LossyFrom<Src>,
fn lossy_into(self) -> Dst
[src]
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,