Elixir bindings for OpenZL, Meta's format-aware compression framework.
Provides one-shot compression and decompression of binary data, with optional reusable contexts for amortizing setup cost across many operations. Supports typed/columnar compression and SDDL format-aware compression.
Thread Safety
Compression and decompression contexts are not thread-safe. Each context should be used by a single Erlang/Elixir process at a time. If you need to compress or decompress from multiple concurrent processes, create a separate context per process rather than sharing one.
Summary
Functions
Compresses the given binary using OpenZL.
Compresses the given binary using a reusable compression context.
Returns the upper bound on compressed output size for a given input size.
Compresses multiple typed inputs into a single frame.
Compresses typed data (numeric, struct, or string) with type information.
Creates a reusable compression context.
Creates a reusable decompression context.
Creates a compressor from compiled SDDL binary.
Decompresses an OpenZL-compressed binary.
Decompresses using a reusable decompression context.
Decompresses a multi-output frame into a list of typed result maps.
Decompresses a single typed output from a compressed frame.
Queries frame metadata without decompression.
Compiles SDDL source text to a binary description.
Sets the compression level on a reusable compression context.
Attaches a compressor to a compression context.
Returns the OpenZL library version string.
Functions
Compresses the given binary using OpenZL.
Returns {:ok, compressed} on success or {:error, reason} on failure.
Compresses the given binary using a reusable compression context.
Creating a context with create_compression_context/0 and reusing it
across multiple calls avoids repeated allocation of internal state.
@spec compress_bound(non_neg_integer()) :: non_neg_integer()
Returns the upper bound on compressed output size for a given input size.
Useful for pre-allocating buffers.
Compresses multiple typed inputs into a single frame.
Each input is a tagged tuple: {:numeric, data, width},
{:struct, data, struct_width}, or {:string, data, lengths_bin}.
Compresses typed data (numeric, struct, or string) with type information.
Accepts tagged tuples:
{:numeric, data, element_width}— width must be 1, 2, 4, or 8{:struct, data, struct_width}— fixed-width records{:string, data, lengths_bin}— variable-length strings with packed uint32 lengths
Creates a reusable compression context.
The context is garbage-collected when no longer referenced.
Contexts are not thread-safe — do not share a context across concurrent processes without external synchronization.
Creates a reusable decompression context.
The context is garbage-collected when no longer referenced.
Contexts are not thread-safe — do not share a context across concurrent processes without external synchronization.
Creates a compressor from compiled SDDL binary.
Decompresses an OpenZL-compressed binary.
Returns {:ok, decompressed} on success or {:error, reason} on failure.
Decompresses using a reusable decompression context.
Decompresses a multi-output frame into a list of typed result maps.
Decompresses a single typed output from a compressed frame.
Returns {:ok, info_map} where info_map contains :type, :data,
:element_width, :num_elements, and optionally :string_lengths.
Queries frame metadata without decompression.
Returns {:ok, info_map} with :format_version, :num_outputs, and
:outputs (a list of per-output metadata maps).
Compiles SDDL source text to a binary description.
Sets the compression level on a reusable compression context.
Higher levels produce smaller output but take longer. The level persists across subsequent compress calls on the same context (sticky parameters).
Attaches a compressor to a compression context.
After this call, compress/2 on this context will use the compressor's
format-aware compression graph.
@spec version() :: String.t()
Returns the OpenZL library version string.