Skip to content

About

Transcoding codecs for compression and decompression with LZ4

Resources

Stars

11 stars

Watchers

13 watching

Forks

Latest commit

 

History

112 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CodecLz4

Stable Latest Build Status CodeCov

Provides transcoding codecs for compression and decompression with LZ4. Source: LZ4 The compression algorithm is similar to the compression available through Blosc.jl, but uses the LZ4 Frame format.

For non-streaming use, where the whole input is already in memory, consider ChunkCodecLibLz4 instead. It is designed for compressing and decompressing whole arrays in the LZ4 frame and block formats.

Non-streaming functions for single raw LZ4 blocks are also included here via lz4_compress, lz4_hc_compress, and lz4_decompress.

A raw LZ4 block is not the LZ4 frame format, so these functions cannot read or write .lz4 files or data from LZ4FrameCompressor, and vice versa.

Warning

Do not use LZ4FastCompressor, LZ4HCCompressor, or LZ4SafeDecompressor for new data. They write a block-stream format that is specific to CodecLz4 and depends on the byte order of the machine that wrote it, so no other LZ4 tool can read it. They are only kept to read existing data. Use LZ4FrameCompressor and LZ4FrameDecompressor instead.

Installation

Pkg.add("CodecLz4")

Usage

using CodecLz4

# Some text.
text = """
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean sollicitudin
mauris non nisi consectetur, a dapibus urna pretium. Vestibulum non posuere
erat. Donec luctus a turpis eget aliquet. Cras tristique iaculis ex, eu
malesuada sem interdum sed. Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae; Etiam volutpat, risus nec gravida ultricies,
erat ex bibendum ipsum, sed varius ipsum ipsum vitae dui.
"""

# Streaming API.
stream = LZ4FrameCompressorStream(IOBuffer(text))
for line in eachline(LZ4FrameDecompressorStream(stream))
println(line)
end
close(stream)

# Array API.
compressed = transcode(LZ4FrameCompressor, text)
@assert sizeof(compressed) < sizeof(text)
@assert transcode(LZ4FrameDecompressor, compressed) == Vector{UInt8}(text)

The API is heavily based off of CodecZLib, and uses TranscodingStreams.jl. See those for details.

About

Transcoding codecs for compression and decompression with LZ4

Resources

Stars

11 stars

Watchers

13 watching

Forks

Releases

Used by

Contributors

Languages