pub struct VectorIndex { /* private fields */ }Implementations§
Source§impl VectorIndex
impl VectorIndex
Sourcepub fn mrl_search(
&self,
query: &[f32],
limit: usize,
config: &MrlConfig,
filter: Option<&dyn SearchFilter>,
) -> Result<Vec<VectorHit>, SearchError>
pub fn mrl_search( &self, query: &[f32], limit: usize, config: &MrlConfig, filter: Option<&dyn SearchFilter>, ) -> Result<Vec<VectorHit>, SearchError>
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.
Sourcepub fn mrl_search_with_stats(
&self,
query: &[f32],
limit: usize,
config: &MrlConfig,
filter: Option<&dyn SearchFilter>,
) -> Result<(Vec<VectorHit>, MrlSearchStats), SearchError>
pub fn mrl_search_with_stats( &self, query: &[f32], limit: usize, config: &MrlConfig, filter: Option<&dyn SearchFilter>, ) -> Result<(Vec<VectorHit>, MrlSearchStats), SearchError>
Source§impl VectorIndex
impl VectorIndex
Sourcepub fn search_top_k(
&self,
query: &[f32],
limit: usize,
filter: Option<&dyn SearchFilter>,
) -> Result<Vec<VectorHit>, SearchError>
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.
Sourcepub fn search_top_k_with_params(
&self,
query: &[f32],
limit: usize,
filter: Option<&dyn SearchFilter>,
params: SearchParams,
) -> Result<Vec<VectorHit>, SearchError>
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
impl VectorIndex
Sourcepub fn open(path: &Path) -> Result<VectorIndex, SearchError>
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.
Sourcepub fn create(
path: &Path,
embedder_id: &str,
dimension: usize,
) -> Result<VectorIndexWriter, SearchError>
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).
Sourcepub fn create_with_revision(
path: &Path,
embedder_id: &str,
embedder_revision: &str,
dimension: usize,
quantization: Quantization,
) -> Result<VectorIndexWriter, SearchError>
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).
Sourcepub const fn record_count(&self) -> usize
pub const fn record_count(&self) -> usize
Number of vectors in this index.
Sourcepub fn embedder_id(&self) -> &str
pub fn embedder_id(&self) -> &str
Embedder id stored in the index header.
Sourcepub fn embedder_revision(&self) -> &str
pub fn embedder_revision(&self) -> &str
Embedder revision stored in the index header.
Sourcepub const fn quantization(&self) -> Quantization
pub const fn quantization(&self) -> Quantization
Stored quantization.
Sourcepub const fn metadata(&self) -> &VectorMetadata
pub const fn metadata(&self) -> &VectorMetadata
Full parsed metadata.
Sourcepub const fn set_wal_config(&mut self, config: WalConfig)
pub const fn set_wal_config(&mut self, config: WalConfig)
Set the WAL configuration for incremental updates.
Sourcepub const fn wal_record_count(&self) -> usize
pub const fn wal_record_count(&self) -> usize
Number of entries in the write-ahead log (pending compaction).
Sourcepub fn needs_compaction(&self) -> bool
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.
Sourcepub fn soft_delete(&mut self, doc_id: &str) -> Result<bool, SearchError>
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.
Sourcepub fn soft_delete_batch(
&mut self,
doc_ids: &[&str],
) -> Result<usize, SearchError>
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.
Sourcepub fn is_deleted(&self, record_index: usize) -> bool
pub fn is_deleted(&self, record_index: usize) -> bool
Whether the record at record_index is tombstoned.
Sourcepub fn tombstone_count(&self) -> usize
pub fn tombstone_count(&self) -> usize
Number of tombstoned records in the main index.
Sourcepub fn tombstone_ratio(&self) -> f64
pub fn tombstone_ratio(&self) -> f64
Fraction of records that are tombstoned (tombstones / record_count).
Sourcepub fn needs_vacuum(&self) -> bool
pub fn needs_vacuum(&self) -> bool
Whether the tombstone ratio exceeds the default vacuum threshold.
Sourcepub fn vacuum(&mut self) -> Result<VacuumStats, SearchError>
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.
Sourcepub fn append(
&mut self,
doc_id: &str,
vector: &[f32],
) -> Result<(), SearchError>
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.
Sourcepub fn append_batch(
&mut self,
entries: &[(String, Vec<f32>)],
) -> Result<(), SearchError>
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.
Sourcepub fn compact(&mut self) -> Result<CompactionStats, SearchError>
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.
Sourcepub fn doc_id_at(&self, index: usize) -> Result<&str, SearchError>
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.
Sourcepub fn vector_at_f32(&self, index: usize) -> Result<Vec<f32>, SearchError>
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.
Sourcepub fn vector_at_f16(&self, index: usize) -> Result<Vec<f16>, SearchError>
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.
Sourcepub fn find_index_by_doc_hash(&self, doc_id_hash: u64) -> Option<usize>
pub fn find_index_by_doc_hash(&self, doc_id_hash: u64) -> Option<usize>
Binary-search the sorted record table by document hash.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for VectorIndex
impl RefUnwindSafe for VectorIndex
impl Send for VectorIndex
impl Sync for VectorIndex
impl Unpin for VectorIndex
impl UnsafeUnpin for VectorIndex
impl UnwindSafe for VectorIndex
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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 Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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