pub struct VectorStore { /* private fields */ }Expand description
Manages all SQLite read/write operations for collections and vector records.
Implementations§
Source§impl VectorStore
impl VectorStore
Sourcepub async fn new(db_path: &Path) -> VectorResult<Self>
pub async fn new(db_path: &Path) -> VectorResult<Self>
Open (or create) the SQLite database at db_path, applying schema migrations.
Sourcepub async fn open(path: &Path) -> VectorResult<Self>
pub async fn open(path: &Path) -> VectorResult<Self>
Alias for VectorStore::new.
Sourcepub fn pool(&self) -> &SqlitePool
pub fn pool(&self) -> &SqlitePool
Return the underlying SQLx connection pool.
Sourcepub async fn create_collection(
&self,
workspace_id: &str,
col: &Collection,
) -> VectorResult<()>
pub async fn create_collection( &self, workspace_id: &str, col: &Collection, ) -> VectorResult<()>
Persist a new collection definition (upsert).
Sourcepub async fn save_collection(
&self,
workspace_id: &str,
col: &Collection,
) -> VectorResult<()>
pub async fn save_collection( &self, workspace_id: &str, col: &Collection, ) -> VectorResult<()>
Alias for VectorStore::create_collection.
Sourcepub async fn get_collection(
&self,
workspace_id: &str,
name: &str,
) -> VectorResult<Collection>
pub async fn get_collection( &self, workspace_id: &str, name: &str, ) -> VectorResult<Collection>
Retrieve a collection by name.
Sourcepub async fn delete_collection(
&self,
workspace_id: &str,
name: &str,
) -> VectorResult<()>
pub async fn delete_collection( &self, workspace_id: &str, name: &str, ) -> VectorResult<()>
Delete a collection by name.
Sourcepub async fn list_collections(
&self,
workspace_id: &str,
) -> VectorResult<Vec<Collection>>
pub async fn list_collections( &self, workspace_id: &str, ) -> VectorResult<Vec<Collection>>
List all collections.
Sourcepub async fn list_all_collections(&self) -> VectorResult<Vec<Collection>>
pub async fn list_all_collections(&self) -> VectorResult<Vec<Collection>>
List all collections across all workspaces.
Sourcepub async fn insert_record(
&self,
workspace_id: &str,
record: &VectorRecord,
internal_id: usize,
) -> VectorResult<()>
pub async fn insert_record( &self, workspace_id: &str, record: &VectorRecord, internal_id: usize, ) -> VectorResult<()>
Persist a vector record, linking it to the given internal_id.
Sourcepub async fn save_record(
&self,
workspace_id: &str,
record: &VectorRecord,
internal_id: usize,
) -> VectorResult<()>
pub async fn save_record( &self, workspace_id: &str, record: &VectorRecord, internal_id: usize, ) -> VectorResult<()>
Alias for VectorStore::insert_record.
Sourcepub async fn get_record(
&self,
workspace_id: &str,
id: Uuid,
) -> VectorResult<(VectorRecord, usize)>
pub async fn get_record( &self, workspace_id: &str, id: Uuid, ) -> VectorResult<(VectorRecord, usize)>
Retrieve a record and its internal identifier by UUID.
Sourcepub async fn delete_record(
&self,
workspace_id: &str,
id: Uuid,
) -> VectorResult<Option<usize>>
pub async fn delete_record( &self, workspace_id: &str, id: Uuid, ) -> VectorResult<Option<usize>>
Delete a vector record by id and return its previous internal id when found.
Sourcepub async fn batch_insert_records(
&self,
workspace_id: &str,
records: &[(VectorRecord, usize)],
) -> VectorResult<()>
pub async fn batch_insert_records( &self, workspace_id: &str, records: &[(VectorRecord, usize)], ) -> VectorResult<()>
Insert multiple vector records in a single transaction.
Sourcepub async fn uuid_to_internal(
&self,
workspace_id: &str,
id: Uuid,
) -> VectorResult<usize>
pub async fn uuid_to_internal( &self, workspace_id: &str, id: Uuid, ) -> VectorResult<usize>
Resolve a record UUID to its internal id.
Sourcepub async fn internal_to_uuid(
&self,
workspace_id: &str,
collection: &str,
internal_id: usize,
) -> VectorResult<Uuid>
pub async fn internal_to_uuid( &self, workspace_id: &str, collection: &str, internal_id: usize, ) -> VectorResult<Uuid>
Resolve a collection-scoped internal id to its UUID.
Sourcepub async fn bulk_internal_to_uuid(
&self,
workspace_id: &str,
collection: &str,
ids: &[usize],
) -> VectorResult<Vec<(usize, VectorRecord)>>
pub async fn bulk_internal_to_uuid( &self, workspace_id: &str, collection: &str, ids: &[usize], ) -> VectorResult<Vec<(usize, VectorRecord)>>
Bulk-resolve collection-scoped internal ids to stored vector metadata.
Sourcepub async fn increment_vector_count(
&self,
workspace_id: &str,
collection: &str,
delta: i64,
) -> VectorResult<()>
pub async fn increment_vector_count( &self, workspace_id: &str, collection: &str, delta: i64, ) -> VectorResult<()>
Increment a collection’s stored vector count.
Sourcepub async fn update_collection_index_type(
&self,
workspace_id: &str,
collection: &str,
index_type: IndexType,
) -> VectorResult<()>
pub async fn update_collection_index_type( &self, workspace_id: &str, collection: &str, index_type: IndexType, ) -> VectorResult<()>
Update the persisted index type for a collection.
Sourcepub async fn collection_stats(
&self,
workspace_id: &str,
name: &str,
) -> VectorResult<CollectionStats>
pub async fn collection_stats( &self, workspace_id: &str, name: &str, ) -> VectorResult<CollectionStats>
Return collection storage statistics as tracked in SQLite.
Sourcepub async fn next_internal_id(
&self,
workspace_id: &str,
collection: &str,
) -> VectorResult<usize>
pub async fn next_internal_id( &self, workspace_id: &str, collection: &str, ) -> VectorResult<usize>
Return the next available internal id for a collection.
Sourcepub async fn list_records_for_collection(
&self,
workspace_id: &str,
collection: &str,
) -> VectorResult<Vec<(VectorRecord, usize)>>
pub async fn list_records_for_collection( &self, workspace_id: &str, collection: &str, ) -> VectorResult<Vec<(VectorRecord, usize)>>
Load all persisted records for a collection, ordered by internal id.
Sourcepub async fn keyword_search(
&self,
workspace_id: &str,
collection: &str,
query: &str,
limit: usize,
) -> VectorResult<Vec<(usize, VectorRecord, f32)>>
pub async fn keyword_search( &self, workspace_id: &str, collection: &str, query: &str, limit: usize, ) -> VectorResult<Vec<(usize, VectorRecord, f32)>>
Search full-text records for a collection using SQLite FTS5.
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request