CollectionVectorStore

Struct CollectionVectorStore 

Source
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>

Source

pub const fn new(engine: E) -> Self

Create a new collection vector store.

Source

pub fn put_vector( &self, collection_id: CollectionId, entity_id: EntityId, vector_name: &str, data: &VectorData, ) -> Result<(), VectorError>

Store a vector for an entity.

§Errors

Returns an error if the storage operation fails.

Source

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.

Source

pub fn get_vector( &self, collection_id: CollectionId, entity_id: EntityId, vector_name: &str, ) -> Result<Option<VectorData>, VectorError>

Get a vector for an entity.

§Errors

Returns an error if the storage operation fails.

Source

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.

Source

pub fn delete_vector( &self, collection_id: CollectionId, entity_id: EntityId, vector_name: &str, ) -> Result<bool, VectorError>

Delete a specific vector.

§Returns

Returns Ok(true) if the vector was deleted, Ok(false) if it didn’t exist.

§Errors

Returns an error if the storage operation fails.

Source

pub fn delete_all_vectors( &self, collection_id: CollectionId, entity_id: EntityId, ) -> Result<usize, VectorError>

Delete all vectors for an entity.

This is called when an entity is deleted to cascade-delete its vectors.

§Returns

Returns the number of vectors deleted.

§Errors

Returns an error if the storage operation fails.

Source

pub fn delete_all_vectors_tx<T: Transaction>( &self, tx: &mut T, collection_id: CollectionId, entity_id: EntityId, ) -> Result<usize, VectorError>

Delete all vectors for an entity within a transaction.

Use this method when you need to delete vectors as part of a larger atomic operation (e.g., deleting an entity with its vectors).

§Returns

Returns the number of vectors deleted.

§Errors

Returns an error if the storage operation fails.

Source

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.

Source

pub fn exists( &self, collection_id: CollectionId, entity_id: EntityId, vector_name: &str, ) -> Result<bool, VectorError>

Check if a vector exists for an entity.

§Errors

Returns an error if the storage operation fails.

Source

pub fn count_entity_vectors( &self, collection_id: CollectionId, entity_id: EntityId, ) -> Result<usize, VectorError>

Count the number of vectors for an entity.

§Errors

Returns an error if the storage operation fails.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more