Documentation
¶
Overview ¶
Package alp implements Adaptive Lossless floating-Point compression.
ALP is a lossless compression scheme for floating-point data from SIGMOD 2024. It exploits the fact that most real-world floats are human-friendly decimals that can be represented as integers scaled by powers of 10.
Reference: https://dl.acm.org/doi/10.1145/3626717
Index ¶
- Constants
- func Decode(dst []float64, src *Vector)
- func DecodeRD48(dst []float64, leftCodes, rightParts []byte, prefixes [2]uint16)
- func Encode(dst *Vector, src []float64, s State)
- func Pack(vector *Vector) []byte
- func PackedSize(vector *Vector) int
- func Unpack(dst *Vector, src []byte)
- type State
- type Vector
Constants ¶
const VectorSize = 1024
VectorSize is the number of values per compression block. This matches the paper's recommendation for cache efficiency.
Variables ¶
This section is empty.
Functions ¶
func DecodeRD48 ¶
DecodeRD48 decodes the common ALP-RD layout with two 16-bit prefixes and one packed 48-bit suffix per value. Each bit in leftCodes selects one of the prefixes; rightParts stores six little-endian bytes per value.
DecodeRD48 panics if leftCodes or rightParts are too short for dst.
func Pack ¶
Pack serializes a Vector to bytes.
The format is a 13-byte header, bit-packed encoded values, then exceptions. The header contains frame-of-reference (8 bytes), bit width, exponent, factor, and exception count (2 bytes), all in little-endian order.
func PackedSize ¶
PackedSize returns the number of bytes Pack will produce for vector.
Types ¶
type State ¶
type State struct {
Exp uint8 // Exponent: multiply by 10^Exp before rounding
Factor uint8 // Factor: divide by 10^Factor after rounding
}
State holds the encoding parameters learned from sampling. A single State can encode many vectors of similar data.
type Vector ¶
type Vector struct {
// Encoded contains the integers after ALP transformation.
Encoded [VectorSize]int64
// FrameOfRef is the minimum encoded value subtracted for bit-packing.
FrameOfRef int64
// BitWidth is the number of bits needed to represent max-min.
BitWidth uint8
// Exp and Factor are the encoding parameters used for this vector.
Exp uint8
Factor uint8
// ExceptionPos and ExceptionBits contain the positions and raw float bits
// for values that do not round-trip through the integer transform. Only the
// first NumExceptions entries are valid.
NumExceptions uint16
ExceptionPos [VectorSize]uint16
ExceptionBits [VectorSize]uint64
}
Vector is a compressed block of VectorSize float64 values.