Delta-of-delta encoding for timestamps as used in the Gorilla compression algorithm.
The algorithm works as follows:
- Store the first timestamp as-is (64 bits)
- Store the delta between the second and first timestamp (variable length)
- For subsequent timestamps, compute delta-of-delta and encode with variable length:
- If delta-of-delta is 0: store single bit '0'
- If delta-of-delta fits in [-63, 64]: store '10' + 7 bits
- If delta-of-delta fits in [-255, 256]: store '110' + 9 bits
- If delta-of-delta fits in [-2047, 2048]: store '1110' + 12 bits
- Otherwise: store '1111' + 32 bits
This encoding is highly efficient for regularly spaced time series data.
Summary
Functions
Encodes a list of timestamps using delta-of-delta compression.