risingwave_stream::common::state_cache

Trait StateCache

source
pub trait StateCache: EstimateSize {
    type Key: Ord + EstimateSize;
    type Value: EstimateSize;
    type Filler<'a>: StateCacheFiller<Key = Self::Key, Value = Self::Value> + 'a
       where Self: 'a;

    // Required methods
    fn is_synced(&self) -> bool;
    fn begin_syncing(&mut self) -> Self::Filler<'_>;
    fn insert(
        &mut self,
        key: Self::Key,
        value: Self::Value,
    ) -> Option<Self::Value>;
    fn delete(&mut self, key: &Self::Key) -> Option<Self::Value>;
    fn apply_batch(
        &mut self,
        batch: impl IntoIterator<Item = (Op, Self::Key, Self::Value)>,
    );
    fn clear(&mut self);
    fn values(&self) -> impl Iterator<Item = &Self::Value>;
    fn first_key_value(&self) -> Option<(&Self::Key, &Self::Value)>;
}
Expand description

A common interface for state table cache.

Required Associated Types§

source

type Key: Ord + EstimateSize

source

type Value: EstimateSize

source

type Filler<'a>: StateCacheFiller<Key = Self::Key, Value = Self::Value> + 'a where Self: 'a

Type of state cache filler, for syncing the cache with the state table.

Required Methods§

source

fn is_synced(&self) -> bool

Check if the cache is synced with the state table.

source

fn begin_syncing(&mut self) -> Self::Filler<'_>

Begin syncing the cache with the state table.

source

fn insert(&mut self, key: Self::Key, value: Self::Value) -> Option<Self::Value>

Insert an entry into the cache. Should not break cache validity.

source

fn delete(&mut self, key: &Self::Key) -> Option<Self::Value>

Delete an entry from the cache. Should not break cache validity.

source

fn apply_batch( &mut self, batch: impl IntoIterator<Item = (Op, Self::Key, Self::Value)>, )

Apply a batch of operations to the cache. Should not break cache validity.

source

fn clear(&mut self)

Clear the cache.

source

fn values(&self) -> impl Iterator<Item = &Self::Value>

Iterate over the values in the cache.

source

fn first_key_value(&self) -> Option<(&Self::Key, &Self::Value)>

Get the reference of first key-value pair in the cache.

Object Safety§

This trait is not object safe.

Implementors§