pub struct CompressedVector { /* private fields */ }Expand description
Immutable per-vector compressed payload. Mirrors Python CompressedVector.
§Invariants
indices.len() == dimension as usizebit_width ∈ {2, 4, 8}- If
residual.is_some(),residual.len() == dimension as usize * 2
Implementations§
Source§impl CompressedVector
impl CompressedVector
Sourcepub fn new(
indices: Box<[u8]>,
residual: Option<Box<[u8]>>,
config_hash: ConfigHash,
dimension: u32,
bit_width: u8,
) -> Result<Self, CodecError>
pub fn new( indices: Box<[u8]>, residual: Option<Box<[u8]>>, config_hash: ConfigHash, dimension: u32, bit_width: u8, ) -> Result<Self, CodecError>
Validated constructor. Mirrors Python CompressedVector.__post_init__.
§Errors
CodecError::UnsupportedBitWidthifbit_width ∉ {2, 4, 8}CodecError::DimensionMismatchifindices.len() != dimensionCodecError::LengthMismatchifresidual.len() != dimension * 2
Sourcepub fn indices(&self) -> &[u8]
pub fn indices(&self) -> &[u8]
Raw index bytes — one byte per dimension (upper bits zero for bit_width < 8).
Sourcepub fn residual(&self) -> Option<&[u8]>
pub fn residual(&self) -> Option<&[u8]>
Optional f16 LE residual bytes — 2 * dimension bytes when present.
Sourcepub const fn config_hash(&self) -> &ConfigHash
pub const fn config_hash(&self) -> &ConfigHash
The config_hash of the CodecConfig used to compress this vector.
Sourcepub fn has_residual(&self) -> bool
pub fn has_residual(&self) -> bool
true when a residual buffer is present.
Sourcepub fn size_bytes(&self) -> usize
pub fn size_bytes(&self) -> usize
Python-parity size estimate: ceil(dim * bit_width / 8) + residual.len().
This is the packed on-disk footprint, not the in-memory footprint (indices are stored unpacked, 1 byte/dim, until Phase 16).
Trait Implementations§
Source§impl Clone for CompressedVector
impl Clone for CompressedVector
Source§fn clone(&self) -> CompressedVector
fn clone(&self) -> CompressedVector
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 moreAuto Trait Implementations§
impl Freeze for CompressedVector
impl RefUnwindSafe for CompressedVector
impl Send for CompressedVector
impl Sync for CompressedVector
impl Unpin for CompressedVector
impl UnsafeUnpin for CompressedVector
impl UnwindSafe for CompressedVector
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