pub struct SessionWindowOperator<A: Aggregator> { /* private fields */ }Expand description
Session window operator.
Groups events by activity periods separated by gaps. Each unique key maintains its own session state independently.
§Session Lifecycle
- Start: First event for a key creates a new session
- Extend: Events within gap period extend the session
- Close: Timer fires when gap expires, emitting results
- Merge: Late data may merge previously separate sessions
§State Management
Session state is stored using prefixed keys:
ses:<key_hash>- Session metadata (start, end, key)sac:<key_hash>- Accumulator state
§Emit Strategies
OnWatermark: Emit when watermark passes session endOnUpdate: Emit after every state updateOnWindowClose: Only emit on final closureChangelog: Emit CDC records with Z-set weightsFinal: Suppress all intermediate, drop late data
Implementations§
Source§impl<A: Aggregator> SessionWindowOperator<A>where
A::Acc: Archive + for<'a> RkyvSerialize<HighSerializer<AlignedVec, ArenaHandle<'a>, Error>>,
<A::Acc as Archive>::Archived: for<'a> CheckBytes<HighValidator<'a, Error>> + RkyvDeserialize<A::Acc, HighDeserializer<Error>>,
impl<A: Aggregator> SessionWindowOperator<A>where
A::Acc: Archive + for<'a> RkyvSerialize<HighSerializer<AlignedVec, ArenaHandle<'a>, Error>>,
<A::Acc as Archive>::Archived: for<'a> CheckBytes<HighValidator<'a, Error>> + RkyvDeserialize<A::Acc, HighDeserializer<Error>>,
Sourcepub fn with_id(
gap: Duration,
aggregator: A,
allowed_lateness: Duration,
operator_id: String,
) -> Self
pub fn with_id( gap: Duration, aggregator: A, allowed_lateness: Duration, operator_id: String, ) -> Self
Creates a new session window operator with a custom operator ID.
§Panics
Panics if gap or allowed lateness does not fit in i64.
Sourcepub fn set_key_column(&mut self, column_index: usize)
pub fn set_key_column(&mut self, column_index: usize)
Sets the key column for per-key session tracking.
If not set, a single global session is maintained.
Sourcepub fn key_column(&self) -> Option<usize>
pub fn key_column(&self) -> Option<usize>
Returns the key column index if set.
Sourcepub fn set_emit_strategy(&mut self, strategy: EmitStrategy)
pub fn set_emit_strategy(&mut self, strategy: EmitStrategy)
Sets the emit strategy for this operator.
Sourcepub fn emit_strategy(&self) -> &EmitStrategy
pub fn emit_strategy(&self) -> &EmitStrategy
Returns the current emit strategy.
Sourcepub fn set_late_data_config(&mut self, config: LateDataConfig)
pub fn set_late_data_config(&mut self, config: LateDataConfig)
Sets the late data handling configuration.
Sourcepub fn late_data_config(&self) -> &LateDataConfig
pub fn late_data_config(&self) -> &LateDataConfig
Returns the current late data configuration.
Sourcepub fn late_data_metrics(&self) -> &LateDataMetrics
pub fn late_data_metrics(&self) -> &LateDataMetrics
Returns the late data metrics.
Sourcepub fn reset_late_data_metrics(&mut self)
pub fn reset_late_data_metrics(&mut self)
Resets the late data metrics counters.
Sourcepub fn allowed_lateness_ms(&self) -> i64
pub fn allowed_lateness_ms(&self) -> i64
Returns the allowed lateness in milliseconds.
Sourcepub fn active_session_count(&self) -> usize
pub fn active_session_count(&self) -> usize
Returns the number of active sessions.
Trait Implementations§
Source§impl<A: Aggregator> Operator for SessionWindowOperator<A>where
A::Acc: 'static + Archive + for<'a> RkyvSerialize<HighSerializer<AlignedVec, ArenaHandle<'a>, Error>>,
<A::Acc as Archive>::Archived: for<'a> CheckBytes<HighValidator<'a, Error>> + RkyvDeserialize<A::Acc, HighDeserializer<Error>>,
impl<A: Aggregator> Operator for SessionWindowOperator<A>where
A::Acc: 'static + Archive + for<'a> RkyvSerialize<HighSerializer<AlignedVec, ArenaHandle<'a>, Error>>,
<A::Acc as Archive>::Archived: for<'a> CheckBytes<HighValidator<'a, Error>> + RkyvDeserialize<A::Acc, HighDeserializer<Error>>,
Source§fn process(&mut self, event: &Event, ctx: &mut OperatorContext<'_>) -> OutputVec
fn process(&mut self, event: &Event, ctx: &mut OperatorContext<'_>) -> OutputVec
Process an incoming event
Source§fn on_timer(&mut self, timer: Timer, ctx: &mut OperatorContext<'_>) -> OutputVec
fn on_timer(&mut self, timer: Timer, ctx: &mut OperatorContext<'_>) -> OutputVec
Handle timer expiration
Source§fn checkpoint(&self) -> OperatorState
fn checkpoint(&self) -> OperatorState
Checkpoint the operator’s state
Source§fn restore(&mut self, state: OperatorState) -> Result<(), OperatorError>
fn restore(&mut self, state: OperatorState) -> Result<(), OperatorError>
Restore from a checkpoint Read more
Auto Trait Implementations§
impl<A> Freeze for SessionWindowOperator<A>where
A: Freeze,
impl<A> RefUnwindSafe for SessionWindowOperator<A>
impl<A> Send for SessionWindowOperator<A>
impl<A> Sync for SessionWindowOperator<A>
impl<A> Unpin for SessionWindowOperator<A>
impl<A> UnwindSafe for SessionWindowOperator<A>
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Returns the layout of the type.
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Returns whether the given value has been niched. Read more
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
Writes data to
out indicating that a T is niched.