pub struct CompactionPicker { /* private fields */ }Expand description
Hybrid compaction picker combining TWCS and size-tiered strategies.
The picker operates in two passes:
-
TWCS pass — groups segments by
(shard_id, measurement)and triggers compaction when the count exceedscount_trigger_threshold. -
Size-tiered pass — within each
(shard_id, measurement)group, classifies segments bySizeTierand triggers merges when a tier’s count exceedssize_tier_threshold.
The CompactionPolicy selects which passes run:
Twcs→ TWCS pass onlySizeTiered→ size-tiered pass onlyHybrid→ both passes, TWCS first (deduplicates tasks)
Implementations§
Source§impl CompactionPicker
impl CompactionPicker
Sourcepub fn new(trigger_threshold: usize) -> Self
pub fn new(trigger_threshold: usize) -> Self
Create a picker with the given count-based trigger threshold.
Uses the default policy with Hybrid strategy.
Sourcepub fn with_policy(policy: CompactionPolicy) -> Self
pub fn with_policy(policy: CompactionPolicy) -> Self
Create a picker from an explicit CompactionPolicy.
Sourcepub fn policy(&self) -> &CompactionPolicy
pub fn policy(&self) -> &CompactionPolicy
Returns the active compaction policy.
Sourcepub fn trigger_threshold(&self) -> usize
pub fn trigger_threshold(&self) -> usize
Returns the count-based trigger threshold.
Sourcepub fn pick(
&self,
segments: &[SegmentCatalogEntry],
output_dir: &Path,
) -> Vec<CompactionTask>
pub fn pick( &self, segments: &[SegmentCatalogEntry], output_dir: &Path, ) -> Vec<CompactionTask>
Scan a set of segments and produce compaction tasks.
Uses the configured policy to run TWCS, size-tiered, or hybrid
compaction. Groups segments by (shard_id, measurement).
Segments in Compacting or SoftDeleted state should be filtered
out before calling this method.
Sourcepub fn pick_level(
&self,
segments: &[SegmentCatalogEntry],
output_dir: &Path,
source_level: CompactionLevel,
) -> Vec<CompactionTask>
pub fn pick_level( &self, segments: &[SegmentCatalogEntry], output_dir: &Path, source_level: CompactionLevel, ) -> Vec<CompactionTask>
Scan segments at a specific compaction level and produce tasks.
Enables multi-level compaction (L0→L1, L1→L2).
Sourcepub fn backpressure_delay_ms(&self, l0_count: usize) -> u64
pub fn backpressure_delay_ms(&self, l0_count: usize) -> u64
Check if write backpressure should be applied.
Returns a throttle factor: 0 = no throttle, >0 = delay in
milliseconds per write. Escalates linearly as L0 count grows
beyond 4 × trigger_threshold.
Trait Implementations§
Source§impl Clone for CompactionPicker
impl Clone for CompactionPicker
Source§fn clone(&self) -> CompactionPicker
fn clone(&self) -> CompactionPicker
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CompactionPicker
impl Debug for CompactionPicker
Source§impl Default for CompactionPicker
impl Default for CompactionPicker
Source§fn default() -> CompactionPicker
fn default() -> CompactionPicker
Auto Trait Implementations§
impl Freeze for CompactionPicker
impl RefUnwindSafe for CompactionPicker
impl Send for CompactionPicker
impl Sync for CompactionPicker
impl Unpin for CompactionPicker
impl UnsafeUnpin for CompactionPicker
impl UnwindSafe for CompactionPicker
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more