public class

SnappyOutputStream

extends OutputStream
java.lang.Object
   ↳ java.io.OutputStream
     ↳ org.iq80.snappy.SnappyOutputStream

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).

Summary

Public Constructors
SnappyOutputStream(OutputStream out)
Creates a Snappy output stream to write data to the specified underlying output stream.
Public Methods
void close()
void flush()
static SnappyOutputStream newChecksumFreeBenchmarkOutputStream(OutputStream out)
Creates a Snappy output stream with block checksums disabled.
void write(byte[] input, int offset, int length)
void write(int b)
[Expand]
Inherited Methods
From class java.io.OutputStream
From class java.lang.Object
From interface java.io.Closeable
From interface java.io.Flushable
From interface java.lang.AutoCloseable

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
Throws
IOException

Public Methods

public void close ()

Throws
IOException

public void flush ()

Throws
IOException

public static SnappyOutputStream newChecksumFreeBenchmarkOutputStream (OutputStream out)

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
Throws
IOException

public void write (byte[] input, int offset, int length)

Throws
IOException

public void write (int b)

Throws
IOException