Class Overview
This class implements an output stream for writing Snappy compressed data.
The output format is the stream header "snappy\0" followed by one or more
compressed blocks of data, each of which is preceded by a seven byte header.
The first byte of the header is a flag indicating if the block is compressed
or not. A value of 0x00 means uncompressed, and 0x01 means compressed.
The second and third bytes are the size of the block in the stream as a big
endian number. This value is never zero as empty blocks are never written.
The maximum allowed length is 32k (1 << 15).
The remaining four byes are crc32c checksum of the user input data masked
with the following function:
((crc >>> 15) | (crc << 17)) + 0xa282ead8
An uncompressed block is simply copied from the input, thus guaranteeing
that the output is never larger than the input (not including the header).
Public Constructors
public
SnappyOutputStream
(OutputStream out)
Creates a Snappy output stream to write data to the specified underlying output stream.
Parameters
| out
| the underlying output stream
|
Public Methods
Creates a Snappy output stream with block checksums disabled. This is only useful for
apples-to-apples benchmarks with other compressors that do not perform block checksums.
Parameters
| out
| the underlying output stream
|
public
void
write
(byte[] input, int offset, int length)
public
void
write
(int b)