pub struct QuantizedVectorStore { /* private fields */ }Expand description
Stores f32 vectors quantized to INT8, reducing memory ~4× vs raw f32.
Each vector is independently scaled with per-vector scale and zero_point
so that dequantization error is bounded to roughly scale / 2 per element.
§Memory layout
Internally uses a single flat Vec<i8> of length count * dim.
Implementations§
Source§impl QuantizedVectorStore
impl QuantizedVectorStore
Sourcepub fn push(&mut self, vector: &[f32]) -> usize
pub fn push(&mut self, vector: &[f32]) -> usize
Quantize vector to INT8 and append it to the store.
Returns the assigned integer ID (0-based).
Sourcepub fn get(&self, id: usize) -> Option<Vec<f32>>
pub fn get(&self, id: usize) -> Option<Vec<f32>>
Dequantize the vector stored at id back to f32.
Returns None if id >= self.len().
Sourcepub fn cosine_similarity_q(&self, a_id: usize, b_id: usize) -> f32
pub fn cosine_similarity_q(&self, a_id: usize, b_id: usize) -> f32
Compute approximate cosine similarity between two stored vectors.
Dequantizes both vectors then computes exact cosine similarity in f32. Returns 0.0 if either id is out of range or a vector has zero norm.
Sourcepub fn bytes_per_vector(&self) -> f64
pub fn bytes_per_vector(&self) -> f64
Approximate memory usage per stored vector (bytes).
Counts the i8 storage only (not scale/zero_point metadata):
dim * 1 byte per vector.
Auto Trait Implementations§
impl Freeze for QuantizedVectorStore
impl RefUnwindSafe for QuantizedVectorStore
impl Send for QuantizedVectorStore
impl Sync for QuantizedVectorStore
impl Unpin for QuantizedVectorStore
impl UnsafeUnpin for QuantizedVectorStore
impl UnwindSafe for QuantizedVectorStore
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.