# `GorillaStream.Compression.Gorilla.Encoder`
[🔗](https://github.com/awksedgreep/gorilla_stream/blob/main/lib/gorilla_stream/compression/gorilla/encoder.ex#L1)

Main encoder for the Gorilla compression algorithm.

This module coordinates the compression pipeline:
1. Separates timestamps and values from the input stream
2. Applies delta-of-delta encoding to timestamps
3. Applies XOR-based compression to values
4. Packs both bitstreams together
5. Adds metadata header

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

# `encode`

Encodes a stream of {timestamp, float} tuples using the Gorilla compression algorithm.

This is an optimized implementation that skips some validation checks for better performance.
Input data is assumed to be valid {timestamp, float} tuples.

## Parameters
- `data`: List of {timestamp, float} tuples

## Returns
- `{:ok, encoded_data}`: When encoding is successful
- `{:error, reason}`: When encoding fails

# `encode_elixir`

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

# `estimate_compression_ratio`

Estimates the compression ratio for given data without full compression.

This is useful for determining if Gorilla compression would be beneficial
for a particular dataset.

## Parameters
- `data`: List of {timestamp, float} tuples

## Returns
- `{:ok, estimated_ratio}`: Estimated compression ratio (compressed_size / original_size)
- `{:error, reason}`: If estimation fails

# `nif_available?`

Returns true if the native NIF encoder is available.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
