pub struct VectorIndexOptimizer { /* private fields */ }Expand description
Production-quality vector index optimizer.
Observes a stream of query/insert events, builds a WorkloadProfile,
and recommends the best IndexStructure given an OptimizationCriterion.
It also monitors live IndexStats and emits MaintenanceActions when needed.
Implementations§
Source§impl VectorIndexOptimizer
impl VectorIndexOptimizer
Sourcepub fn new(config: OptimizerConfig) -> Self
pub fn new(config: OptimizerConfig) -> Self
Create a new optimizer with the provided configuration.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a new optimizer with default configuration.
Sourcepub fn record_query(
&mut self,
k: usize,
latency_us: u64,
recall: f64,
_current_ts: u64,
)
pub fn record_query( &mut self, k: usize, latency_us: u64, recall: f64, _current_ts: u64, )
Record a completed query.
k: requested top-klatency_us: measured query latency in microsecondsrecall: observed recall@k (0–1)current_ts: current Unix timestamp in seconds (for time-series tracking)
Sourcepub fn record_insert(&mut self, _current_ts: u64)
pub fn record_insert(&mut self, _current_ts: u64)
Record an insert operation.
current_ts: current Unix timestamp in seconds
Sourcepub fn record_delete(&mut self, _current_ts: u64)
pub fn record_delete(&mut self, _current_ts: u64)
Record a delete operation.
Sourcepub fn workload_profile(
&self,
dataset_size: usize,
dim: usize,
) -> WorkloadProfile
pub fn workload_profile( &self, dataset_size: usize, dim: usize, ) -> WorkloadProfile
Snapshot the current workload profile.
Sourcepub fn recommend(
&mut self,
dataset_size: usize,
dim: usize,
) -> Result<IndexRecommendation, OptimizerError>
pub fn recommend( &mut self, dataset_size: usize, dim: usize, ) -> Result<IndexRecommendation, OptimizerError>
Recommend the best index structure for the given dataset and dimensionality.
Returns Err(OptimizerError::InsufficientData) until profile_window queries
have been observed.
Sourcepub fn estimate_recall(structure: &IndexStructure, n: usize, k: usize) -> f64
pub fn estimate_recall(structure: &IndexStructure, n: usize, k: usize) -> f64
Heuristic recall estimate for a structure at a given dataset size and k.
Sourcepub fn should_rebuild(
&mut self,
current_stats: &IndexStats,
) -> Option<MaintenanceAction>
pub fn should_rebuild( &mut self, current_stats: &IndexStats, ) -> Option<MaintenanceAction>
Check whether a rebuild or other maintenance is required.
Returns Some(action) when a rebuild is recommended, None otherwise.
Sourcepub fn record_post_rebuild_recall(&mut self, new_recall: f64)
pub fn record_post_rebuild_recall(&mut self, new_recall: f64)
Observe a post-rebuild recall to update improvement tracking.
Sourcepub fn maintenance_actions(
&mut self,
stats: &IndexStats,
dataset_size: usize,
dim: usize,
) -> Vec<MaintenanceAction>
pub fn maintenance_actions( &mut self, stats: &IndexStats, dataset_size: usize, dim: usize, ) -> Vec<MaintenanceAction>
Comprehensive maintenance check — returns all applicable actions.
Sourcepub fn compare_structures(
&self,
a: &IndexStructure,
b: &IndexStructure,
profile: &WorkloadProfile,
) -> Ordering
pub fn compare_structures( &self, a: &IndexStructure, b: &IndexStructure, profile: &WorkloadProfile, ) -> Ordering
Compare two index structures under the active criterion and profile.
Returns Ordering::Greater if a is preferred over b.
Sourcepub fn stats(&self) -> OptimizerStats
pub fn stats(&self) -> OptimizerStats
Return aggregate statistics for this optimizer instance.
Sourcepub fn profiling_progress(&self) -> (usize, usize)
pub fn profiling_progress(&self) -> (usize, usize)
Current profiling window fill level (0 to profile_window).
Returns (observed_queries, required_for_recommendation).
Both the latency and recall windows must reach profile_window before
recommend returns a valid result.
Auto Trait Implementations§
impl Freeze for VectorIndexOptimizer
impl RefUnwindSafe for VectorIndexOptimizer
impl Send for VectorIndexOptimizer
impl Sync for VectorIndexOptimizer
impl Unpin for VectorIndexOptimizer
impl UnsafeUnpin for VectorIndexOptimizer
impl UnwindSafe for VectorIndexOptimizer
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> 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.