Skip to main content

QuantizedIndex

Struct QuantizedIndex 

Source
pub struct QuantizedIndex { /* private fields */ }
Expand description

Exact scan over a selected compact representation.

Int8 and Binary require cosine distance. Floating-point formats support every DistanceMetric. Returned compact distances can be re-scored with Self::search_rerank.

Implementations§

Source§

impl QuantizedIndex

Source

pub fn build( config: IndexConfig, kind: QuantizationKind, vectors: &[(u64, &[f32])], ) -> Result<Self, SearchError>

Builds a compact exact-scan index.

§Errors

Returns typed config, vector, key, capacity, or allocation errors.

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub const fn dimensions(&self) -> usize

Source

pub const fn kind(&self) -> QuantizationKind

Source

pub const fn config(&self) -> &IndexConfig

Source

pub fn estimated_memory_bytes(&self) -> usize

Source

pub fn search( &self, query: &[f32], count: usize, ) -> Result<Vec<SearchHit>, SearchError>

Searches all compact vectors.

§Errors

Returns a typed query validation or allocation error.

Source

pub fn search_batch( &self, queries: &[&[f32]], count: usize, ) -> Result<Vec<Vec<SearchHit>>, SearchError>

Searches independent queries with bounded workers.

§Errors

Returns the first input or worker error.

Source

pub fn search_rerank( &self, oracle: &VectorIndex, query: &[f32], count: usize, candidates: usize, ) -> Result<Vec<SearchHit>, SearchError>

Retrieves compact candidates and re-scores them against an f32 index.

§Errors

Returns a typed dimension, query, key, or allocation error.

Source§

impl QuantizedIndex

Source

pub fn to_bytes(&self) -> Result<Vec<u8>, SearchError>

Serializes the complete compact index into a checksummed buffer.

§Errors

Returns a capacity or allocation error.

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Self, SearchError>

Restores and fully validates a compact index from a buffer.

§Errors

Returns a typed format, integrity, configuration, or allocation error.

Source

pub fn write_to(&self, writer: impl Write) -> Result<(), SearchError>

Writes the checksummed compact representation to a stream.

§Errors

Returns a serialization or stream error.

Source

pub fn read_from(reader: impl Read) -> Result<Self, SearchError>

Reads and validates a compact representation from a stream.

§Errors

Returns a stream, format, integrity, or allocation error.

Source

pub fn save(&self, path: impl AsRef<Path>) -> Result<(), SearchError>

Atomically saves a checksummed compact snapshot.

§Errors

Returns a serialization or filesystem error.

Source

pub fn load(path: impl AsRef<Path>) -> Result<Self, SearchError>

Loads and validates a compact snapshot.

§Errors

Returns a filesystem, format, integrity, or allocation error.

Trait Implementations§

Source§

impl Debug for QuantizedIndex

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl SearchShard for QuantizedIndex

Source§

fn dimensions(&self) -> usize

Source§

fn search_shard( &self, query: &[f32], count: usize, ) -> Result<Vec<SearchHit>, SearchError>

Searches this shard. Read more

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, 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.