Struct lance_index::vector::pq::storage::ProductQuantizationStorage
source · pub struct ProductQuantizationStorage { /* private fields */ }Expand description
Product Quantization Storage
It stores PQ code, as well as the row ID to the orignal vectors.
It is possible to store additonal metadata to accelerate filtering later.
TODO: support f16/f64 later.
Implementations§
source§impl ProductQuantizationStorage
impl ProductQuantizationStorage
pub fn new( codebook: Arc<Float32Array>, batch: RecordBatch, num_bits: u32, num_sub_vectors: usize, dimension: usize, metric_type: MetricType ) -> Result<Self>
pub fn batch(&self) -> &RecordBatch
sourcepub async fn build(
quantizer: Arc<ProductQuantizerImpl<Float32Type>>,
batch: &RecordBatch,
vector_col: &str
) -> Result<Self>
pub async fn build( quantizer: Arc<ProductQuantizerImpl<Float32Type>>, batch: &RecordBatch, vector_col: &str ) -> Result<Self>
Build a PQ storage from ProductQuantizer and a RecordBatch.
§Parameters
quantizer: ProductQuantizer The quantizer used to transform the vectors. batch: RecordBatch The batch of vectors to be transformed. vector_col: &str The name of the column containing the vectors.
sourcepub async fn load(object_store: &ObjectStore, path: &Path) -> Result<Self>
pub async fn load(object_store: &ObjectStore, path: &Path) -> Result<Self>
pub fn schema(&self) -> SchemaRef
pub fn get_row_ids(&self, ids: &[u32]) -> Vec<u64>
sourcepub async fn write_partition(
&self,
writer: &mut FileWriter<ManifestDescribing>
) -> Result<usize>
pub async fn write_partition( &self, writer: &mut FileWriter<ManifestDescribing> ) -> Result<usize>
Write the PQ storage as a Lance partition to disk, and returns the number of rows written.
sourcepub async fn write_full(
&self,
writer: &mut FileWriter<ManifestDescribing>
) -> Result<()>
pub async fn write_full( &self, writer: &mut FileWriter<ManifestDescribing> ) -> Result<()>
Write the PQ storage to disk.
Trait Implementations§
source§impl Clone for ProductQuantizationStorage
impl Clone for ProductQuantizationStorage
source§fn clone(&self) -> ProductQuantizationStorage
fn clone(&self) -> ProductQuantizationStorage
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for ProductQuantizationStorage
impl Debug for ProductQuantizationStorage
source§impl PartialEq for ProductQuantizationStorage
impl PartialEq for ProductQuantizationStorage
source§impl QuantizerStorage for ProductQuantizationStorage
impl QuantizerStorage for ProductQuantizationStorage
source§fn load_partition<'life0, 'life1, 'async_trait>(
reader: &'life0 FileReader,
range: Range<usize>,
metric_type: MetricType,
metadata: &'life1 Self::Metadata
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_partition<'life0, 'life1, 'async_trait>(
reader: &'life0 FileReader,
range: Range<usize>,
metric_type: MetricType,
metadata: &'life1 Self::Metadata
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
type Metadata = ProductQuantizationMetadata
source§impl VectorStorage for ProductQuantizationStorage
impl VectorStorage for ProductQuantizationStorage
fn as_any(&self) -> &dyn Any
fn len(&self) -> usize
fn row_ids(&self) -> &[u64]
source§fn metric_type(&self) -> MetricType
fn metric_type(&self) -> MetricType
Return the metric type of the vectors.
Auto Trait Implementations§
impl Freeze for ProductQuantizationStorage
impl !RefUnwindSafe for ProductQuantizationStorage
impl Send for ProductQuantizationStorage
impl Sync for ProductQuantizationStorage
impl Unpin for ProductQuantizationStorage
impl !UnwindSafe for ProductQuantizationStorage
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 more