pub trait CentroidGraph: Send + Sync {
// Required methods
fn search(&self, query: &[f32], k: usize) -> Vec<u64>;
fn add_centroid(&self, entry: &CentroidEntry) -> Result<()>;
fn remove_centroid(&self, centroid_id: u64) -> Result<()>;
fn get_centroid_vector(&self, centroid_id: u64) -> Option<Vec<f32>>;
fn len(&self) -> usize;
// Provided method
fn is_empty(&self) -> bool { ... }
}Expand description
Trait for HNSW-based centroid graph implementations.
The graph stores centroids and enables fast approximate nearest neighbor search to find relevant clusters during query execution.
Required Methods§
Sourcefn add_centroid(&self, entry: &CentroidEntry) -> Result<()>
fn add_centroid(&self, entry: &CentroidEntry) -> Result<()>
Add a centroid to the graph.
Uses interior mutability since the graph is behind Arc<dyn CentroidGraph>.
Sourcefn remove_centroid(&self, centroid_id: u64) -> Result<()>
fn remove_centroid(&self, centroid_id: u64) -> Result<()>
Remove a centroid from the graph by its ID.
Uses interior mutability since the graph is behind Arc<dyn CentroidGraph>.