oxirs_vec/optimizer/mod.rs
1//! Cost-based vector index optimizer.
2//!
3//! This module implements selectivity-aware index selection for vector
4//! search. Given (data_size, dim, requested_recall, query_density) the
5//! [`index_dispatcher::OptimizerDispatcher`] picks the lowest-cost index
6//! family that meets the recall floor, with a fallback chain when an
7//! observed recall trips the SLA.
8//!
9//! Component split:
10//!
11//! - [`cost_model`] — explicit per-index cost formulas (HNSW: `O(log n × M × ef)`,
12//! IVF: `O(n / nprobe + n_clusters)`, LSH: `O(K × L × dim + L × bucket)`,
13//! PQ: `O(centroids × subquantizers + n × subquantizers)`).
14//! - [`index_dispatcher`] — execution-agnostic brain that consults the cost
15//! model and chooses a primary + fallback chain.
16//! - [`query_stats`] — persisted per-family observation aggregates feeding
17//! online cost-weight learning.
18//!
19//! The crate-level [`crate::index_dispatcher::IndexDispatcher`] wires this
20//! brain to concrete vector-index instances (HNSW/IVF/LSH/PQ).
21
22pub mod cost_model;
23pub mod index_dispatcher;
24pub mod query_stats;
25
26pub use cost_model::{
27 CostEstimate, CostModel, CostWeights, IndexFamily, IndexParameters, WorkloadProfile,
28};
29pub use index_dispatcher::{
30 dispatcher_with_families, dispatcher_with_parameters, DispatchError, DispatchPlan,
31 DispatcherConfig, OptimizerDispatcher,
32};
33pub use query_stats::{FamilyStats, QueryObservation, QueryStats};