pub trait LocalStateStore: StaticSendSync {
type Iter<'a>: StateStoreIter + 'a;
type RevIter<'a>: StateStoreIter + 'a;
Show 13 methods
// Required methods
fn get(
&self,
key: TableKey<Bytes>,
read_options: ReadOptions,
) -> impl Future<Output = StorageResult<Option<Bytes>>> + Send + '_;
fn iter(
&self,
key_range: TableKeyRange,
read_options: ReadOptions,
) -> impl Future<Output = StorageResult<Self::Iter<'_>>> + Send + '_;
fn rev_iter(
&self,
key_range: TableKeyRange,
read_options: ReadOptions,
) -> impl Future<Output = StorageResult<Self::RevIter<'_>>> + Send + '_;
fn get_table_watermark(&self, vnode: VirtualNode) -> Option<Bytes>;
fn insert(
&mut self,
key: TableKey<Bytes>,
new_val: Bytes,
old_val: Option<Bytes>,
) -> StorageResult<()>;
fn delete(
&mut self,
key: TableKey<Bytes>,
old_val: Bytes,
) -> StorageResult<()>;
fn flush(
&mut self,
) -> impl Future<Output = StorageResult<usize>> + Send + '_;
fn try_flush(
&mut self,
) -> impl Future<Output = StorageResult<()>> + Send + '_;
fn epoch(&self) -> u64;
fn is_dirty(&self) -> bool;
fn init(
&mut self,
opts: InitOptions,
) -> impl Future<Output = StorageResult<()>> + Send + '_;
fn seal_current_epoch(
&mut self,
next_epoch: u64,
opts: SealCurrentEpochOptions,
);
fn update_vnode_bitmap(&mut self, vnodes: Arc<Bitmap>) -> Arc<Bitmap>;
}
Expand description
A state store that is dedicated for streaming operator, which only reads the uncommitted data
written by itself. Each local state store is not Clone
, and is owned by a streaming state
table.
Required Associated Types§
type Iter<'a>: StateStoreIter + 'a
type RevIter<'a>: StateStoreIter + 'a
Required Methods§
sourcefn get(
&self,
key: TableKey<Bytes>,
read_options: ReadOptions,
) -> impl Future<Output = StorageResult<Option<Bytes>>> + Send + '_
fn get( &self, key: TableKey<Bytes>, read_options: ReadOptions, ) -> impl Future<Output = StorageResult<Option<Bytes>>> + Send + '_
Point gets a value from the state store. The result is based on the latest written snapshot.
sourcefn iter(
&self,
key_range: TableKeyRange,
read_options: ReadOptions,
) -> impl Future<Output = StorageResult<Self::Iter<'_>>> + Send + '_
fn iter( &self, key_range: TableKeyRange, read_options: ReadOptions, ) -> impl Future<Output = StorageResult<Self::Iter<'_>>> + Send + '_
Opens and returns an iterator for given prefix_hint
and full_key_range
Internally, prefix_hint
will be used to for checking bloom_filter
and
full_key_range
used for iter. (if the prefix_hint
not None, it should be be included
in key_range
) The returned iterator will iterate data based on the latest written
snapshot.
fn rev_iter( &self, key_range: TableKeyRange, read_options: ReadOptions, ) -> impl Future<Output = StorageResult<Self::RevIter<'_>>> + Send + '_
sourcefn get_table_watermark(&self, vnode: VirtualNode) -> Option<Bytes>
fn get_table_watermark(&self, vnode: VirtualNode) -> Option<Bytes>
Get last persisted watermark for a given vnode.
sourcefn insert(
&mut self,
key: TableKey<Bytes>,
new_val: Bytes,
old_val: Option<Bytes>,
) -> StorageResult<()>
fn insert( &mut self, key: TableKey<Bytes>, new_val: Bytes, old_val: Option<Bytes>, ) -> StorageResult<()>
Inserts a key-value entry associated with a given epoch
into the state store.
sourcefn delete(&mut self, key: TableKey<Bytes>, old_val: Bytes) -> StorageResult<()>
fn delete(&mut self, key: TableKey<Bytes>, old_val: Bytes) -> StorageResult<()>
Deletes a key-value entry from the state store. Only the key-value entry with epoch smaller
than the given epoch
will be deleted.
fn flush(&mut self) -> impl Future<Output = StorageResult<usize>> + Send + '_
fn try_flush(&mut self) -> impl Future<Output = StorageResult<()>> + Send + '_
fn epoch(&self) -> u64
fn is_dirty(&self) -> bool
sourcefn init(
&mut self,
opts: InitOptions,
) -> impl Future<Output = StorageResult<()>> + Send + '_
fn init( &mut self, opts: InitOptions, ) -> impl Future<Output = StorageResult<()>> + Send + '_
Initializes the state store with given epoch
pair.
Typically we will use epoch.curr
as the initialized epoch,
Since state table will begin as empty.
In some cases like replicated state table, state table may not be empty initially,
as such we need to wait for epoch.prev
checkpoint to complete,
hence this interface is made async.
sourcefn seal_current_epoch(&mut self, next_epoch: u64, opts: SealCurrentEpochOptions)
fn seal_current_epoch(&mut self, next_epoch: u64, opts: SealCurrentEpochOptions)
Updates the monotonically increasing write epoch to new_epoch
.
All writes after this function is called will be tagged with new_epoch
. In other words,
the previous write epoch is sealed.