Skip to main content

AsyncVectorStore

Trait AsyncVectorStore 

Source
pub trait AsyncVectorStore: Send + Sync {
    type Error: Error + Send + Sync + 'static;

    // Required methods
    fn add_vector<'life0, 'async_trait>(
        &'life0 mut self,
        id: String,
        vector: Vec<f32>,
        metadata: VectorMetadata,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn add_vectors_batch<'life0, 'async_trait>(
        &'life0 mut self,
        vectors: VectorBatch,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn search<'life0, 'life1, 'async_trait>(
        &'life0 self,
        query_vector: &'life1 [f32],
        k: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn search_with_threshold<'life0, 'life1, 'async_trait>(
        &'life0 self,
        query_vector: &'life1 [f32],
        k: usize,
        threshold: f32,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn remove_vector<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn len<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn add_vectors_batch_concurrent<'life0, 'async_trait>(
        &'life0 mut self,
        vectors: VectorBatch,
        max_concurrent: usize,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn search_batch<'life0, 'life1, 'async_trait>(
        &'life0 self,
        query_vectors: &'life1 [Vec<f32>],
        k: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<SearchResult>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn remove_vectors_batch<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        ids: &'life1 [&'life2 str],
    ) -> Pin<Box<dyn Future<Output = Result<Vec<bool>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn is_empty<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn health_check<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn build_index<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Async vector similarity search abstraction for non-blocking vector operations

§Async Version

This trait provides async operations for vector search with better concurrency and scalability.

Required Associated Types§

Source

type Error: Error + Send + Sync + 'static

The error type returned by vector store operations

Required Methods§

Source

fn add_vector<'life0, 'async_trait>( &'life0 mut self, id: String, vector: Vec<f32>, metadata: VectorMetadata, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Add a vector with associated ID and metadata

Source

fn add_vectors_batch<'life0, 'async_trait>( &'life0 mut self, vectors: VectorBatch, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Add multiple vectors in batch

Source

fn search<'life0, 'life1, 'async_trait>( &'life0 self, query_vector: &'life1 [f32], k: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Search for k most similar vectors

Source

fn search_with_threshold<'life0, 'life1, 'async_trait>( &'life0 self, query_vector: &'life1 [f32], k: usize, threshold: f32, ) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Search with distance threshold

Source

fn remove_vector<'life0, 'life1, 'async_trait>( &'life0 mut self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove a vector by ID

Source

fn len<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get vector count

Provided Methods§

Source

fn add_vectors_batch_concurrent<'life0, 'async_trait>( &'life0 mut self, vectors: VectorBatch, max_concurrent: usize, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Add vectors with concurrency control for large batches

Source

fn search_batch<'life0, 'life1, 'async_trait>( &'life0 self, query_vectors: &'life1 [Vec<f32>], k: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<SearchResult>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Search multiple queries concurrently

Source

fn remove_vectors_batch<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, ids: &'life1 [&'life2 str], ) -> Pin<Box<dyn Future<Output = Result<Vec<bool>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Remove multiple vectors in batch

Source

fn is_empty<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check if empty

Source

fn health_check<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Health check for vector store

Source

fn build_index<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Build index for better search performance (if applicable)

Implementors§