Struct streambed_logged::compaction::KeyBasedRetention
source · pub struct KeyBasedRetention { /* private fields */ }Expand description
The goal of key-based retention is to keep the latest record for a given key within a topic. This is the same as Kafka’s key-based retention and effectively makes the commit log a key value store.
KeyBasedRetention is guaranteed to return a key that is the record’s key.
Implementations§
Trait Implementations§
source§impl CompactionStrategy for KeyBasedRetention
impl CompactionStrategy for KeyBasedRetention
source§fn init<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = KeyBasedRetentionState> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn init<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = KeyBasedRetentionState> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Produce the initial state for the reducer function.
source§fn reduce(
state: &mut KeyBasedRetentionState,
key: Key,
record: ConsumerRecord,
) -> MaxKeysReached
fn reduce( state: &mut KeyBasedRetentionState, key: Key, record: ConsumerRecord, ) -> MaxKeysReached
The reducer function receives a mutable state reference, a key and a consumer
record, and returns a bool indicating whether the function has
reached its maximum number of distinct keys. If it has then
compaction may occur again once the current consumption of records
has finished. The goal is to avoid needing to process every type of
topic/partition/key in one go i.e. a subset can be processed, and then another
subset etc. This strategy helps to manage memory.
source§fn collect(state: KeyBasedRetentionState) -> CompactionMap
fn collect(state: KeyBasedRetentionState) -> CompactionMap
The collect function is responsible for mapping the state into
a map of keys and their minimum offsets. The compactor will filter out
the first n keys in a subsequent run where n is the number of keys
found on the first run. This permits memory to be controlled given
a large number of distinct keys. The cost of the re-run strategy is that
additional compaction scans will be required, resulting in more I/O.
Auto Trait Implementations§
impl Freeze for KeyBasedRetention
impl RefUnwindSafe for KeyBasedRetention
impl Send for KeyBasedRetention
impl Sync for KeyBasedRetention
impl Unpin for KeyBasedRetention
impl UnwindSafe for KeyBasedRetention
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more