Skip to main content

VectorSegmentExt

Trait VectorSegmentExt 

Source
pub trait VectorSegmentExt: Send + Sync {
    // Required methods
    fn write_vector_segment<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        collection_name: &'life1 str,
        dim: usize,
        vectors: &'life2 [Vec<f32>],
        surrogate_ids: &'life3 [u64],
    ) -> Pin<Box<dyn Future<Output = Result<(), LiteError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn open_vector_segment<'life0, 'life1, 'async_trait>(
        &'life0 self,
        collection_name: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<PagedbBacking>, LiteError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete_vector_segment<'life0, 'life1, 'async_trait>(
        &'life0 self,
        collection_name: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), LiteError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Extension trait: write, open, and delete HNSW vector segments backed by pagedb encrypted segment files.

Implementors are responsible for translating between the generic NDVS byte stream and the pagedb segment page layout.

This trait is object-safe so StorageEngine implementations can return Option<&dyn VectorSegmentExt> via as_vector_segment_ext().

Required Methods§

Source

fn write_vector_segment<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, collection_name: &'life1 str, dim: usize, vectors: &'life2 [Vec<f32>], surrogate_ids: &'life3 [u64], ) -> Pin<Box<dyn Future<Output = Result<(), LiteError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Write a vector segment for collection_name.

Serialises the NDVS v2 format in memory, chunks it into 4 KiB pagedb pages, creates a new encrypted segment, and links it under vec/hnsw/{collection_name}. If a segment already exists under that name it is atomically replaced (old segment is tombstoned and will be reaped by the next Db::gc_now call).

vectors[i] corresponds to node i; surrogate_ids must either be empty or have the same length as vectors.

Source

fn open_vector_segment<'life0, 'life1, 'async_trait>( &'life0 self, collection_name: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<PagedbBacking>, LiteError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Open a previously written vector segment for collection_name.

Returns None if no segment exists under vec/hnsw/{collection_name}.

Source

fn delete_vector_segment<'life0, 'life1, 'async_trait>( &'life0 self, collection_name: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), LiteError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete the vector segment for collection_name.

No-op if no segment exists. The segment file is tombstoned and will be removed by the next Db::gc_now cycle.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<V: Vfs + Clone + Send + Sync + 'static> VectorSegmentExt for PagedbStorage<V>
where <V as Vfs>::LockHandle: Sync, <V as Vfs>::File: Sync,