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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl StateCache for StateTableWatermarkCache

Source§

type Filler<'a> = &'a mut TopNStateCache<DefaultOrdered<OwnedRow>, ()>

Source§

type Key = DefaultOrdered<OwnedRow>

Source§

type Value = ()

Source§

impl<K: Ord + EstimateSize, V: EstimateSize> StateCache for OrderedStateCache<K, V>

Source§

type Filler<'a> = &'a mut OrderedStateCache<K, V> where Self: 'a

Source§

type Key = K

Source§

type Value = V

Source§

impl<K: Ord + EstimateSize, V: EstimateSize> StateCache for TopNStateCache<K, V>

Source§

type Filler<'a> = &'a mut TopNStateCache<K, V> where Self: 'a

Source§

type Key = K

Source§

type Value = V