pub struct CollectionVectorStore<E: StorageEngine> { /* private fields */ }Expand description
Vector storage for collections.
Provides CRUD operations for vectors stored separately from entities. This enables efficient vector access without loading entity data, and supports multiple named vectors per entity.
Implementations§
Source§impl<E: StorageEngine> CollectionVectorStore<E>
impl<E: StorageEngine> CollectionVectorStore<E>
Sourcepub fn put_vector(
&self,
collection_id: CollectionId,
entity_id: EntityId,
vector_name: &str,
data: &VectorData,
) -> Result<(), VectorError>
pub fn put_vector( &self, collection_id: CollectionId, entity_id: EntityId, vector_name: &str, data: &VectorData, ) -> Result<(), VectorError>
Sourcepub fn put_vector_tx<T: Transaction>(
&self,
tx: &mut T,
collection_id: CollectionId,
entity_id: EntityId,
vector_name: &str,
data: &VectorData,
) -> Result<(), VectorError>
pub fn put_vector_tx<T: Transaction>( &self, tx: &mut T, collection_id: CollectionId, entity_id: EntityId, vector_name: &str, data: &VectorData, ) -> Result<(), VectorError>
Store a vector within a transaction.
Use this method when you need to store vectors as part of a larger atomic operation (e.g., upserting an entity with vectors).
§Errors
Returns an error if the storage operation fails.
Sourcepub fn get_vector(
&self,
collection_id: CollectionId,
entity_id: EntityId,
vector_name: &str,
) -> Result<Option<VectorData>, VectorError>
pub fn get_vector( &self, collection_id: CollectionId, entity_id: EntityId, vector_name: &str, ) -> Result<Option<VectorData>, VectorError>
Sourcepub fn get_all_vectors(
&self,
collection_id: CollectionId,
entity_id: EntityId,
) -> Result<HashMap<String, VectorData>, VectorError>
pub fn get_all_vectors( &self, collection_id: CollectionId, entity_id: EntityId, ) -> Result<HashMap<String, VectorData>, VectorError>
Get all vectors for an entity.
Returns a map of vector names to their data.
§Errors
Returns an error if the storage operation fails.
Sourcepub fn delete_vector(
&self,
collection_id: CollectionId,
entity_id: EntityId,
vector_name: &str,
) -> Result<bool, VectorError>
pub fn delete_vector( &self, collection_id: CollectionId, entity_id: EntityId, vector_name: &str, ) -> Result<bool, VectorError>
Sourcepub fn delete_all_vectors(
&self,
collection_id: CollectionId,
entity_id: EntityId,
) -> Result<usize, VectorError>
pub fn delete_all_vectors( &self, collection_id: CollectionId, entity_id: EntityId, ) -> Result<usize, VectorError>
Sourcepub fn delete_all_vectors_tx<T: Transaction>(
&self,
tx: &mut T,
collection_id: CollectionId,
entity_id: EntityId,
) -> Result<usize, VectorError>
pub fn delete_all_vectors_tx<T: Transaction>( &self, tx: &mut T, collection_id: CollectionId, entity_id: EntityId, ) -> Result<usize, VectorError>
Sourcepub fn put_vectors_batch(
&self,
collection_id: CollectionId,
vectors: &[(EntityId, &str, &VectorData)],
) -> Result<(), VectorError>
pub fn put_vectors_batch( &self, collection_id: CollectionId, vectors: &[(EntityId, &str, &VectorData)], ) -> Result<(), VectorError>
Store multiple vectors at once.
This is more efficient than calling put_vector multiple times
as it uses a single transaction.
§Errors
Returns an error if the storage operation fails.
Sourcepub fn exists(
&self,
collection_id: CollectionId,
entity_id: EntityId,
vector_name: &str,
) -> Result<bool, VectorError>
pub fn exists( &self, collection_id: CollectionId, entity_id: EntityId, vector_name: &str, ) -> Result<bool, VectorError>
Sourcepub fn count_entity_vectors(
&self,
collection_id: CollectionId,
entity_id: EntityId,
) -> Result<usize, VectorError>
pub fn count_entity_vectors( &self, collection_id: CollectionId, entity_id: EntityId, ) -> Result<usize, VectorError>
Sourcepub fn list_entities_with_vector(
&self,
collection_id: CollectionId,
vector_name: &str,
) -> Result<Vec<EntityId>, VectorError>
pub fn list_entities_with_vector( &self, collection_id: CollectionId, vector_name: &str, ) -> Result<Vec<EntityId>, VectorError>
List all entity IDs that have vectors with a specific name in a collection.
Note: This is an expensive operation as it requires scanning all vectors in the collection. Use with caution on large collections.
§Errors
Returns an error if the storage operation fails.