Parquex.Zstd (parquex v0.4.0)

View Source

One-shot compression and decompression using standard Zstandard frames.

These functions operate on complete values in memory. Compression accepts iodata and uses zstd's default compression level when :level is omitted. Decompression requires :max_output_size so untrusted input cannot expand without an application-selected bound.

Examples

iex> {:ok, compressed} = Parquex.Zstd.compress(["hello", " world"])
iex> {:ok, "hello world"} =
...>   Parquex.Zstd.decompress(compressed, max_output_size: 11)

iex> {:ok, compressed} = Parquex.Zstd.compress("payload", level: 7)
iex> {:ok, "payload"} =
...>   Parquex.Zstd.decompress(compressed, max_output_size: 1_024)

The encoded bytes are interoperable zstd frames. Their exact representation is not guaranteed to remain identical when the native zstd implementation is upgraded.

Summary

Functions

Compresses complete iodata into one standard zstd frame.

Decompresses one or more concatenated standard zstd frames.

Functions

compress(data, options \\ [])

@spec compress(
  iodata(),
  keyword()
) :: {:ok, binary()} | {:error, Parquex.Error.t()}

Compresses complete iodata into one standard zstd frame.

:level defaults to 0, which selects zstd's default level. The native zstd implementation validates the supported level range.

decompress(data, options)

@spec decompress(
  iodata(),
  keyword()
) :: {:ok, binary()} | {:error, Parquex.Error.t()}

Decompresses one or more concatenated standard zstd frames.

The required :max_output_size is a non-negative byte limit. Decompression fails before returning data if the combined output would exceed that limit.