pub struct VectorIndex { /* private fields */ }Expand description
Vector index for semantic search
Implementations§
Source§impl VectorIndex
impl VectorIndex
Sourcepub fn with_parallel_processing(parallel_processor: ParallelProcessor) -> Self
pub fn with_parallel_processing(parallel_processor: ParallelProcessor) -> Self
Create a new vector index with parallel processing support
Sourcepub fn add_vector(&mut self, id: String, embedding: Vec<f32>) -> Result<()>
pub fn add_vector(&mut self, id: String, embedding: Vec<f32>) -> Result<()>
Add a vector to the index
Sourcepub fn build_index(&mut self) -> Result<()>
pub fn build_index(&mut self) -> Result<()>
Build the index from all added vectors
Sourcepub fn search(
&self,
query_embedding: &[f32],
top_k: usize,
) -> Result<Vec<(String, f32)>>
pub fn search( &self, query_embedding: &[f32], top_k: usize, ) -> Result<Vec<(String, f32)>>
Search for similar vectors
Sourcepub fn dimension(&self) -> Option<usize>
pub fn dimension(&self) -> Option<usize>
Get embedding dimension (assuming all embeddings have the same dimension)
Sourcepub fn remove_vector(&mut self, id: &str) -> Result<()>
pub fn remove_vector(&mut self, id: &str) -> Result<()>
Remove a vector from the index
Sourcepub fn batch_add_vectors(
&mut self,
vectors: Vec<(String, Vec<f32>)>,
) -> Result<()>
pub fn batch_add_vectors( &mut self, vectors: Vec<(String, Vec<f32>)>, ) -> Result<()>
Batch add multiple vectors in parallel with proper synchronization
Sourcepub fn batch_search(
&self,
queries: &[Vec<f32>],
top_k: usize,
) -> Result<Vec<Vec<(String, f32)>>>
pub fn batch_search( &self, queries: &[Vec<f32>], top_k: usize, ) -> Result<Vec<Vec<(String, f32)>>>
Batch search for multiple queries in parallel
Sourcepub fn compute_all_similarities(&self) -> HashMap<(String, String), f32>
pub fn compute_all_similarities(&self) -> HashMap<(String, String), f32>
Parallel similarity computation between all vectors with optimized chunking
Sourcepub fn find_similar(
&self,
query_embedding: &[f32],
threshold: f32,
) -> Result<Vec<(String, f32)>>
pub fn find_similar( &self, query_embedding: &[f32], threshold: f32, ) -> Result<Vec<(String, f32)>>
Find vectors within a similarity threshold
Sourcepub fn statistics(&self) -> VectorIndexStatistics
pub fn statistics(&self) -> VectorIndexStatistics
Calculate statistics about the index
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<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
Mutably borrows from an owned value. Read more
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> 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>
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 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>
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