pub struct MemoryStore { /* private fields */ }Expand description
In-memory VectorStore with cosine similarity and BM25 keyword search.
Implementations§
Source§impl MemoryStore
impl MemoryStore
Sourcepub fn open(path: impl Into<PathBuf>) -> Result<Self, RagError>
pub fn open(path: impl Into<PathBuf>) -> Result<Self, RagError>
Open a store backed by path: existing content is loaded, and every
change is written back (see the module docs for the guarantees).
Sourcepub fn set_autosave(&self, autosave: bool)
pub fn set_autosave(&self, autosave: bool)
Write after every change (default true). With autosave off, changes stay
in memory until MemoryStore::flush.
Source§impl MemoryStore
impl MemoryStore
Trait Implementations§
Source§impl Clone for MemoryStore
impl Clone for MemoryStore
Source§impl Debug for MemoryStore
impl Debug for MemoryStore
Source§impl Default for MemoryStore
impl Default for MemoryStore
Source§impl VectorStore for MemoryStore
impl VectorStore for MemoryStore
Source§fn upsert(
&self,
chunks: Vec<StoredChunk>,
) -> BoxFuture<'_, Result<(), RagError>>
fn upsert( &self, chunks: Vec<StoredChunk>, ) -> BoxFuture<'_, Result<(), RagError>>
Insert or replace chunks (by
id).Source§fn delete_document<'a>(
&'a self,
dataset_id: &'a str,
document_id: &'a str,
) -> BoxFuture<'a, Result<usize, RagError>>
fn delete_document<'a>( &'a self, dataset_id: &'a str, document_id: &'a str, ) -> BoxFuture<'a, Result<usize, RagError>>
Remove every chunk of a document. Returns the number removed when known.
Source§fn delete_dataset<'a>(
&'a self,
dataset_id: &'a str,
) -> BoxFuture<'a, Result<usize, RagError>>
fn delete_dataset<'a>( &'a self, dataset_id: &'a str, ) -> BoxFuture<'a, Result<usize, RagError>>
Remove every chunk of a dataset.
Source§fn document_chunks<'a>(
&'a self,
dataset_id: &'a str,
document_id: &'a str,
) -> BoxFuture<'a, Result<Vec<StoredChunk>, RagError>>
fn document_chunks<'a>( &'a self, dataset_id: &'a str, document_id: &'a str, ) -> BoxFuture<'a, Result<Vec<StoredChunk>, RagError>>
Every chunk of one document, vectors included. The ingestor uses this to
re-ingest a document without re-embedding unchanged chunks and to find the
chunks a new version no longer contains.
Source§fn delete_chunks<'a>(
&'a self,
dataset_id: &'a str,
ids: &'a [String],
) -> BoxFuture<'a, Result<usize, RagError>>
fn delete_chunks<'a>( &'a self, dataset_id: &'a str, ids: &'a [String], ) -> BoxFuture<'a, Result<usize, RagError>>
Remove chunks by id. Returns the number removed when known.
Source§fn search<'a>(
&'a self,
query: VectorQuery<'a>,
) -> BoxFuture<'a, Result<Vec<Hit>, RagError>>
fn search<'a>( &'a self, query: VectorQuery<'a>, ) -> BoxFuture<'a, Result<Vec<Hit>, RagError>>
Nearest neighbours by cosine similarity, best first.
Source§fn supports_keyword(&self) -> bool
fn supports_keyword(&self) -> bool
Whether
VectorStore::keyword_search is implemented.Source§fn keyword_search<'a>(
&'a self,
query: KeywordQuery<'a>,
) -> BoxFuture<'a, Result<Vec<Hit>, RagError>>
fn keyword_search<'a>( &'a self, query: KeywordQuery<'a>, ) -> BoxFuture<'a, Result<Vec<Hit>, RagError>>
Keyword (BM25) search, best first. Stores without a keyword index return nothing.
Source§fn contains_hash<'a>(
&'a self,
dataset_id: &'a str,
content_hash: &'a str,
) -> BoxFuture<'a, Result<bool, RagError>>
fn contains_hash<'a>( &'a self, dataset_id: &'a str, content_hash: &'a str, ) -> BoxFuture<'a, Result<bool, RagError>>
Whether a chunk with this content hash already exists in the dataset.
Stores that cannot answer cheaply return
false. The built-in crate::Ingestor
does not use this (it de-duplicates per document via VectorStore::document_chunks).Auto Trait Implementations§
impl Forget for MemoryStore
impl Freeze for MemoryStore
impl Move for MemoryStore
impl RefUnwindSafe for MemoryStore
impl Send for MemoryStore
impl Sync for MemoryStore
impl Unpin for MemoryStore
impl UnsafeUnpin for MemoryStore
impl UnwindSafe for MemoryStore
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