pub struct InMemoryVectorStore { /* private fields */ }Expand description
Linear-scan in-memory vector store.
Implementations§
Source§impl InMemoryVectorStore
impl InMemoryVectorStore
Sourcepub fn new(embedder: Arc<dyn Embeddings>) -> Self
pub fn new(embedder: Arc<dyn Embeddings>) -> Self
New empty store with the given embedder and Cosine distance.
Sourcepub fn with_distance(embedder: Arc<dyn Embeddings>, distance: Distance) -> Self
pub fn with_distance(embedder: Arc<dyn Embeddings>, distance: Distance) -> Self
New empty store with explicit distance.
Trait Implementations§
Source§impl VectorStore for InMemoryVectorStore
impl VectorStore for InMemoryVectorStore
Source§fn add_texts<'life0, 'async_trait>(
&'life0 mut self,
texts: Vec<String>,
metadata: Option<Vec<HashMap<String, Value>>>,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add_texts<'life0, 'async_trait>(
&'life0 mut self,
texts: Vec<String>,
metadata: Option<Vec<HashMap<String, Value>>>,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Add documents (text + optional metadata). The store is responsible
for embedding them. Returns the IDs assigned.
Source§fn add_vectors<'life0, 'async_trait>(
&'life0 mut self,
vectors: Vec<Vec<f32>>,
texts: Vec<String>,
metadata: Option<Vec<HashMap<String, Value>>>,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add_vectors<'life0, 'async_trait>(
&'life0 mut self,
vectors: Vec<Vec<f32>>,
texts: Vec<String>,
metadata: Option<Vec<HashMap<String, Value>>>,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Add pre-embedded vectors directly. Useful when the caller has
already paid the embedding cost.
Source§fn similarity_search<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn similarity_search<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Similarity search: embed the query, return top-k matches.
Source§fn similarity_search_by_vector<'life0, 'async_trait>(
&'life0 self,
query_vector: Vec<f32>,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn similarity_search_by_vector<'life0, 'async_trait>(
&'life0 self,
query_vector: Vec<f32>,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Similarity search by pre-computed query vector.
Source§fn delete<'life0, 'async_trait>(
&'life0 mut self,
ids: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn delete<'life0, 'async_trait>(
&'life0 mut self,
ids: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Delete documents by ID. IDs not found are silently ignored.
Source§fn similarity_search_with_filter<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
k: usize,
filter: &'life2 Filter,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn similarity_search_with_filter<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
k: usize,
filter: &'life2 Filter,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Similarity search with a metadata filter. Read more
Auto Trait Implementations§
impl Freeze for InMemoryVectorStore
impl !RefUnwindSafe for InMemoryVectorStore
impl Send for InMemoryVectorStore
impl Sync for InMemoryVectorStore
impl Unpin for InMemoryVectorStore
impl UnsafeUnpin for InMemoryVectorStore
impl !UnwindSafe for InMemoryVectorStore
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