Struct streambed_logged::compaction::NthKeyBasedRetention
source · pub struct NthKeyBasedRetention { /* private fields */ }Expand description
Similar to KeyBasedRetention, but instead of retaining the latest offset for a key. this strategy retains the oldest nth offset associated with a key.
Implementations§
Trait Implementations§
source§impl CompactionStrategy for NthKeyBasedRetention
impl CompactionStrategy for NthKeyBasedRetention
§type S = (HashMap<u64, VecDeque<u64>>, usize, usize)
type S = (HashMap<u64, VecDeque<u64>>, usize, usize)
The state to manage throughout a compaction run.
source§fn init<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = NthKeyBasedRetentionState> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn init<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = NthKeyBasedRetentionState> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Produce the initial state for the reducer function.
source§fn reduce(
state: &mut NthKeyBasedRetentionState,
key: Key,
record: ConsumerRecord,
) -> MaxKeysReached
fn reduce( state: &mut NthKeyBasedRetentionState, 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: NthKeyBasedRetentionState) -> CompactionMap
fn collect(state: NthKeyBasedRetentionState) -> 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 NthKeyBasedRetention
impl RefUnwindSafe for NthKeyBasedRetention
impl Send for NthKeyBasedRetention
impl Sync for NthKeyBasedRetention
impl Unpin for NthKeyBasedRetention
impl UnwindSafe for NthKeyBasedRetention
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