pub struct SessionWindowOperator<A: Aggregator> { /* private fields */ }Expand description
Creates the standard session output schema. Session window operator.
Groups events by activity periods separated by gaps. Each unique key maintains its own session state independently, supporting multiple concurrent sessions per key.
§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:
six:<key_hash>-SessionIndex(all sessions for a key)sac:<session_id>- Per-session 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>
impl<A: Aggregator> SessionWindowOperator<A>
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_max_cached_indices(&mut self, max: usize)
pub fn set_max_cached_indices(&mut self, max: usize)
Sets the maximum number of session indices to cache in-memory.
When the cache exceeds this limit, it is cleared and entries are reloaded from the persistent state store on demand. Default: 16,384.
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 window_close_metrics(&self) -> &WindowCloseMetrics
pub fn window_close_metrics(&self) -> &WindowCloseMetrics
Returns the window close metrics.
Sourcepub fn reset_window_close_metrics(&mut self)
pub fn reset_window_close_metrics(&mut self)
Resets the window close 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 across all keys.
Trait Implementations§
Source§impl<A: Aggregator> Operator for SessionWindowOperator<A>
impl<A: Aggregator> Operator for SessionWindowOperator<A>
Source§fn process(&mut self, event: &Event, ctx: &mut OperatorContext<'_>) -> OutputVec
fn process(&mut self, event: &Event, ctx: &mut OperatorContext<'_>) -> OutputVec
Source§fn on_timer(&mut self, timer: Timer, ctx: &mut OperatorContext<'_>) -> OutputVec
fn on_timer(&mut self, timer: Timer, ctx: &mut OperatorContext<'_>) -> OutputVec
Source§fn checkpoint(&self) -> OperatorState
fn checkpoint(&self) -> OperatorState
Source§fn restore(&mut self, state: OperatorState) -> Result<(), OperatorError>
fn restore(&mut self, state: OperatorState) -> Result<(), OperatorError>
Auto Trait Implementations§
impl<A> !Freeze for SessionWindowOperator<A>
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> UnsafeUnpin for SessionWindowOperator<A>where
A: UnsafeUnpin,
impl<A> UnwindSafe for SessionWindowOperator<A>
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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<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