Documentation
¶
Overview ¶
Package bitpack implements the pure bit-packing and SIMD kernel layer shared by qdf's integer codecs (FOR, Delta+FOR, dict, PFOR, ALP). It encodes []uint64 deltas as a tight LSB-first bit-stream and decodes it back, with byte-aligned and variable-width fast paths dispatched to hand-written AVX2 (amd64) / NEON (arm64) kernels under the qdf_simd build tag and a portable scalar fallback otherwise.
The layer is dependency-closed: it imports only the standard library and golang.org/x/sys/cpu, and holds no qdf wire-format or codec state. All bit layouts are LSB-first within each byte; Pack and Unpack are exact inverses for every width in [1, 56].
Index ¶
- func BitsForDelta(d uint64) int
- func DecodeHex4(dst, src []byte, lut *[16]byte)
- func Pack(out []byte, vals []uint64, bitsPer int)
- func PackBoolsLSB(dst []byte, src []bool, n int)
- func PackChunk(out []byte, vals []uint64, bitsPer int, elemOff int)
- func Unpack(out []uint64, in []byte, bitsPer int)
- func UnpackScalar(out []uint64, in []byte, bitsPer int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BitsForDelta ¶
BitsForDelta returns the number of bits required to represent values in [0, d], i.e. bits.Len64(d). 0 => no bits needed (all equal).
func DecodeHex4 ¶ added in v0.1.1
DecodeHex4 fills dst from a 4-bit nibble stream src via the 16-entry LUT (dst[2i]=lut[src[i]&0xf], dst[2i+1]=lut[src[i]>>4]). Scalar fallback for non-SIMD builds.
func Pack ¶
Pack writes len(vals)*bits bits into out, LSB-first within each byte. out must have len >= ceil(len(vals)*bits/8). bits must be in [1, 56].
func PackBoolsLSB ¶
PackBoolsLSB fallback: plain scalar bit-by-bit pack.
func PackChunk ¶
PackChunk writes a chunk of values starting at element offset elemOff in the output bit-stream. It is Pack generalised to write into the middle of an existing buffer. bitsPer must be in [0, 56].
func Unpack ¶
Unpack reads len(out)*bits bits from in. bits must be in [1, 56]. in must have len >= ceil(len(out)*bits/8). Byte-aligned widths take a dedicated zero-extend fast path (asm under qdf_simd, otherwise scalar memcpy-with-mask); other widths use the variable-width / sliding-window decoders.
func UnpackScalar ¶
UnpackScalar is the original byte-at-a-time decoder, kept as a parity reference (oracle) for the fast paths' tests.
Types ¶
This section is empty.