Package org.iq80.snappy
Class SnappyOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.iq80.snappy.AbstractSnappyOutputStream
-
- org.iq80.snappy.SnappyOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
@Deprecated public class SnappyOutputStream extends AbstractSnappyOutputStream
Deprecated.UseSnappyFramedOutputStream
which implements the standardx-snappy-framed
specification.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).NOTE:This data produced by this class is not compatible with the
x-snappy-framed
specification. It can only be read bySnappyInputStream
.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
calculateChecksum
Deprecated.(package private) static int
MAX_BLOCK_SIZE
Deprecated.static double
MIN_COMPRESSION_RATIO
Deprecated.Write out the uncompressed content if the compression ratio (compressed length / raw length) exceeds this value.(package private) static byte[]
STREAM_HEADER
Deprecated.
-
Constructor Summary
Constructors Modifier Constructor Description SnappyOutputStream(java.io.OutputStream out)
Deprecated.Creates a Snappy output stream to write data to the specified underlying output stream.private
SnappyOutputStream(java.io.OutputStream out, boolean calculateChecksum)
Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected int
calculateCRC32C(byte[] data, int offset, int length)
Deprecated.Calculates a CRC32C checksum over the data.static SnappyOutputStream
newChecksumFreeBenchmarkOutputStream(java.io.OutputStream out)
Deprecated.Creates a Snappy output stream with block checksums disabled.protected void
writeBlock(java.io.OutputStream out, byte[] data, int offset, int length, boolean compressed, int crc32c)
Deprecated.Write a frame (block) to out.protected void
writeHeader(java.io.OutputStream out)
Deprecated.Writes the implementation specific header or "marker bytes" to out.-
Methods inherited from class org.iq80.snappy.AbstractSnappyOutputStream
close, flush, write, write
-
-
-
-
Field Detail
-
STREAM_HEADER
static final byte[] STREAM_HEADER
Deprecated.
-
MAX_BLOCK_SIZE
static final int MAX_BLOCK_SIZE
Deprecated.- See Also:
- Constant Field Values
-
MIN_COMPRESSION_RATIO
public static final double MIN_COMPRESSION_RATIO
Deprecated.Write out the uncompressed content if the compression ratio (compressed length / raw length) exceeds this value.- See Also:
- Constant Field Values
-
calculateChecksum
private final boolean calculateChecksum
Deprecated.
-
-
Constructor Detail
-
SnappyOutputStream
public SnappyOutputStream(java.io.OutputStream out) throws java.io.IOException
Deprecated.Creates a Snappy output stream to write data to the specified underlying output stream.- Parameters:
out
- the underlying output stream- Throws:
java.io.IOException
-
SnappyOutputStream
private SnappyOutputStream(java.io.OutputStream out, boolean calculateChecksum) throws java.io.IOException
Deprecated.- Throws:
java.io.IOException
-
-
Method Detail
-
newChecksumFreeBenchmarkOutputStream
public static SnappyOutputStream newChecksumFreeBenchmarkOutputStream(java.io.OutputStream out) throws java.io.IOException
Deprecated.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:
java.io.IOException
-
writeHeader
protected void writeHeader(java.io.OutputStream out) throws java.io.IOException
Deprecated.Description copied from class:AbstractSnappyOutputStream
Writes the implementation specific header or "marker bytes" to out.- Specified by:
writeHeader
in classAbstractSnappyOutputStream
- Parameters:
out
- The underlyingOutputStream
.- Throws:
java.io.IOException
-
calculateCRC32C
protected int calculateCRC32C(byte[] data, int offset, int length)
Deprecated.Description copied from class:AbstractSnappyOutputStream
Calculates a CRC32C checksum over the data.This can be overridden to provider alternative implementations (such as returning 0 if checksums are not desired).
- Overrides:
calculateCRC32C
in classAbstractSnappyOutputStream
- Returns:
- The CRC32 checksum.
-
writeBlock
protected void writeBlock(java.io.OutputStream out, byte[] data, int offset, int length, boolean compressed, int crc32c) throws java.io.IOException
Deprecated.Description copied from class:AbstractSnappyOutputStream
Write a frame (block) to out.- Specified by:
writeBlock
in classAbstractSnappyOutputStream
- Parameters:
out
- TheOutputStream
to write to.data
- The data to write.offset
- The offset in data to start at.length
- The length of data to use.compressed
- Indicates if data is the compressed or raw content. This is based on whether the compression ratio desired is reached.crc32c
- The calculated checksum.- Throws:
java.io.IOException
-
-