#[non_exhaustive]pub struct InMemoryStore { /* private fields */ }Expand description
HashMap-based VectorStore implementation for tests.
Performs brute-force cosine similarity search — no HNSW required.
save and load are no-ops. is_ready is configurable.
Implementations§
Source§impl InMemoryStore
impl InMemoryStore
Sourcepub fn new(dimensions: usize) -> Self
pub fn new(dimensions: usize) -> Self
Create a new InMemoryStore with the given embedding dimensionality.
is_ready defaults to true. Use InMemoryStore::with_ready to
override.
Sourcepub fn with_ready(self, ready: bool) -> Self
pub fn with_ready(self, ready: bool) -> Self
Override the value returned by is_ready().
Trait Implementations§
Source§impl VectorStore for InMemoryStore
impl VectorStore for InMemoryStore
Source§fn add(
&self,
scope: &Scope,
vector: &[f32],
qualified_name: String,
) -> Result<u64, MemoryError>
fn add( &self, scope: &Scope, vector: &[f32], qualified_name: String, ) -> Result<u64, MemoryError>
Source§fn remove(
&self,
_scope: &Scope,
qualified_name: &str,
) -> Result<(), MemoryError>
fn remove( &self, _scope: &Scope, qualified_name: &str, ) -> Result<(), MemoryError>
Remove the entry for
qualified_name from scope (and from the
all-index). Best-effort — does not fail if the entry is absent.Source§fn search(
&self,
filter: &ScopeFilter,
query: &[f32],
limit: usize,
) -> Result<Vec<(u64, String, f32)>, MemoryError>
fn search( &self, filter: &ScopeFilter, query: &[f32], limit: usize, ) -> Result<Vec<(u64, String, f32)>, MemoryError>
Source§fn find_by_name(&self, qualified_name: &str) -> Option<u64>
fn find_by_name(&self, qualified_name: &str) -> Option<u64>
Look up the vector key for a qualified name in the all-index. Read more
Source§fn save(&self, _dir: &Path) -> Result<(), MemoryError>
fn save(&self, _dir: &Path) -> Result<(), MemoryError>
Persist all indexes to subdirectories under
dir.Source§fn dimensions(&self) -> usize
fn dimensions(&self) -> usize
The embedding dimensionality this store was initialised with.
Source§fn commit_sha(&self) -> Option<String>
fn commit_sha(&self) -> Option<String>
The commit SHA last written to or read from the index metadata, if any.
Source§fn set_commit_sha(&self, sha: Option<&str>)
fn set_commit_sha(&self, sha: Option<&str>)
Overwrite the stored commit SHA.
Auto Trait Implementations§
impl !Freeze for InMemoryStore
impl RefUnwindSafe for InMemoryStore
impl Send for InMemoryStore
impl Sync for InMemoryStore
impl Unpin for InMemoryStore
impl UnsafeUnpin for InMemoryStore
impl UnwindSafe for InMemoryStore
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
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