An implementation of the streaming LZO compression and decompression format used in the LZOP command line utility as a Codec for TranscodingStreams.jl.
Pkg.add("CodecLZOP")
using CodecLZOP
# 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 = LZOPCompressorStream(IOBuffer(text))
for line in eachline(LZOPDecompressorStream(stream))
println(line)
end
close(stream)
# Array API.
compressed = transcode(LZOPCompressor, text)
@assert sizeof(compressed) < sizeof(text)
@assert transcode(LZOPDecompressor, compressed) == Vector{UInt8}(text)
This package exports following codecs and streams:
Codec | Stream |
---|---|
LZOPCompressor |
LZOPCompressorStream |
LZOPDecompressor |
LZOPDecompressorStream |
See docstrings and TranscodingStreams.jl for details.
LZO (Lempel-Ziv-Oberhumer) is a variant of the LZ77 compression algorithm. The implementation of LZO in liblzo2 can only compress and decompress entire blocks of data in memory and all at once. LZOP is a command-line utility that implements streaming compression and decompression capabilities using LZO by:
- Splitting input data into independent blocks; and
- Adds information at the beginning of each block that encodes compressed size, uncompressed size, and checksum information.
This codec implements streaming compression and decompression of data by implementing the method of LZOP. Note that LZOP archives (the files produced by the LZOP command-line utility) are concatenated collections of files compressed using the LZOP method, but these archives contain additional header information for each file and therefore CodecLZOP
will not directly encode or decode these files. For a Julia utility that reads and writes LZOP archives, see the documentation for LZOPStreams.jl.