Contents

COMPRESSION_LZ4_RAW

The LZ4 compression algorithm, without frame headers.

Declaration

var COMPRESSION_LZ4_RAW: compression_algorithm { get }

Discussion

Raw LZ4 is the same compression algorithm as COMPRESSION_LZ4, but it produces and consumes the bare LZ4 block format without the small frame that the Compression library wraps around the raw stream. Use it when you need to interoperate with a third-party LZ4 implementation that expects the unframed open-source block format directly, or when you’re writing data into a higher-level container that already provides its own framing, sizes, and validation.

The frame that COMPRESSION_LZ4 adds carries per-block magic bytes, the decoded and encoded sizes of each block, and an explicit end-of-stream marker (described in the discussion of COMPRESSION_LZ4). Raw LZ4 omits all of that.

A common reason to choose raw LZ4 is interoperability: the buffers it produces can be decoded directly by the open-source LZ4 library’s block decompression APIs, and likewise the Compression library can decode buffers produced by those APIs. The framed COMPRESSION_LZ4 doesn’t provide this interoperability, and a third-party decoder rejects the added frame bytes as invalid LZ4.

If you’re keeping the data inside an Apple-only pipeline, prefer COMPRESSION_LZ4 for the validation and the embedded size information.

Raw LZ4 is available through the buffer API only — compression_encode_buffer(_:_:_:_:_:_:) and compression_decode_buffer(_:_:_:_:_:_:).

See Also

Algorithm Constants