pub trait VectorStorage: Send + Sync {
// Required methods
fn store(&mut self, id: u64, vector: &[f32]) -> Result<()>;
fn store_batch(&mut self, vectors: &[(u64, &[f32])]) -> Result<usize>;
fn retrieve(&self, id: u64) -> Result<Option<Vec<f32>>>;
fn delete(&mut self, id: u64) -> Result<()>;
fn flush(&mut self) -> Result<()>;
fn len(&self) -> usize;
fn ids(&self) -> Vec<u64>;
// Provided method
fn is_empty(&self) -> bool { ... }
}Expand description
Trait defining storage operations for vectors.
Required Methods§
Sourcefn store_batch(&mut self, vectors: &[(u64, &[f32])]) -> Result<usize>
fn store_batch(&mut self, vectors: &[(u64, &[f32])]) -> Result<usize>
Stores multiple vectors in a single batch operation.
This is optimized for bulk imports:
- Single WAL write for the entire batch
- Contiguous memory writes
- Single fsync at the end
§Errors
Returns an error if the write operation fails.