pub trait VectorIndex:
Send
+ Sync
+ Debug {
// Required methods
fn reader(&self) -> Result<Arc<dyn VectorIndexReader>>;
fn writer(&self) -> Result<Box<dyn VectorIndexWriter>>;
fn storage(&self) -> &Arc<dyn Storage>;
fn close(&self) -> Result<()>;
fn is_closed(&self) -> bool;
fn stats(&self) -> Result<VectorIndexStats>;
fn optimize(&self) -> Result<()>;
fn searcher(&self) -> Result<Box<dyn VectorIndexSearcher>>;
fn embedder(&self) -> Arc<dyn Embedder>;
// Provided methods
fn refresh(&self) -> Result<()> { ... }
fn last_wal_seq(&self) -> u64 { ... }
fn set_last_wal_seq(&self, _seq: u64) -> Result<()> { ... }
}Expand description
Trait for vector index implementations.
This trait defines the low-level interface for individual vector indexes (Flat, HNSW, IVF, etc.). Each index type implements this trait to provide reader/writer access and basic lifecycle management.
This is analogous to crate::lexical::index::LexicalIndex in the lexical module.
For high-level, document-centric operations, see
crate::vector::store::VectorStore which manages multiple
vector fields and handles document-level operations.
Required Methods§
Sourcefn reader(&self) -> Result<Arc<dyn VectorIndexReader>>
fn reader(&self) -> Result<Arc<dyn VectorIndexReader>>
Get a reader for this index.
Returns a reader that can be used to query the index.
Sourcefn writer(&self) -> Result<Box<dyn VectorIndexWriter>>
fn writer(&self) -> Result<Box<dyn VectorIndexWriter>>
Get a writer for this index.
Returns a writer that can be used to add or update vectors.
Sourcefn storage(&self) -> &Arc<dyn Storage>
fn storage(&self) -> &Arc<dyn Storage>
Get the storage backend for this index.
Returns a reference to the underlying storage.
Sourcefn close(&self) -> Result<()>
fn close(&self) -> Result<()>
Close the index and release resources.
This should flush any pending writes and release all resources. Uses interior mutability for thread-safe access.
Sourcefn is_closed(&self) -> bool
fn is_closed(&self) -> bool
Check if the index is closed.
Returns true if the index has been closed.
Sourcefn stats(&self) -> Result<VectorIndexStats>
fn stats(&self) -> Result<VectorIndexStats>
Get index statistics.
Returns statistics about the index such as vector count, dimension, etc.
Sourcefn optimize(&self) -> Result<()>
fn optimize(&self) -> Result<()>
Optimize the index.
Performs index optimization to improve query performance. Uses interior mutability for thread-safe access.
Sourcefn searcher(&self) -> Result<Box<dyn VectorIndexSearcher>>
fn searcher(&self) -> Result<Box<dyn VectorIndexSearcher>>
Create a searcher tailored for this index implementation.
Returns a boxed VectorIndexSearcher capable of executing search/count operations.
Provided Methods§
Sourcefn refresh(&self) -> Result<()>
fn refresh(&self) -> Result<()>
Refresh the index metadata from storage.
Should be called after external writes (e.g., by a Writer) to ensure the index state is up-to-date.
Sourcefn last_wal_seq(&self) -> u64
fn last_wal_seq(&self) -> u64
Get the last processed WAL sequence number.
Sourcefn set_last_wal_seq(&self, _seq: u64) -> Result<()>
fn set_last_wal_seq(&self, _seq: u64) -> Result<()>
Set the last processed WAL sequence number.