QuantizedVector

Struct QuantizedVector 

Source
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 dimension
  • ex_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: u8

Number of extended bits per element

§dim: usize

Original 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: f32

Implementations§

Source§

impl QuantizedVector

Source

pub fn unpack_binary_code(&self) -> Vec<u8>

Unpack binary code for computation (legacy method, prefer using cached binary_code_unpacked)

Source

pub fn unpack_ex_code(&self) -> Vec<u16>

Unpack extended code for computation (legacy method, prefer using cached ex_code_unpacked)

Source

pub fn ensure_unpacked_cache(&mut self)

Ensure unpacked caches are populated (call after deserialization)

Trait Implementations§

Source§

impl Clone for QuantizedVector

Source§

fn clone(&self) -> QuantizedVector

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for QuantizedVector

Source§

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

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

impl<'de> Deserialize<'de> for QuantizedVector

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for QuantizedVector

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Ungil for T
where T: Send,