GorillaStream.Compression.Encoder.ValueCompression (gorilla_stream v3.0.3)

Copy Markdown View Source

XOR-based value compression for floating-point values as used in the Gorilla algorithm.

The algorithm works as follows:

  1. Store the first value as-is (64 bits)
  2. For subsequent values:
    • XOR the value with the previous value
    • If XOR result is 0: store single bit '0'
    • If XOR result is non-zero:
      • Count leading zeros and trailing zeros
      • If leading/trailing zero counts match the previous value's pattern: store '10' + meaningful bits only
      • Otherwise: store '11' + 5 bits for leading zeros + 6 bits for length + meaningful bits

This encoding is highly efficient for slowly changing floating-point time series data.

Summary

Functions

Compresses a list of float values using XOR-based compression.

Functions

compress(list)

Compresses a list of float values using XOR-based compression.

Parameters

  • values: List of float values

Returns

  • {encoded_bits, metadata}: Tuple containing the encoded bits as binary and metadata