Skip to main content

VectorIndex

Struct VectorIndex 

Source
pub struct VectorIndex { /* private fields */ }

Implementations§

Source§

impl VectorIndex

Search using MRL-accelerated truncated scan with full-dimension rescore.

If config.search_dims >= self.dimension(), this falls back to the standard search_top_k (no truncation benefit).

§Errors

Returns SearchError::DimensionMismatch when query.len() does not match index dimensionality, SearchError::InvalidConfig for invalid config values, and SearchError::IndexCorrupted for malformed data.

Source

pub fn mrl_search_with_stats( &self, query: &[f32], limit: usize, config: &MrlConfig, filter: Option<&dyn SearchFilter>, ) -> Result<(Vec<VectorHit>, MrlSearchStats), SearchError>

Like mrl_search but also returns diagnostic stats.

§Errors

Same error conditions as mrl_search.

Source§

impl VectorIndex

Source

pub fn search_top_k( &self, query: &[f32], limit: usize, filter: Option<&dyn SearchFilter>, ) -> Result<Vec<VectorHit>, SearchError>

Brute-force cosine-similarity top-k search over all records.

The query is expected to already be normalized for cosine similarity. The result is sorted by descending score with NaN-safe semantics.

§Errors

Returns SearchError::DimensionMismatch when query.len() does not match index dimensionality, and SearchError::IndexCorrupted for malformed vector slab contents.

Source

pub fn search_top_k_with_params( &self, query: &[f32], limit: usize, filter: Option<&dyn SearchFilter>, params: SearchParams, ) -> Result<Vec<VectorHit>, SearchError>

Brute-force cosine-similarity top-k search with configurable parallelism.

Behaves identically to search_top_k but uses the caller-supplied SearchParams instead of the compiled-in defaults.

§Errors

Returns SearchError::DimensionMismatch when query.len() does not match index dimensionality, and SearchError::IndexCorrupted for malformed vector slab contents.

Source§

impl VectorIndex

Source

pub fn open(path: &Path) -> Result<VectorIndex, SearchError>

Open an existing FSVI index from disk.

§Errors

Returns SearchError::IndexNotFound if the file does not exist and SearchError::IndexCorrupted when header/layout validation fails.

Source

pub fn create( path: &Path, embedder_id: &str, dimension: usize, ) -> Result<VectorIndexWriter, SearchError>

Create a writer that stores vectors as f16 with an empty revision string.

§Errors

Returns SearchError::InvalidConfig when arguments are invalid (for example, zero dimension or oversized header fields).

Source

pub fn create_with_revision( path: &Path, embedder_id: &str, embedder_revision: &str, dimension: usize, quantization: Quantization, ) -> Result<VectorIndexWriter, SearchError>

Create a writer with explicit embedder revision and quantization.

§Errors

Returns SearchError::InvalidConfig when arguments are invalid (for example, zero dimension or oversized header fields).

Source

pub const fn record_count(&self) -> usize

Number of vectors in this index.

Source

pub const fn dimension(&self) -> usize

Embedding dimensionality.

Source

pub fn embedder_id(&self) -> &str

Embedder id stored in the index header.

Source

pub fn embedder_revision(&self) -> &str

Embedder revision stored in the index header.

Source

pub const fn quantization(&self) -> Quantization

Stored quantization.

Source

pub const fn metadata(&self) -> &VectorMetadata

Full parsed metadata.

Source

pub const fn set_wal_config(&mut self, config: WalConfig)

Set the WAL configuration for incremental updates.

Source

pub const fn wal_record_count(&self) -> usize

Number of entries in the write-ahead log (pending compaction).

Source

pub fn needs_compaction(&self) -> bool

Whether the WAL is large enough that compaction is recommended.

Returns true when the WAL exceeds either the absolute threshold or the ratio threshold relative to the main index size.

Source

pub fn soft_delete(&mut self, doc_id: &str) -> Result<bool, SearchError>

Tombstone (soft-delete) a document by doc_id.

Returns Ok(true) when a live record was marked deleted, and Ok(false) when the document does not exist or is already tombstoned.

§Errors

Returns SearchError::Io for filesystem write/sync failures and SearchError::IndexCorrupted if the on-disk record table is malformed.

Source

pub fn soft_delete_batch( &mut self, doc_ids: &[&str], ) -> Result<usize, SearchError>

Tombstone a batch of document ids.

Returns the number of records that transitioned from live -> deleted.

§Errors

Returns the first IO/corruption error encountered while updating flags.

Source

pub fn is_deleted(&self, record_index: usize) -> bool

Whether the record at record_index is tombstoned.

Source

pub fn tombstone_count(&self) -> usize

Number of tombstoned records in the main index.

Source

pub fn tombstone_ratio(&self) -> f64

Fraction of records that are tombstoned (tombstones / record_count).

Source

pub fn needs_vacuum(&self) -> bool

Whether the tombstone ratio exceeds the default vacuum threshold.

Source

pub fn vacuum(&mut self) -> Result<VacuumStats, SearchError>

Rewrite the main index file without tombstoned records.

WAL entries are preserved and reloaded after the rewrite.

§Errors

Returns SearchError::Io for filesystem failures and SearchError::IndexCorrupted for malformed data.

Source

pub fn append( &mut self, doc_id: &str, vector: &[f32], ) -> Result<(), SearchError>

Append a single vector to the index via the WAL.

The vector is immediately searchable. It is written to the WAL sidecar file for crash safety.

§Errors

Returns SearchError::DimensionMismatch for wrong embedding lengths and SearchError::Io for filesystem failures.

Source

pub fn append_batch( &mut self, entries: &[(String, Vec<f32>)], ) -> Result<(), SearchError>

Append a batch of vectors to the index via the WAL.

All vectors in the batch are written atomically to a single WAL batch (one CRC covers the whole batch).

§Errors

Returns SearchError::DimensionMismatch for wrong embedding lengths, SearchError::InvalidConfig for invalid values, and SearchError::Io for filesystem failures.

Source

pub fn compact(&mut self) -> Result<CompactionStats, SearchError>

Compact the WAL into the main index.

Rewrites the main index file with all main + WAL records merged, then removes the WAL sidecar. The index is atomically swapped (write to tmp, rename over original).

§Errors

Returns SearchError::Io for filesystem failures and SearchError::InvalidConfig for encoding issues.

Source

pub fn doc_id_at(&self, index: usize) -> Result<&str, SearchError>

Resolve the document id at index.

§Errors

Returns SearchError::InvalidConfig for out-of-range indices and SearchError::IndexCorrupted for malformed record/string tables.

Source

pub fn vector_at_f32(&self, index: usize) -> Result<Vec<f32>, SearchError>

Decode a vector as f32 values.

§Errors

Returns SearchError::InvalidConfig for out-of-range indices and SearchError::IndexCorrupted for malformed vector slab data.

Source

pub fn vector_at_f16(&self, index: usize) -> Result<Vec<f16>, SearchError>

Decode a vector as f16 values.

§Errors

Returns SearchError::InvalidConfig for out-of-range indices and SearchError::IndexCorrupted for malformed vector slab data.

Source

pub fn find_index_by_doc_hash(&self, doc_id_hash: u64) -> Option<usize>

Binary-search the sorted record table by document hash.

Source

pub fn get_embeddings(&self, doc_id_hashes: &[u64]) -> Vec<Option<Vec<f16>>>

Fetch embeddings for hashed doc ids (f16 values).

Missing hashes return None entries at the same position.

Trait Implementations§

Source§

impl Debug for VectorIndex

Source§

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

Formats the value using the given formatter. 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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, _span: NoopSpan) -> Self

Instruments this future with a span (no-op when disabled).
Source§

fn in_current_span(self) -> Self

Instruments this future with the current span (no-op when disabled).
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Fruit for T
where T: Send + Downcast,