GorillaStream.Compression.Gorilla.Decoder (gorilla_stream v3.0.1)

Copy Markdown View Source

Main decoder for the Gorilla compression algorithm.

This module coordinates the decompression pipeline:

  1. Extracts and validates metadata header
  2. Unpacks the combined bitstream into timestamp and value components
  3. Applies delta-of-delta decoding to timestamps
  4. Applies XOR-based decompression to values
  5. Recombines timestamps and values into the original stream

The Gorilla algorithm is specifically designed for time series data with regularly spaced timestamps and slowly changing floating-point values.

Summary

Functions

Decodes compressed binary data back into a stream of {timestamp, float} tuples.

Decodes and validates the result matches expected characteristics.

Pure-Elixir decode, used as fallback when NIF is unavailable.

Estimates decompression performance for given compressed data.

Gets information about compressed data without full decompression.

Returns true if the native NIF decoder is available.

Validates that compressed data can be properly decoded without full decompression.

Functions

decode(encoded_data)

Decodes compressed binary data back into a stream of {timestamp, float} tuples.

Parameters

  • encoded_data: Binary data to decode

Returns

  • {:ok, decoded_data}: When decoding is successful
  • {:error, reason}: When decoding fails

decode_and_validate(encoded_data, validation_opts \\ [])

Decodes and validates the result matches expected characteristics.

Parameters

  • encoded_data: Binary data to decode
  • validation_opts: Optional validation parameters

Returns

  • {:ok, {stream, stats}}: Decoded stream and statistics
  • {:error, reason}: If decoding or validation fails

decode_elixir(encoded_data)

Pure-Elixir decode, used as fallback when NIF is unavailable.

estimate_decompression_performance(encoded_data)

Estimates decompression performance for given compressed data.

Parameters

  • encoded_data: Binary data to analyze

Returns

  • {:ok, performance_info}: Performance estimates
  • {:error, reason}: If analysis fails

get_compression_info(encoded_data)

Gets information about compressed data without full decompression.

Parameters

  • encoded_data: Binary data to analyze

Returns

  • {:ok, info} with compression information, or {:error, reason}

nif_available?()

Returns true if the native NIF decoder is available.

validate_compressed_data(encoded_data)

Validates that compressed data can be properly decoded without full decompression.

Parameters

  • encoded_data: Binary data to validate

Returns

  • :ok if valid, {:error, reason} if invalid