pub struct CursorState { /* private fields */ }Expand description
In-memory per-stream cursor state for data marker capture.
Assigns a StreamSlot lazily on the first observation of a topic, advances each slot’s
cursor (cumulative count and highest ts_init) on every message in O(1) with no I/O, and
builds a DataCursorSnapshot of the slots that changed since the previous snapshot.
Implementations§
Source§impl CursorState
impl CursorState
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new empty CursorState.
Sourcepub fn advance(
&mut self,
topic: Topic,
data_cls: DataClass,
identifier: &str,
ts_init: UnixNanos,
) -> (StreamSlot, u32)
pub fn advance( &mut self, topic: Topic, data_cls: DataClass, identifier: &str, ts_init: UnixNanos, ) -> (StreamSlot, u32)
Advances the cursor for topic, assigning a slot on its first observation.
Returns the stream slot and the same_ts_ordinal: the running ordinal among records
sharing the current ts_init within the slot, which resets to zero when ts_init
advances (only the high-fidelity path reads it). Bumps the slot’s cumulative count,
raises its highest ts_init, and marks it dirty so the next
build_snapshot includes it. A first observation also queues a
StreamDictEntry for take_new_dict_entries.
§Panics
Panics if the number of distinct streams exceeds u32::MAX.
Sourcepub fn take_new_dict_entries(&mut self) -> Vec<StreamDictEntry>
pub fn take_new_dict_entries(&mut self) -> Vec<StreamDictEntry>
Removes and returns the dict entries queued since the previous call.
Each StreamDictEntry is produced once, when its slot is first assigned by
advance.
Sourcepub fn build_snapshot(
&mut self,
marker_seq: u64,
event_seq_before: u64,
ts_init: UnixNanos,
) -> Option<DataCursorSnapshot>
pub fn build_snapshot( &mut self, marker_seq: u64, event_seq_before: u64, ts_init: UnixNanos, ) -> Option<DataCursorSnapshot>
Builds a snapshot of every slot that advanced since the previous snapshot, clearing the dirty set.
Returns None when no slot has advanced, so a quiet interval writes nothing.
Trait Implementations§
Source§impl Debug for CursorState
impl Debug for CursorState
Source§impl Default for CursorState
impl Default for CursorState
Source§fn default() -> CursorState
fn default() -> CursorState
Auto Trait Implementations§
impl Freeze for CursorState
impl RefUnwindSafe for CursorState
impl Send for CursorState
impl Sync for CursorState
impl Unpin for CursorState
impl UnsafeUnpin for CursorState
impl UnwindSafe for CursorState
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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