Delta-of-delta decoding for timestamps in the Gorilla compression algorithm.
This module reverses the delta-of-delta encoding process to reconstruct the original timestamps from the compressed bitstream.
The decoding process:
- Read the first timestamp (64 bits)
- Read the first delta (variable length)
- For subsequent values, read delta-of-delta values and reconstruct timestamps:
- '0' bit: delta-of-delta is 0 (same interval as previous)
- '10' + 7 bits: delta-of-delta in range [-63, 64]
- '110' + 9 bits: delta-of-delta in range [-255, 256]
- '1110' + 12 bits: delta-of-delta in range [-2047, 2048]
- '1111' + 32 bits: delta-of-delta as 32-bit signed integer
Summary
Functions
Decodes timestamp bitstream back into a list of timestamps.
Gets information about a timestamp bitstream without full decoding.
Validates that a timestamp bitstream can be properly decoded.
Functions
Decodes timestamp bitstream back into a list of timestamps.
Parameters
timestamp_bits: Bitstream containing encoded timestampsmetadata: Metadata containing count and first timestamp info
Returns
{:ok, timestamps}: List of decoded timestamps{:error, reason}: If decoding fails
Gets information about a timestamp bitstream without full decoding.
Parameters
timestamp_bits: Bitstream to analyzemetadata: Metadata with count information
Returns
{:ok, info}with basic information, or{:error, reason}
Validates that a timestamp bitstream can be properly decoded.
Parameters
timestamp_bits: Bitstream to validateexpected_count: Expected number of timestamps
Returns
:okif valid,{:error, reason}if invalid