pub struct BinaryQuantized {
pub bits: Vec<u8>,
pub dimensions: usize,
}Expand description
Binary quantization (32x compression)
Fields§
§bits: Vec<u8>Binary representation (1 bit per dimension, packed into bytes)
dimensions: usizeNumber of dimensions
Implementations§
Source§impl BinaryQuantized
impl BinaryQuantized
Sourcepub fn hamming_distance_fast(a: &[u8], b: &[u8]) -> u32
pub fn hamming_distance_fast(a: &[u8], b: &[u8]) -> u32
Fast hamming distance using SIMD-optimized operations
Uses hardware POPCNT on x86_64 or NEON vcnt on ARM64 for optimal performance. Processes 16 bytes at a time on ARM64, 8 bytes at a time on x86_64. Falls back to 64-bit operations for remainders.
Sourcepub fn similarity(&self, other: &Self) -> f32
pub fn similarity(&self, other: &Self) -> f32
Compute normalized hamming similarity (0.0 to 1.0)
Sourcepub fn compression_ratio() -> f32
pub fn compression_ratio() -> f32
Get compression ratio (32x for binary)
Sourcepub fn from_bytes(bits: Vec<u8>, dimensions: usize) -> Self
pub fn from_bytes(bits: Vec<u8>, dimensions: usize) -> Self
Create from bytes
Trait Implementations§
Source§impl Clone for BinaryQuantized
impl Clone for BinaryQuantized
Source§fn clone(&self) -> BinaryQuantized
fn clone(&self) -> BinaryQuantized
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BinaryQuantized
impl Debug for BinaryQuantized
Source§impl<'de> Deserialize<'de> for BinaryQuantized
impl<'de> Deserialize<'de> for BinaryQuantized
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl QuantizedVector for BinaryQuantized
impl QuantizedVector for BinaryQuantized
Auto Trait Implementations§
impl Freeze for BinaryQuantized
impl RefUnwindSafe for BinaryQuantized
impl Send for BinaryQuantized
impl Sync for BinaryQuantized
impl Unpin for BinaryQuantized
impl UnwindSafe for BinaryQuantized
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
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 more