pub trait WindowState: EstimateSize {
// Required methods
fn append(&mut self, key: StateKey, args: SmallVec<[Datum; 2]>);
fn curr_window(&self) -> StatePos<'_>;
fn is_empty(&self) -> bool;
fn slide(&mut self) -> Result<(Datum, StateEvictHint)>;
fn slide_no_output(&mut self) -> Result<StateEvictHint>;
// Provided methods
fn readiness(&self) -> Readiness { ... }
fn enable_persistence(&mut self) { ... }
fn snapshot(&self) -> Option<WindowStateSnapshot> { ... }
fn restore(&mut self, _snapshot: WindowStateSnapshot) -> Result<()> { ... }
}Required Methods§
Sourcefn append(&mut self, key: StateKey, args: SmallVec<[Datum; 2]>)
fn append(&mut self, key: StateKey, args: SmallVec<[Datum; 2]>)
Append a new input row to the state. The key is expected to be increasing.
Sourcefn curr_window(&self) -> StatePos<'_>
fn curr_window(&self) -> StatePos<'_>
Get the current window frame position.
Sourcefn slide(&mut self) -> Result<(Datum, StateEvictHint)>
fn slide(&mut self) -> Result<(Datum, StateEvictHint)>
Slide the window frame forward and collect the output and evict hint. Similar to Iterator::next.
Sourcefn slide_no_output(&mut self) -> Result<StateEvictHint>
fn slide_no_output(&mut self) -> Result<StateEvictHint>
Slide the window frame forward and collect the evict hint. Don’t calculate the output if possible.
Provided Methods§
Sourcefn readiness(&self) -> Readiness
fn readiness(&self) -> Readiness
Get the readiness of the current window, given that the rows are appended in the order of
the order key, so no future row is less than the last one. Unlike StatePos::is_ready,
which is conservative and must not change for the recovery of existing jobs, this is exact.
Sourcefn enable_persistence(&mut self)
fn enable_persistence(&mut self)
Enable persistence for this window state. When enabled, the state may return
CanEvict hints and should support snapshot/restore.
Sourcefn snapshot(&self) -> Option<WindowStateSnapshot>
fn snapshot(&self) -> Option<WindowStateSnapshot>
Create a snapshot of the current state for persistence.
Returns None if the state doesn’t support persistence.
Sourcefn restore(&mut self, _snapshot: WindowStateSnapshot) -> Result<()>
fn restore(&mut self, _snapshot: WindowStateSnapshot) -> Result<()>
Restore the state from a snapshot. Called during recovery before replaying rows.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".