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 Compressor and Decompressor classes implementing the ddn.api.compressor interface.
  • 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

Module Initializers 1

shared static this()

Types 2

Snappy compressor implementing the Compressor interface.

Buffers all input until finish() is called, then compresses and emits the complete Snappy stream.

Methods
CompressionOptions options() @property constReturns the compression options.
void setOutputSink(OutputSink sink)Set the output sink for compressed data.
void setProgressCallback(ProgressCallback callback)Set an optional progress callback.
ulong bytesInTotal() @property constReturns total bytes written to the compressor.
ulong bytesOutTotal() @property constReturns total bytes emitted by the compressor.
void write(const(ubyte)[] data)Write data to be compressed.
void flush(FlushMode mode = FlushMode.SYNC)Flush pending data.
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.
Constructors
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.

Methods
DecompressionOptions options() @property constReturns the decompression options.
void setOutputSink(OutputSink sink)Set the output sink for decompressed data.
void setProgressCallback(ProgressCallback callback)Set an optional progress callback.
ulong bytesInTotal() @property constReturns total bytes written to the decompressor.
ulong bytesOutTotal() @property constReturns total bytes emitted by the decompressor.
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.
Constructors
this(DecompressionOptions opts)Construct a new Snappy decompressor.

Functions 2

fnCompressor makeSnappyCompressor(CompressionOptions opts)Create a Snappy compressor.
fnDecompressor makeSnappyDecompressor(DecompressionOptions opts)Create a Snappy decompressor.