Blosc2 meta-compressor codec.
Blosc2 is a high-performance meta-compressor designed for binary data, particularly numerical arrays. It can use other compressors (Zstd, LZ4, etc.) internally while adding features like byte shuffle and frame-based container formats.
Options
:cname— Internal compressor::lz4,:lz4hc,:blosclz,:zstd,:snappy,:zlib(default::lz4):clevel— Compression level 0-9 (default: 5). 0 means no compression (store raw data).:shuffle— Shuffle filter::none,:byte(default::byte). Byte shuffle reorders data to improve compression ratios for typed data.:typesize— Element size in bytes for shuffle (default: 8)
Performance Characteristics
- Optimized for numerical/array data
- Byte shuffle dramatically improves compression ratios for typed data
- Excellent when used with appropriate typesize and shuffle settings
Examples
iex> {:ok, compressed} = ExCodecs.encode(:blosc2, <<1, 2, 3, 4, 5, 6, 7, 8>>)
iex> {:ok, decompressed} = ExCodecs.decode(:blosc2, compressed)
iex> decompressed
<<1, 2, 3, 4, 5, 6, 7, 8>>
iex> {:ok, compressed} = ExCodecs.encode(:blosc2, <<1, 2, 3, 4, 5, 6, 7, 8>>, cname: :zstd, clevel: 5, shuffle: :byte)
iex> is_binary(compressed)
trueNote: Blosc2 is optimized for data whose length is a multiple of
typesize. For general-purpose binary compression, Zstd or LZ4 may be more appropriate.
Summary
Functions
Returns codec metadata for the registry.
Decodes (decompresses) Blosc2-compressed data.
Encodes (compresses) data using Blosc2.
Functions
Returns codec metadata for the registry.
Decodes (decompresses) Blosc2-compressed data.
Encodes (compresses) data using Blosc2.
Options
:cname— Internal compressor atom (default::lz4):clevel— Compression level 0-9 (default: 5):shuffle— Shuffle filter::none,:byte(default::byte):typesize— Element size in bytes (default: 8)