ddn.compressor.lzo
ddn.compressor.lzo
LZO compression provider for ddn.api.compressor.
This module provides a basic LZO compression and decompression implementation using a simplified LZO1X-style format. It includes:
- Streaming
CompressorandDecompressorclasses implementing theddn.api.compressorinterface. - Hash-based match finding with configurable compression levels (0-9).
- Simple block format with headers and checksums.
- Efficient compression suitable for in-memory data.
LZO (Lempel-Ziv-Oberhumer) is a lossless data compression algorithm that is focused on decompression speed. It is widely used in applications where fast decompression is critical.
Important: This implementation uses a simplified format that is NOT compatible with the lzop command-line tool or standard LZO file format. It is designed for use within the ddn.compressor API for internal data compression where interoperability with external tools is not required.
Compression levels control the trade-off between speed and compression ratio:
- Level 0: Store-only mode (no compression, fastest).
- Levels 1-3: Fast compression with smaller hash tables.
- Levels 4-6: Default compression with medium hash tables.
- Levels 7-9: Better compression with larger hash tables.
The default compression level is 3, providing a good balance between compression ratio and speed.
Copyright
Module Initializers 1
()Types 2
LZO compressor that implements ddn.api.compressor.Compressor.
This class provides streaming compression using the LZO1X algorithm. Internally it uses a pre-allocated malloc'd hash table and a buffer-offset tracking scheme to avoid unnecessary copies on block boundaries.
void setOutputSink(OutputSink sink)Set the output sink delegate that will receive compressed chunks.void setProgressCallback(ProgressCallback callback)Set an optional progress callback.void write(const(ubyte)[] data)Feed more uncompressed data.void finish()Finalize the stream. No further writes are allowed.void reset()Reset the compression stream to initial state.bool setDictionary(const(ubyte)[] dict)Set dictionary (not supported for LZO).bool isFinished() @property constReturns true if finish() has been called and the stream is closed for further writes.this(CompressionOptions opts)Create a compressor with provided options.~thisDestructor – frees the `malloc`'d hash table, output buffer, and block buffer.LZO decompressor that implements ddn.api.compressor.Decompressor.
void setOutputSink(OutputSink sink)Set the output sink delegate for decompressed data.void setProgressCallback(ProgressCallback callback)Set an optional progress callback.void write(const(ubyte)[] data)Feed more compressed data.void finish()Finish the stream.void reset()Reset the decompression stream.bool setDictionary(const(ubyte)[] dict)Set dictionary (not supported for LZO).bool isFinished() @property constReturns true if finish() has been called and the stream is closed for further writes.this(DecompressionOptions opts)Create a decompressor with provided options.~thisDestructor – frees the `malloc`'d decompression buffer.Functions 2
Compressor makeLzoCompressor(CompressionOptions opts)Factory function that constructs an `LzoCompressor`.Decompressor makeLzoDecompressor(DecompressionOptions opts)Factory function that constructs an `LzoDecompressor`.