pub struct TqCodec { /* private fields */ }Expand description
Complete TQ codec for one field dimension. Cheap to build (sub-millisecond)
and immutable; share via Arc per open segment.
Implementations§
Source§impl TqCodec
impl TqCodec
pub fn new(dim: usize) -> Self
pub fn dim(&self) -> usize
pub fn padded_dim(&self) -> usize
Sourcepub fn fingerprint(&self) -> u64
pub fn fingerprint(&self) -> u64
Deterministic compatibility fingerprint carried as quantizer_version.
Sourcepub fn estimated_memory_bytes(&self) -> usize
pub fn estimated_memory_bytes(&self) -> usize
Heap footprint: two rotations (signs f32 + perm u32 per padded coord) plus the fixed-size codebook.
Sourcepub fn encode_into(
&self,
vector: &[f32],
nibbles: &mut [u8],
scratch: &mut TqEncodeScratch,
) -> f32
pub fn encode_into( &self, vector: &[f32], nibbles: &mut [u8], scratch: &mut TqEncodeScratch, ) -> f32
Encode one vector into nibbles (one 0..=15 value per padded
coordinate) and return gamma. The vector is normalized internally;
zero vectors encode as all-zero nibbles with gamma = 0.
Sourcepub fn encode_residual_into(
&self,
vector: &[f32],
nibbles: &mut [u8],
scratch: &mut TqEncodeScratch,
) -> (f32, f32)
pub fn encode_residual_into( &self, vector: &[f32], nibbles: &mut [u8], scratch: &mut TqEncodeScratch, ) -> (f32, f32)
Encode one (possibly non-unit) vector as scale · unit_direction and
return (scale = ‖vector‖₂, gamma). IVF leaves store centroid
residuals, whose norms carry ranking information; scale restores it
at score time. Zero vectors encode as all-zero nibbles with
scale = gamma = 0.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TqCodec
impl RefUnwindSafe for TqCodec
impl Send for TqCodec
impl Sync for TqCodec
impl Unpin for TqCodec
impl UnsafeUnpin for TqCodec
impl UnwindSafe for TqCodec
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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> ⓘ
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