pub struct Codec { /* private fields */ }Implementations§
Source§impl Codec
impl Codec
pub fn new(dim: usize, seed: u64) -> Self
pub fn dim(&self) -> usize
pub fn n_byte_groups(&self) -> usize
Sourcepub fn encode_packed(&self, vector: &[f32]) -> (Vec<u8>, f32)
pub fn encode_packed(&self, vector: &[f32]) -> (Vec<u8>, f32)
Encode vector into the packed 4-bit code groups +
pre-rotation L2 norm without appending to any storage. This is
the persistence-layer entry point used by
TurboExtent::append in the durable write path (#693). The
BlockedCodeStorage::append view of the same bytes is what
the in-memory scorer reads.
Sourcepub fn encode_into(
&self,
storage: &mut BlockedCodeStorage,
vector: &[f32],
) -> EncodedVector
pub fn encode_into( &self, storage: &mut BlockedCodeStorage, vector: &[f32], ) -> EncodedVector
Encode vector and append it to storage. Returns a handle the
caller can pass back to Self::score_many (indirectly through
the storage itself).
pub fn scalar_score( &self, query: &[f32], candidate: &[f32], metric: DistanceMetric, ) -> f32
Sourcepub fn score_many(
&self,
query: &[f32],
storage: &BlockedCodeStorage,
metric: DistanceMetric,
) -> Vec<f32>
pub fn score_many( &self, query: &[f32], storage: &BlockedCodeStorage, metric: DistanceMetric, ) -> Vec<f32>
Score query against every vector currently in storage.
Returns a Vec<f32> of length storage.n_blocks() * BLOCK_LANES
indexed by block_idx * BLOCK_LANES + lane; entries in unused
trailing-block lanes are filled with f32::NEG_INFINITY.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Codec
impl Freeze for Codecwhere
*const u8 is !null: Freeze,
PhantomData<usize>: Freeze,
PhantomData<f32>: Freeze,
PhantomData<f64>: Freeze,
impl Move for Codec
impl RefUnwindSafe for Codec
impl Send for Codecwhere
RawVecInner: Send,
impl Sync for Codecwhere
RawVecInner: Sync,
impl Unpin for Codec
impl UnsafeUnpin for Codecwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<usize>: UnsafeUnpin,
PhantomData<f32>: UnsafeUnpin,
PhantomData<f64>: UnsafeUnpin,
impl UnwindSafe for Codecwhere
RawVecInner: UnwindSafe,
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request