pub struct VectorStore { /* private fields */ }Expand description
Per-table store front.
Implementations§
Source§impl VectorStore
impl VectorStore
Sourcepub fn open(backend: Arc<dyn Backend>) -> Result<Self, StoreError>
pub fn open(backend: Arc<dyn Backend>) -> Result<Self, StoreError>
Build a new store on top of backend and rehydrate every
schema / row that the backend already persists. The
rehydration walks every row in every table and rebuilds
the HNSW indexes from scratch; for the MVP this is
preferable to persisting the HNSW topology because the
table sizes we care about (up to ~10 million vectors)
rebuild in seconds.
§Errors
Surfaces any backend error encountered during the rehydration walk.
Sourcepub fn in_memory() -> Self
pub fn in_memory() -> Self
Build a fresh in-memory store. Convenience for tests and embedders that do not need persistence.
Sourcepub fn create_table(&self, schema: TableSchema) -> Result<(), StoreError>
pub fn create_table(&self, schema: TableSchema) -> Result<(), StoreError>
Register a new TableSchema.
§Errors
StoreError::TableExists when the schema’s name is
already in use.
Sourcepub fn tables(&self) -> Vec<TableSchema>
pub fn tables(&self) -> Vec<TableSchema>
List every registered table.
Sourcepub fn upsert(
&self,
table: &str,
key: RowKey,
vector: &[f32],
metadata: HashMap<String, Value>,
) -> Result<(), StoreError>
pub fn upsert( &self, table: &str, key: RowKey, vector: &[f32], metadata: HashMap<String, Value>, ) -> Result<(), StoreError>
Insert or overwrite a vector row.
The vector slice is encoded with the table’s codec and
fed to the HNSW index in f32 form. Re-inserts (same
key) replace the prior row in the row store and link a
fresh HNSW node, soft-deleting the prior one.
§Errors
StoreError::UnknownTable when the table is not
registered, StoreError::DimensionMismatch when the
vector’s dimension does not match the table dimension,
and StoreError::Encoding / StoreError::Index /
StoreError::Backend for the underlying failures.
Sourcepub fn get(
&self,
table: &str,
key: &[u8],
) -> Result<Option<VectorRow>, StoreError>
pub fn get( &self, table: &str, key: &[u8], ) -> Result<Option<VectorRow>, StoreError>
Fetch the row at (table, key).
§Errors
StoreError::UnknownTable for an unregistered table;
StoreError::Backend for a backend failure.
Sourcepub fn delete(&self, table: &str, key: &[u8]) -> Result<bool, StoreError>
pub fn delete(&self, table: &str, key: &[u8]) -> Result<bool, StoreError>
Delete the row at (table, key). Returns true when
present.
§Errors
StoreError::UnknownTable for an unregistered table;
StoreError::Backend for a backend failure.
Sourcepub fn search(
&self,
table: &str,
query: &[f32],
k: usize,
ef: Option<usize>,
) -> Result<Vec<(VectorRow, f32)>, StoreError>
pub fn search( &self, table: &str, query: &[f32], k: usize, ef: Option<usize>, ) -> Result<Vec<(VectorRow, f32)>, StoreError>
Run a top-k ANN search against table with query.
ef overrides the index’s default search beam width.
§Errors
StoreError::UnknownTable for an unregistered table;
StoreError::DimensionMismatch when the query
dimension does not match the table dimension.
Sourcepub fn stats(&self, table: &str) -> Result<TableStats, StoreError>
pub fn stats(&self, table: &str) -> Result<TableStats, StoreError>
Per-table snapshot statistics: live row count, soft- deleted node count, dimension, codec.
§Errors
StoreError::UnknownTable for an unregistered table.
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> 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<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.