Expand description
Adaptive Index - Automatic Performance Optimization
A high-level API that automatically selects and switches between index types based on dataset size and query patterns for optimal performance.
§Features
- Automatic index selection: Starts with brute-force, upgrades to HNSW/IVF-PQ as needed
- Performance tracking: Monitors search latency and automatically optimizes
- Seamless transitions: Transparently switches between index types
- Simple API: Single interface for all index types
§Example
use oxify_vector::adaptive::{AdaptiveIndex, AdaptiveConfig};
use std::collections::HashMap;
// Create adaptive index with automatic optimization
let mut index = AdaptiveIndex::new(AdaptiveConfig::default());
// Build from embeddings
let mut embeddings = HashMap::new();
embeddings.insert("doc1".to_string(), vec![0.1, 0.2, 0.3]);
embeddings.insert("doc2".to_string(), vec![0.2, 0.3, 0.4]);
index.build(&embeddings)?;
// Search - automatically uses best index type
let query = vec![0.15, 0.25, 0.35];
let results = index.search(&query, 10)?;
// Add more vectors - may trigger index upgrade
index.add_vector("doc3".to_string(), vec![0.3, 0.4, 0.5])?;
// Check current strategy
println!("Using strategy: {:?}", index.current_strategy());Structs§
- Adaptive
Config - Configuration for adaptive index
- Adaptive
Index - Adaptive index that automatically optimizes performance
- Adaptive
Stats - Performance statistics for adaptive index