pub struct VectorStore { /* private fields */ }Expand description
In-memory vector index for fast cosine similarity search.
Loads all embeddings from the Embeddings galaxy into memory on first access. Supports incremental updates (add/remove vectors without full rebuild).
Implementations§
Source§impl VectorStore
impl VectorStore
Sourcepub fn load(&mut self, store: &MemoryStore) -> Result<()>
pub fn load(&mut self, store: &MemoryStore) -> Result<()>
Load all embeddings from the LMDB Embeddings galaxy into memory.
This scans the Embeddings galaxy and loads all stored embedding vectors.
Must be called before search if vectors were stored directly via
MemoryStore::put_embedding without going through add.
Sourcepub fn add(&mut self, memory_id: Uuid, galaxy: Galaxy, embedding: Vec<f32>)
pub fn add(&mut self, memory_id: Uuid, galaxy: Galaxy, embedding: Vec<f32>)
Add a vector to the index.
Sourcepub fn search(
&self,
query: &[f32],
limit: usize,
galaxy_filter: Option<Galaxy>,
) -> Vec<VectorSearchResult>
pub fn search( &self, query: &[f32], limit: usize, galaxy_filter: Option<Galaxy>, ) -> Vec<VectorSearchResult>
Search for the most similar vectors to a query embedding.
Returns results sorted by cosine similarity (highest first). Optionally filter by galaxy.
Sourcepub fn search_similar_to(
&self,
memory_id: Uuid,
limit: usize,
) -> Vec<VectorSearchResult>
pub fn search_similar_to( &self, memory_id: Uuid, limit: usize, ) -> Vec<VectorSearchResult>
Search for similar vectors to a memory’s own embedding.
Excludes the memory itself from results.
Trait Implementations§
Source§impl Default for VectorStore
impl Default for VectorStore
Source§impl VectorSearchEngine for VectorStore
impl VectorSearchEngine for VectorStore
Source§fn add_vector(&mut self, memory_id: Uuid, galaxy: Galaxy, embedding: Vec<f32>)
fn add_vector(&mut self, memory_id: Uuid, galaxy: Galaxy, embedding: Vec<f32>)
Add a vector to the index.
Source§fn remove_vector(&mut self, memory_id: Uuid) -> bool
fn remove_vector(&mut self, memory_id: Uuid) -> bool
Remove a vector from the index.
Source§fn search_vectors(
&self,
query: &[f32],
limit: usize,
galaxy_filter: Option<Galaxy>,
) -> Vec<VectorSearchResult>
fn search_vectors( &self, query: &[f32], limit: usize, galaxy_filter: Option<Galaxy>, ) -> Vec<VectorSearchResult>
Search for the most similar vectors to a query embedding. Read more
Source§fn search_similar_vectors(
&self,
memory_id: Uuid,
limit: usize,
) -> Vec<VectorSearchResult>
fn search_similar_vectors( &self, memory_id: Uuid, limit: usize, ) -> Vec<VectorSearchResult>
Search for similar vectors to a memory’s own embedding. Read more
Source§fn vector_count(&self) -> usize
fn vector_count(&self) -> usize
Get the number of indexed vectors.
Source§fn load_vectors(&mut self, store: &MemoryStore) -> Result<()>
fn load_vectors(&mut self, store: &MemoryStore) -> Result<()>
Load all embeddings from the LMDB Embeddings galaxy.
Source§fn clear_vectors(&mut self)
fn clear_vectors(&mut self)
Clear the index.
Source§fn is_index_empty(&self) -> bool
fn is_index_empty(&self) -> bool
Whether the index is empty.
Auto Trait Implementations§
impl Freeze for VectorStore
impl RefUnwindSafe for VectorStore
impl Send for VectorStore
impl Sync for VectorStore
impl Unpin for VectorStore
impl UnsafeUnpin for VectorStore
impl UnwindSafe for VectorStore
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
Converts
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>
Converts
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)
Converts
&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)
Converts
&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
impl<T> Fruit 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> 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