Expand description
DoubleDelta codec for timestamp columns.
Timestamps are monotonically increasing with near-constant intervals (e.g., every 10s). DoubleDelta encodes the difference-of-differences:
value[0] → stored raw (8 bytes)
delta[0] = v[1]-v[0] → stored raw (8 bytes)
dod[i] = delta[i] - delta[i-1] → bit-packed (usually 0 → 1 bit)For constant-rate timestamps, all delta-of-deltas are 0, achieving ~1 bit per sample after the header. 4x better than Gorilla for timestamp columns.
Wire format:
[4 bytes] sample count (LE u32)
[8 bytes] first value (LE i64)
[8 bytes] first delta (LE i64) — only present if count >= 2
[N bytes] bitstream of delta-of-deltas — only present if count >= 3DoD bit-packing uses the same bucket scheme as Gorilla timestamps:
0→ dod == 010+ 7 bits → dod in [-63, 64]110+ 9 bits → dod in [-255, 256]1110+ 12 bits → dod in [-2047, 2048]1111+ 64 bits → arbitrary dod
Structs§
- Double
Delta Decoder - Streaming DoubleDelta decoder. Wraps the batch
decode()function. - Double
Delta Encoder - Streaming DoubleDelta encoder. Accumulates values and produces
compressed bytes on
finish().