
PackedIntCodec
- Namespace
- Rowles.LeanLucene.Codecs.Postings
- Assembly
- Rowles.LeanLucene.dll
Frame-of-Reference bit-packing codec for blocks of 128 integers. Packs values using the minimum number of bits needed for the largest value in the block.
Output format: [numBits : 1 byte][packed data : numBits × 16 bytes].
When numBits is 0 (all values are zero) the output is a single byte.
public static class PackedIntCodec
BlockSize
Number of integers processed per block.
BitsRequired(ReadOnlySpan<int>)
Computes the number of bits needed to represent the maximum value in the span. Returns 0 if all values are 0.
Pack(ReadOnlySpan<int>, Span<byte>)
Packs BlockSize values into minimum-width bit-packed format.
Returns the number of bytes written to output.
PackDelta(ReadOnlySpan<int>, int, Span<byte>)
Packs BlockSize sorted values using delta encoding.
Each value is stored as the difference from the previous value;
offset is subtracted from the first value.
Returns (numBits, bytesWritten). The caller must store
numBits and offset separately.
Unpack(ReadOnlySpan<byte>, int, Span<int>)
Unpacks bit-packed data into BlockSize integer values.
numBits is the bit width per value (0–32).
UnpackDelta(ReadOnlySpan<byte>, int, int, Span<int>)
Unpacks delta-encoded packed data and integrates (prefix sum) to recover the original absolute values.