Expand description
§Session Window Operators
Implementation of session windows for stream processing.
Session windows are dynamic windows that group events by activity periods separated by gaps. Unlike tumbling and sliding windows which have fixed boundaries, session windows grow with activity and close after inactivity.
§Key Characteristics
- Dynamic boundaries: Sessions start with the first event and extend with each new event within the gap period
- Per-key tracking: Each key maintains independent session state
- Gap-based closure: Sessions close when no events arrive within the gap
- Session merging: Late data can merge previously separate sessions
§Example
Gap: 30 seconds
Events: [t=0] [t=10] [t=20] ...gap... [t=100] [t=110]
|<---- Session 1 ---->| |<- Session 2 ->|
[0, 50) [100, 140)§Usage
use laminar_core::operator::session_window::SessionWindowOperator;
use laminar_core::operator::window::CountAggregator;
use std::time::Duration;
// Create a session window with 30-second gap
let operator = SessionWindowOperator::new(
Duration::from_secs(30), // gap timeout
CountAggregator::new(),
Duration::from_secs(60), // allowed lateness
);Structs§
- Archived
Session State - An archived
SessionState - Session
Metrics - Session metrics for monitoring.
- Session
State - Session state tracking start/end times and key.
- Session
State Resolver - The resolver for an archived
SessionState - Session
Window Operator - Session window operator.