pub struct Runs<'a, E: IntegerElement, Bd: Bound, C: Codec<E, Bd>, const MAX_RUN: usize> { /* private fields */ }Expand description
Sparse storage as a codec, not as a separate algorithm and not as a separate crate (D-16).
A run is (length, code): length consecutive decoded elements, all of
them d(code). A gap is a run whose code decodes to the alphabet’s zero, so
the zeros are explicit and the arithmetic downstream stays dense. No
sparse-specific speedup is claimed; the benefit is residency, and CG-03
measures it like any other codec’s.
A code is a run index, and the run’s length is what Codec::decode_len
reports. MAX_RUN is the longest run the caller declares, so this tier is
variable-length within a compile-time bound — which is exactly what the
MAX_BLOCK spelling is for (S4, S5b).
Implementations§
Source§impl<'a, E: IntegerElement, Bd: Bound, C: Codec<E, Bd>, const MAX_RUN: usize> Runs<'a, E, Bd, C, MAX_RUN>
impl<'a, E: IntegerElement, Bd: Bound, C: Codec<E, Bd>, const MAX_RUN: usize> Runs<'a, E, Bd, C, MAX_RUN>
Sourcepub fn new(inner: C, runs: &'a [(u32, C::Code)]) -> Option<Self>
pub fn new(inner: C, runs: &'a [(u32, C::Code)]) -> Option<Self>
Borrow a run list.
None when a run is empty or longer than MAX_RUN, both of which mean
the list describes no stream. Decided at construction, before any
arithmetic, like every other non-existence in this library (C6).
Sourcepub const fn run_count(&self) -> usize
pub const fn run_count(&self) -> usize
The number of stored runs, which is the residency this tier buys.
Sourcepub fn decoded_len(&self) -> usize
pub fn decoded_len(&self) -> usize
The decoded length of the whole run list.
CK-06 asserts this equals the declared row width, which is the
invariant that lets a variable-length tier live inside Codec.
Trait Implementations§
Source§impl<'a, E: Clone + IntegerElement, Bd: Clone + Bound, C: Clone + Codec<E, Bd>, const MAX_RUN: usize> Clone for Runs<'a, E, Bd, C, MAX_RUN>
impl<'a, E: Clone + IntegerElement, Bd: Clone + Bound, C: Clone + Codec<E, Bd>, const MAX_RUN: usize> Clone for Runs<'a, E, Bd, C, MAX_RUN>
Source§impl<E: IntegerElement, Bd: Bound, C: Codec<E, Bd>, const MAX_RUN: usize> Codec<E, Bd> for Runs<'_, E, Bd, C, MAX_RUN>
impl<E: IntegerElement, Bd: Bound, C: Codec<E, Bd>, const MAX_RUN: usize> Codec<E, Bd> for Runs<'_, E, Bd, C, MAX_RUN>
Source§const IS_FIXED_WIDTH: bool = false
const IS_FIXED_WIDTH: bool = false
Source§fn decode_len(&self, run: Self::Code) -> usize
fn decode_len(&self, run: Self::Code) -> usize
code actually produces. Read more