pub struct VectorStorage { /* private fields */ }Expand description
Vector storage with optional quantization
Manages storage of vectors in either raw f32 format or E8-quantized format. Supports dynamic re-quantization when changing modes.
Implementations§
Source§impl VectorStorage
impl VectorStorage
Sourcepub fn new(dimension: usize, quantization: Quantization) -> Self
pub fn new(dimension: usize, quantization: Quantization) -> Self
Sourcepub fn get_raw_slice(&self, id: usize) -> Option<&[f32]>
pub fn get_raw_slice(&self, id: usize) -> Option<&[f32]>
Get raw vector slice for unquantized storage (zero-copy) Returns None if vector is quantized or ID is invalid
Sourcepub fn get_stored(&self, id: usize) -> Option<&StoredVector>
pub fn get_stored(&self, id: usize) -> Option<&StoredVector>
Get stored vector reference by ID
Sourcepub fn get_batch(
&self,
ids: &[usize],
codec: Option<&E8Codec>,
) -> Vec<Option<Vec<f32>>>
pub fn get_batch( &self, ids: &[usize], codec: Option<&E8Codec>, ) -> Vec<Option<Vec<f32>>>
Batch get multiple vectors by IDs (more efficient than individual gets)
Sourcepub fn memory_bytes(&self) -> usize
pub fn memory_bytes(&self) -> usize
Get total memory usage in bytes
Sourcepub fn bytes_per_vector(&self) -> f32
pub fn bytes_per_vector(&self) -> f32
Get memory usage per vector (average)
Sourcepub fn set_quantization(
&mut self,
new_quantization: Quantization,
codec: Option<&E8Codec>,
) -> Result<()>
pub fn set_quantization( &mut self, new_quantization: Quantization, codec: Option<&E8Codec>, ) -> Result<()>
Change quantization mode (re-quantizes all vectors)
§Arguments
new_quantization- New quantization modecodec- E8 codec (required if switching to E8)
Sourcepub fn quantization(&self) -> &Quantization
pub fn quantization(&self) -> &Quantization
Get current quantization mode
Trait Implementations§
Auto Trait Implementations§
impl Freeze for VectorStorage
impl RefUnwindSafe for VectorStorage
impl Send for VectorStorage
impl Sync for VectorStorage
impl Unpin for VectorStorage
impl UnwindSafe for VectorStorage
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> 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