Expand description
Fixed-width bit packing over 1024-value chunks.
A full chunk at width 2..=63 uses the FastLanes-style interleaved lane order: value i lives in lane i % 16, and the 16 lanes advance together, so both pack and unpack run 16 identical shift-mask operations on consecutive words per step and auto-vectorize. A full chunk at width w occupies exactly 128 * w bytes, so chunk starts are always word aligned and a point read touches one chunk only. A short tail packs LSB-first sequentially into just the words it needs, which keeps tiny streams such as RLE run values from ballooning to full-chunk size. A tail long enough to fill the full-chunk byte count is zero-padded and transposed like a full chunk, so the packed size alone tells unpack which layout it holds. Width 1 stays sequential in every case: those streams are presence bitmaps whose consumers walk set bits by position, so bit i must mean value i. Width 64 stays a plain little-endian value array.
Constants§
- CHUNK
- Values per chunk. Format-stable.
Functions§
- pack
- Packs up to 1024 values at
widthbits into whole little-endian words. Values must already fit inwidthbits. - packed_
bytes - Packed size in bytes of
countvalues atwidthbits, rounded up to whole words. A full chunk is128 * width. - unpack
- Unpacks one chunk.
outmust be exactlyCHUNKlong;packedholds whole words and may cover fewer than 1024 values, in which case the remainder ofoutis zeroed.