Skip to main content

Bits1Query

Struct Bits1Query 

Source
pub struct Bits1Query {
    pub norm_sq: f32,
    /* private fields */
}
Expand description

A query prepared for popcount scoring against 1-bit codes.

Fields§

§norm_sq: f32

Exact ‖q‖².

Implementations§

Source§

impl Bits1Query

Source

pub fn new(rotated: &[f32]) -> Result<Self, TurboQuantError>

Build from the rotated f32 query (same input the Turbo4 query prep uses; qscale/norm_sq semantics identical to encode_query).

Source

pub fn distance_to(&self, metric: Metric, blob: &[u8]) -> f32

Estimated distance to a 1-bit code blob under metric. Pure AND+POPCNT per plane; conventions match the Turbo4 scorers.

Source

pub fn to_blob(&self) -> Vec<u8> ⓘ

Serialize into the flat query-blob form consumed by query_blob_distance — this is what travels through hnsw_rs::Distance<u8>::eval in cascade mode.

Layout: [8 planes × bits_len | 8 × plane_pop u32 | qscale | ‖q‖²].

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.