Skip to main content

MutableVectorIndex

Struct MutableVectorIndex 

Source
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

Source

pub fn load(path: impl AsRef<Path>) -> Result<Self, SearchError>

Loads a complete mutable bundle. Legacy immutable vector snapshots are accepted with empty metadata and deltas.

§Errors

Returns typed snapshot or storage errors.

Source

pub fn save(&self, path: impl AsRef<Path>) -> Result<(), SearchError>

Atomically saves base and sealed graphs, staged vectors, tombstones, and metadata without forcing compaction.

§Errors

Returns a compaction or storage error.

Source§

impl MutableVectorIndex

Source

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.

Source

pub fn from_index(index: VectorIndex) -> Self

Wraps an existing immutable index with an empty mutable delta.

Source

pub const fn config(&self) -> &IndexConfig

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn delta_len(&self) -> usize

Source

pub fn staged_len(&self) -> usize

Number of writes still using exact delta search.

Source

pub fn sealed_len(&self) -> usize

Number of live vectors in the sealed HNSW delta.

Source

pub fn should_compact(&self, maximum_delta: usize) -> bool

Source§

impl MutableVectorIndex

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn delete(&self, key: u64) -> bool

Tombstones a live key. Returns whether a vector was removed.

Source

pub fn delete_batch(&self, keys: &[u64]) -> usize

Tombstones every live key in keys and returns the number removed.

Source

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.

Source

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.

Source

pub fn metadata(&self, key: u64) -> Option<Metadata>

Source§

impl MutableVectorIndex

Source

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.

Source

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

Source

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.

Source

pub fn search_filtered( &self, query: &[f32], count: usize, filter: &MetadataFilter, ) -> Result<Vec<SearchHit>, SearchError>

Searches only records matching filter.

§Errors

Returns a typed query or allocation error.

Trait Implementations§

Source§

impl Debug for MutableVectorIndex

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl SearchShard for MutableVectorIndex

Source§

fn dimensions(&self) -> usize

Source§

fn search_shard( &self, query: &[f32], count: usize, ) -> Result<Vec<SearchHit>, SearchError>

Searches this shard. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.