TimelessMetrics.TextCodec (timeless_metrics v6.0.9)

Copy Markdown View Source

RLE + zstd compression codec for text time-series.

Groups consecutive points with the same string value into a single entry, storing the string once with all associated timestamps. The resulting binary is then zstd-compressed.

Binary format (pre-zstd):

entry_count    4 bytes  uint32
Per entry:
  ts_count     4 bytes  uint32
  timestamps   ts_count * 8 bytes (each int64)
  value_len    4 bytes  uint32
  value        value_len bytes (UTF-8 string)

Summary

Functions

Compress a list of {timestamp, string} points into a binary.

Decompress a binary back into {timestamp, string} points.

Functions

compress(points)

@spec compress([{integer(), String.t()}]) :: {:ok, binary()} | {:error, term()}

Compress a list of {timestamp, string} points into a binary.

Points must be sorted by timestamp. Consecutive points with the same string value are grouped into a single RLE entry.

decompress(binary)

@spec decompress(binary()) :: {:ok, [{integer(), String.t()}]} | {:error, term()}

Decompress a binary back into {timestamp, string} points.