pub struct QuantizedVector {Show 15 fields
pub code: Vec<u16>,
pub binary_code_packed: Vec<u8>,
pub ex_code_packed: Vec<u8>,
pub binary_code_unpacked: Vec<u8>,
pub ex_code_unpacked: Vec<u16>,
pub ex_bits: u8,
pub dim: usize,
pub delta: f32,
pub vl: f32,
pub f_add: f32,
pub f_rescale: f32,
pub f_error: f32,
pub residual_norm: f32,
pub f_add_ex: f32,
pub f_rescale_ex: f32,
}Expand description
Quantised representation of a vector using packed format (aligned with C++ implementation).
Binary codes and extended codes are stored in bit-packed format for memory efficiency.
binary_code_packed: 1 bit per dimensionex_code_packed: ex_bits per dimension
For performance-critical search operations, unpacked codes are cached to avoid repeated unpacking overhead.
Fields§
§code: Vec<u16>Full code (binary_code | ex_code), kept for backward compatibility
binary_code_packed: Vec<u8>Packed binary code (1 bit per element)
ex_code_packed: Vec<u8>Packed extended code (ex_bits per element)
binary_code_unpacked: Vec<u8>Cached unpacked binary code (for fast search)
ex_code_unpacked: Vec<u16>Cached unpacked ex code (for fast search)
ex_bits: u8Number of extended bits per element
dim: usizeOriginal dimension (before padding)
delta: f32§vl: f32§f_add: f32§f_rescale: f32§f_error: f32§residual_norm: f32§f_add_ex: f32§f_rescale_ex: f32Implementations§
Source§impl QuantizedVector
impl QuantizedVector
Sourcepub fn unpack_binary_code(&self) -> Vec<u8> ⓘ
pub fn unpack_binary_code(&self) -> Vec<u8> ⓘ
Unpack binary code for computation (legacy method, prefer using cached binary_code_unpacked)
Sourcepub fn unpack_ex_code(&self) -> Vec<u16>
pub fn unpack_ex_code(&self) -> Vec<u16>
Unpack extended code for computation (legacy method, prefer using cached ex_code_unpacked)
Sourcepub fn ensure_unpacked_cache(&mut self)
pub fn ensure_unpacked_cache(&mut self)
Ensure unpacked caches are populated (call after deserialization)
Trait Implementations§
Source§impl Clone for QuantizedVector
impl Clone for QuantizedVector
Source§fn clone(&self) -> QuantizedVector
fn clone(&self) -> QuantizedVector
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for QuantizedVector
impl Debug for QuantizedVector
Source§impl<'de> Deserialize<'de> for QuantizedVector
impl<'de> Deserialize<'de> for QuantizedVector
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for QuantizedVector
impl RefUnwindSafe for QuantizedVector
impl Send for QuantizedVector
impl Sync for QuantizedVector
impl Unpin for QuantizedVector
impl UnwindSafe for QuantizedVector
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more