Bzip2 compression codec.
Bzip2 is a high-ratio compression algorithm using the Burrows-Wheeler block-sorting text compression algorithm and Huffman coding. It produces smaller output than most other algorithms but is significantly slower.
Options
:block_size— Block size multiplier, 1-9 (default: 9). Higher values produce smaller output but use more memory.
Performance Characteristics
- Excellent compression ratio
- Slower compression and decompression than Zstd
- Higher memory usage, especially at higher block sizes
- Best for archival or storage where ratio matters more than speed
Examples
iex> {:ok, compressed} = ExCodecs.encode(:bzip2, "hello world")
iex> {:ok, decompressed} = ExCodecs.decode(:bzip2, compressed)
iex> decompressed
"hello world"
iex> {:ok, compressed} = ExCodecs.encode(:bzip2, "hello world", block_size: 6)
iex> is_binary(compressed)
true
Summary
Functions
Returns codec metadata for the registry.
Decodes (decompresses) Bzip2-compressed data.
Encodes (compresses) data using Bzip2.