lance_index::vector::storage

Trait VectorStore

source
pub trait VectorStore:
    Send
    + Sync
    + Sized
    + Clone {
    type DistanceCalculator<'a>: DistCalculator
       where Self: 'a;

Show 14 methods // Required methods fn try_from_batch( batch: RecordBatch, distance_type: DistanceType, ) -> Result<Self>; fn as_any(&self) -> &dyn Any; fn schema(&self) -> &SchemaRef; fn to_batches(&self) -> Result<impl Iterator<Item = RecordBatch>>; fn len(&self) -> usize; fn distance_type(&self) -> DistanceType; fn row_id(&self, id: u32) -> u64; fn row_ids(&self) -> impl Iterator<Item = &u64>; fn append_batch( &self, batch: RecordBatch, vector_column: &str, ) -> Result<Self>; fn dist_calculator(&self, query: ArrayRef) -> Self::DistanceCalculator<'_>; fn dist_calculator_from_id(&self, id: u32) -> Self::DistanceCalculator<'_>; fn distance_between(&self, a: u32, b: u32) -> f32; // Provided methods fn is_empty(&self) -> bool { ... } fn dist_calculator_from_native( &self, _query: ArrayRef, ) -> Self::DistanceCalculator<'_> { ... }
}
Expand description

Vector Storage is the abstraction to store the vectors.

It can be in-memory or on-disk, raw vector or quantized vectors.

It abstracts away the logic to compute the distance between vectors.

TODO: should we rename this to “VectorDistance”?;

Internal API

API stability is not guaranteed

Required Associated Types§

source

type DistanceCalculator<'a>: DistCalculator where Self: 'a

Required Methods§

source

fn try_from_batch( batch: RecordBatch, distance_type: DistanceType, ) -> Result<Self>

source

fn as_any(&self) -> &dyn Any

source

fn schema(&self) -> &SchemaRef

source

fn to_batches(&self) -> Result<impl Iterator<Item = RecordBatch>>

source

fn len(&self) -> usize

source

fn distance_type(&self) -> DistanceType

Return DistanceType.

source

fn row_id(&self, id: u32) -> u64

Get the lance ROW ID from one vector.

source

fn row_ids(&self) -> impl Iterator<Item = &u64>

source

fn append_batch(&self, batch: RecordBatch, vector_column: &str) -> Result<Self>

Append Raw RecordBatch into the Storage. The storage implement will perform quantization if necessary.

source

fn dist_calculator(&self, query: ArrayRef) -> Self::DistanceCalculator<'_>

Create a DistCalculator to compute the distance between the query.

Using dist calcualtor can be more efficient as it can pre-compute some values.

source

fn dist_calculator_from_id(&self, id: u32) -> Self::DistanceCalculator<'_>

source

fn distance_between(&self, a: u32, b: u32) -> f32

Provided Methods§

source

fn is_empty(&self) -> bool

Returns true if this graph is empty.

source

fn dist_calculator_from_native( &self, _query: ArrayRef, ) -> Self::DistanceCalculator<'_>

Object Safety§

This trait is not object safe.

Implementors§