pub struct VectorStore { /* private fields */ }Expand description
In-memory vector store partitioned by namespace.
Implementations§
Source§impl VectorStore
impl VectorStore
Sourcepub fn with_dimension(dim: usize) -> Self
pub fn with_dimension(dim: usize) -> Self
Create an empty store that enforces a fixed dimension on upsert.
Sourcepub fn upsert(&mut self, entry: VectorEntry) -> Result<bool, StoreError>
pub fn upsert(&mut self, entry: VectorEntry) -> Result<bool, StoreError>
Insert or update a vector entry.
Returns Ok(true) if the entry was newly inserted, Ok(false) if an
existing entry with the same (namespace, id) was replaced.
When the store is dimension-aware (created with VectorStore::with_dimension),
vectors of a different length are rejected.
Sourcepub fn delete(&mut self, namespace: &str, id: &str) -> bool
pub fn delete(&mut self, namespace: &str, id: &str) -> bool
Delete the entry with the given (namespace, id).
Returns true if the entry existed and was removed.
Sourcepub fn get(&self, namespace: &str, id: &str) -> Option<&VectorEntry>
pub fn get(&self, namespace: &str, id: &str) -> Option<&VectorEntry>
Look up a specific entry by (namespace, id).
Sourcepub fn contains(&self, namespace: &str, id: &str) -> bool
pub fn contains(&self, namespace: &str, id: &str) -> bool
Check whether a specific (namespace, id) exists.
Sourcepub fn search(
&self,
namespace: &str,
query: &[f32],
top_k: usize,
) -> Vec<SearchResult>
pub fn search( &self, namespace: &str, query: &[f32], top_k: usize, ) -> Vec<SearchResult>
Return the top_k most-similar entries in namespace to query,
sorted by descending cosine similarity.
Sourcepub fn search_all_namespaces(
&self,
query: &[f32],
top_k: usize,
) -> Vec<SearchResult>
pub fn search_all_namespaces( &self, query: &[f32], top_k: usize, ) -> Vec<SearchResult>
Return the top_k most-similar entries across all namespaces.
Sourcepub fn list(&self, namespace: &str) -> Vec<&VectorEntry>
pub fn list(&self, namespace: &str) -> Vec<&VectorEntry>
List all entries in namespace. Returns an empty slice if the
namespace does not exist.
Sourcepub fn delete_namespace(&mut self, namespace: &str) -> usize
pub fn delete_namespace(&mut self, namespace: &str) -> usize
Remove all entries belonging to namespace.
Returns the number of entries that were deleted.
Sourcepub fn stats(&self) -> VectorStoreStats
pub fn stats(&self) -> VectorStoreStats
Return aggregate statistics about the store.
Trait Implementations§
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
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>
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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.