ddn.compressor.snappy
ddn.compressor.snappy
Snappy compression provider for ddn.api.compressor.
This module provides a complete Snappy compression and decompression implementation conforming to the Snappy raw format specification. It includes:
- Streaming
CompressorandDecompressorclasses implementing theddn.api.compressorinterface. - Hash-based match finding for LZ77-style compression.
- Full support for all Snappy element types (literals, 1/2/4-byte copies).
- Interoperability with the standard Snappy library format.
Snappy is designed for speed rather than maximum compression ratio. It achieves reasonable compression at very high speeds, making it suitable for real-time applications, database storage, and RPC systems.
Format specification: https://github.com/google/snappy/blob/main/format_description.txt
Copyright
Module Initializers 1
()Types 2
Snappy compressor implementing the Compressor interface.
Buffers all input until finish() is called, then compresses and emits the complete Snappy stream.
void setOutputSink(OutputSink sink)Set the output sink for compressed data.void setProgressCallback(ProgressCallback callback)Set an optional progress callback.void write(const(ubyte)[] data)Write data to be compressed.void finish()Finish compression and emit all output.void reset()Reset the compressor for reuse.bool setDictionary(const(ubyte)[] dict)Set a compression dictionary (not supported by Snappy).bool isFinished() @property constReturns true if finish() has been called and the stream is closed for further writes.this(CompressionOptions opts)Construct a new Snappy compressor.Snappy decompressor implementing the Decompressor interface.
Buffers all input until finish() is called, then decompresses and emits the complete uncompressed data.
void setOutputSink(OutputSink sink)Set the output sink for decompressed data.void setProgressCallback(ProgressCallback callback)Set an optional progress callback.void write(const(ubyte)[] data)Write compressed data to be decompressed.void finish()Finish decompression and emit all output.void reset()Reset the decompressor for reuse.bool setDictionary(const(ubyte)[] dict)Set a decompression dictionary (not supported by Snappy).bool isFinished() @property constReturns true if finish() has been called and the stream is closed for further writes.this(DecompressionOptions opts)Construct a new Snappy decompressor.