pub struct TurboQuantBlockedCodes { /* private fields */ }Expand description
Block-major packed TurboQuant coordinate codes.
Rows are grouped in fixed 32-row blocks. For each block, all rows for packed
byte 0 are stored contiguously, then all rows for packed byte 1, and so on.
This preserves the same packed row representation as TurboQuantPackedCodes
while making search-time scans load one byte position across a whole block.
Implementations§
Source§impl TurboQuantBlockedCodes
impl TurboQuantBlockedCodes
Sourcepub fn new(
bit_width: TurboQuantBitWidth,
dimensions: usize,
rows: usize,
) -> TurboQuantCodecResult<Self>
pub fn new( bit_width: TurboQuantBitWidth, dimensions: usize, rows: usize, ) -> TurboQuantCodecResult<Self>
Allocate zero-filled blocked-code storage.
§Errors
Returns an error when dimensions are invalid or the computed byte size
overflows usize.
Sourcepub fn from_row_major(
codes: &TurboQuantPackedCodes,
) -> TurboQuantCodecResult<Self>
pub fn from_row_major( codes: &TurboQuantPackedCodes, ) -> TurboQuantCodecResult<Self>
Repack row-major packed codes into block-major storage.
§Errors
Returns an error if the blocked storage size overflows usize.
Sourcepub const fn bit_width(&self) -> TurboQuantBitWidth
pub const fn bit_width(&self) -> TurboQuantBitWidth
Return the bit width used by the blocked codes.
Sourcepub const fn dimensions(&self) -> usize
pub const fn dimensions(&self) -> usize
Return the number of dimensions encoded in each row.
Sourcepub const fn bytes_per_row(&self) -> usize
pub const fn bytes_per_row(&self) -> usize
Return the byte stride for one packed row.
Sourcepub fn block_count(&self) -> usize
pub fn block_count(&self) -> usize
Return the number of row blocks in the backing storage.
Sourcepub fn block_byte(&self, block: usize, byte: usize) -> &[u8] ⓘ
pub fn block_byte(&self, block: usize, byte: usize) -> &[u8] ⓘ
Return the packed bytes for one byte position across a 32-row block.
The returned slice always has TURBO_QUANT_BLOCK_ROWS bytes. Tail
lanes beyond Self::block_len are zero padding.
Sourcepub fn write_row_bytes(
&mut self,
row: usize,
bytes: &[u8],
) -> TurboQuantCodecResult<()>
pub fn write_row_bytes( &mut self, row: usize, bytes: &[u8], ) -> TurboQuantCodecResult<()>
Overwrite one packed row from caller-provided row-major bytes.
§Errors
Returns a bounds error when row is outside the matrix, or a byte-length
mismatch when bytes does not contain exactly one packed row.
Sourcepub fn estimated_bytes(&self) -> usize
pub fn estimated_bytes(&self) -> usize
Return the blocked-code byte footprint.
Sourcepub fn resize_rows(&mut self, rows: usize) -> TurboQuantCodecResult<()>
pub fn resize_rows(&mut self, rows: usize) -> TurboQuantCodecResult<()>
Resize the row count while preserving existing packed rows.
Newly added rows are zero-filled. Shrinking clears rows that remain in a retained tail block, so later growth cannot expose stale packed bytes.
§Errors
Returns an error when the computed byte size overflows usize.
Sourcepub fn swap_remove_row(&mut self, row: usize) -> TurboQuantCodecResult<()>
pub fn swap_remove_row(&mut self, row: usize) -> TurboQuantCodecResult<()>
Remove one row by moving the current last row into its slot.
This preserves the packed row bytes without decoding individual
coordinate codes. Tail bytes are cleared through Self::resize_rows.
§Errors
Returns a bounds error when row is outside the matrix, or an overflow
error if shrinking the storage would overflow internal size accounting.
Sourcepub fn read(&self, row: usize, dimension: usize) -> TurboQuantCodecResult<u8>
pub fn read(&self, row: usize, dimension: usize) -> TurboQuantCodecResult<u8>
Read one packed coordinate code.
§Errors
Returns bounds errors when row or dimension is outside the packed
matrix.
Sourcepub fn write(
&mut self,
row: usize,
dimension: usize,
code: u8,
) -> TurboQuantCodecResult<()>
pub fn write( &mut self, row: usize, dimension: usize, code: u8, ) -> TurboQuantCodecResult<()>
Write one packed coordinate code.
§Errors
Returns bounds errors when row or dimension is outside the packed
matrix, and TurboQuantCodecError::InvalidCode when code exceeds
this storage’s bit width.
Trait Implementations§
Source§impl Clone for TurboQuantBlockedCodes
impl Clone for TurboQuantBlockedCodes
Source§fn clone(&self) -> TurboQuantBlockedCodes
fn clone(&self) -> TurboQuantBlockedCodes
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TurboQuantBlockedCodes
impl Debug for TurboQuantBlockedCodes
impl Eq for TurboQuantBlockedCodes
Source§impl PartialEq for TurboQuantBlockedCodes
impl PartialEq for TurboQuantBlockedCodes
Source§fn eq(&self, other: &TurboQuantBlockedCodes) -> bool
fn eq(&self, other: &TurboQuantBlockedCodes) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for TurboQuantBlockedCodes
Auto Trait Implementations§
impl Freeze for TurboQuantBlockedCodes
impl RefUnwindSafe for TurboQuantBlockedCodes
impl Send for TurboQuantBlockedCodes
impl Sync for TurboQuantBlockedCodes
impl Unpin for TurboQuantBlockedCodes
impl UnsafeUnpin for TurboQuantBlockedCodes
impl UnwindSafe for TurboQuantBlockedCodes
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.