pub struct MutableVectorIndex { /* private fields */ }Expand description
Thread-safe mutable overlay over an immutable HNSW base.
Inserts and updates are searched exactly from a bounded delta. Deletions
are tombstones. Self::compact deterministically folds both into a new
immutable base without making readers observe a partial rebuild.
Implementations§
Source§impl MutableVectorIndex
impl MutableVectorIndex
Source§impl MutableVectorIndex
impl MutableVectorIndex
Sourcepub fn build(
config: IndexConfig,
records: &[VectorRecord],
) -> Result<Self, SearchError>
pub fn build( config: IndexConfig, records: &[VectorRecord], ) -> Result<Self, SearchError>
Builds a mutable index and preserves supplied metadata.
§Errors
Returns typed config, vector, allocation, capacity, or duplicate-key errors.
Sourcepub fn from_index(index: VectorIndex) -> Self
pub fn from_index(index: VectorIndex) -> Self
Wraps an existing immutable index with an empty mutable delta.
pub const fn config(&self) -> &IndexConfig
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn delta_len(&self) -> usize
Sourcepub fn staged_len(&self) -> usize
pub fn staged_len(&self) -> usize
Number of writes still using exact delta search.
Sourcepub fn sealed_len(&self) -> usize
pub fn sealed_len(&self) -> usize
Number of live vectors in the sealed HNSW delta.
pub fn should_compact(&self, maximum_delta: usize) -> bool
Source§impl MutableVectorIndex
impl MutableVectorIndex
Sourcepub fn insert(
&self,
key: u64,
vector: &[f32],
metadata: Metadata,
) -> Result<(), SearchError>
pub fn insert( &self, key: u64, vector: &[f32], metadata: Metadata, ) -> Result<(), SearchError>
Inserts a new key.
§Errors
Returns SearchError::DuplicateKey when the live key already exists,
or a typed vector validation error.
Sourcepub fn upsert(
&self,
key: u64,
vector: &[f32],
metadata: Metadata,
) -> Result<MutationOutcome, SearchError>
pub fn upsert( &self, key: u64, vector: &[f32], metadata: Metadata, ) -> Result<MutationOutcome, SearchError>
Inserts or replaces one key without rebuilding the immutable base.
§Errors
Returns a typed vector validation error.
Sourcepub fn insert_batch(&self, records: &[VectorRecord]) -> Result<(), SearchError>
pub fn insert_batch(&self, records: &[VectorRecord]) -> Result<(), SearchError>
Atomically inserts a batch after validating every record.
§Errors
Returns without applying any record when the batch contains duplicate keys, an existing live key, or an invalid vector.
Sourcepub fn upsert_batch(
&self,
records: &[VectorRecord],
) -> Result<Vec<MutationOutcome>, SearchError>
pub fn upsert_batch( &self, records: &[VectorRecord], ) -> Result<Vec<MutationOutcome>, SearchError>
Atomically inserts or replaces a batch after validating every record.
Results follow input order.
§Errors
Returns without applying any record when the batch contains duplicate keys or an invalid vector.
Sourcepub fn delete(&self, key: u64) -> bool
pub fn delete(&self, key: u64) -> bool
Tombstones a live key. Returns whether a vector was removed.
Sourcepub fn delete_batch(&self, keys: &[u64]) -> usize
pub fn delete_batch(&self, keys: &[u64]) -> usize
Tombstones every live key in keys and returns the number removed.
Sourcepub fn rename(&self, from: u64, to: u64) -> Result<bool, SearchError>
pub fn rename(&self, from: u64, to: u64) -> Result<bool, SearchError>
Renames one live vector key without rebuilding either graph.
§Errors
Returns SearchError::DuplicateKey when to is already live.
Sourcepub fn set_metadata(
&self,
key: u64,
metadata: Metadata,
) -> Result<(), SearchError>
pub fn set_metadata( &self, key: u64, metadata: Metadata, ) -> Result<(), SearchError>
Replaces metadata without changing the vector.
§Errors
Returns SearchError::MissingKey when key is not live.
pub fn metadata(&self, key: u64) -> Option<Metadata>
Source§impl MutableVectorIndex
impl MutableVectorIndex
Sourcepub fn seal_delta(&self) -> Result<(), SearchError>
pub fn seal_delta(&self) -> Result<(), SearchError>
Rebuilds only the mutable delta into its own HNSW graph.
This bounds exact staged scanning without rebuilding the immutable base. Concurrent mutations are retried and never lost.
§Errors
Returns a build error or SearchError::MutationConflict after three
conflicting attempts.
Sourcepub fn compact(&self) -> Result<(), SearchError>
pub fn compact(&self) -> Result<(), SearchError>
Deterministically rebuilds the immutable base. Concurrent mutations are detected and retried without losing updates.
§Errors
Returns a build error or SearchError::MutationConflict after three
conflicting rebuilds.
Source§impl MutableVectorIndex
impl MutableVectorIndex
Sourcepub fn search(
&self,
query: &[f32],
count: usize,
) -> Result<Vec<SearchHit>, SearchError>
pub fn search( &self, query: &[f32], count: usize, ) -> Result<Vec<SearchHit>, SearchError>
Searches the immutable base and exact delta, then deterministically merges equal keys.
§Errors
Returns a typed query or allocation error.