pub struct IndexCompactor {
pub policy: CompactionPolicy,
pub stats: CompactorStats,
}Expand description
Analyses HNSW index fragmentation and recommends compaction plans.
IndexCompactor is the central entry point for compaction decisions. Given
an IndexFragmentStats it applies the configured CompactionPolicy and
returns an Option<CompactionPlan>: Some when compaction is warranted,
None when the index is healthy enough to leave alone.
All activity is recorded in CompactorStats so operators can observe how
frequently indexes require maintenance.
Fields§
§policy: CompactionPolicyConfigurable thresholds that drive compaction decisions.
stats: CompactorStatsAtomic activity counters.
Implementations§
Source§impl IndexCompactor
impl IndexCompactor
Sourcepub fn new(policy: CompactionPolicy) -> Self
pub fn new(policy: CompactionPolicy) -> Self
Creates a new IndexCompactor with the supplied policy.
Sourcepub fn analyze(
&self,
fragment_stats: &IndexFragmentStats,
) -> Option<CompactionPlan>
pub fn analyze( &self, fragment_stats: &IndexFragmentStats, ) -> Option<CompactionPlan>
Analyses fragment_stats and returns a CompactionPlan when compaction is needed.
Returns None when the index is below all policy thresholds.
Sourcepub fn estimate_priority(
&self,
stats: &IndexFragmentStats,
) -> CompactionPriority
pub fn estimate_priority( &self, stats: &IndexFragmentStats, ) -> CompactionPriority
Estimates the urgency of the required compaction.
| Condition | Priority |
|---|---|
deleted_ratio > 0.5 or index_bytes > 2 × limit | Critical |
deleted_ratio > 0.25 | High |
| compaction needed | Normal |
| compaction not needed | Low |
Sourcepub fn estimate_bytes_saved(&self, stats: &IndexFragmentStats) -> u64
pub fn estimate_bytes_saved(&self, stats: &IndexFragmentStats) -> u64
Estimates how many bytes will be reclaimed by a compaction.
Uses the approximation deleted_ratio × index_bytes.
Trait Implementations§
Source§impl Clone for IndexCompactor
impl Clone for IndexCompactor
Source§fn clone(&self) -> IndexCompactor
fn clone(&self) -> IndexCompactor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for IndexCompactor
impl RefUnwindSafe for IndexCompactor
impl Send for IndexCompactor
impl Sync for IndexCompactor
impl Unpin for IndexCompactor
impl UnsafeUnpin for IndexCompactor
impl UnwindSafe for IndexCompactor
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.