Skip to main content

WindowState

Trait WindowState 

Source
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§

Source

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.

Source

fn curr_window(&self) -> StatePos<'_>

Get the current window frame position.

Source

fn is_empty(&self) -> bool

Whether no row is retained in the state.

Source

fn slide(&mut self) -> Result<(Datum, StateEvictHint)>

Slide the window frame forward and collect the output and evict hint. Similar to Iterator::next.

Source

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§

Source

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.

Source

fn enable_persistence(&mut self)

Enable persistence for this window state. When enabled, the state may return CanEvict hints and should support snapshot/restore.

Source

fn snapshot(&self) -> Option<WindowStateSnapshot>

Create a snapshot of the current state for persistence. Returns None if the state doesn’t support persistence.

Source

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".

Implementors§