Package org.iq80.snappy
Class SnappyFramedOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.iq80.snappy.AbstractSnappyOutputStream
-
- org.iq80.snappy.SnappyFramedOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public final class SnappyFramedOutputStream extends AbstractSnappyOutputStream
Implements the x-snappy-framed as anOutputStream
.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_BLOCK_SIZE
static double
DEFAULT_MIN_COMPRESSION_RATIO
static int
MAX_BLOCK_SIZE
We place an additional restriction that the uncompressed data in a chunk must be no longer than 65536 bytes.
-
Constructor Summary
Constructors Constructor Description SnappyFramedOutputStream(java.io.OutputStream out)
SnappyFramedOutputStream(java.io.OutputStream out, int blockSize, double minCompressionRatio)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
writeBlock(java.io.OutputStream out, byte[] data, int offset, int length, boolean compressed, int crc32c)
Each chunk consists first a single byte of chunk identifier, then a three-byte little-endian length of the chunk in bytes (from 0 to 16777215, inclusive), and then the data if any.protected void
writeHeader(java.io.OutputStream out)
Writes the implementation specific header or "marker bytes" to out.-
Methods inherited from class org.iq80.snappy.AbstractSnappyOutputStream
calculateCRC32C, close, flush, write, write
-
-
-
-
Field Detail
-
MAX_BLOCK_SIZE
public static final int MAX_BLOCK_SIZE
We place an additional restriction that the uncompressed data in a chunk must be no longer than 65536 bytes. This allows consumers to easily use small fixed-size buffers.- See Also:
- Constant Field Values
-
DEFAULT_BLOCK_SIZE
public static final int DEFAULT_BLOCK_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_MIN_COMPRESSION_RATIO
public static final double DEFAULT_MIN_COMPRESSION_RATIO
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SnappyFramedOutputStream
public SnappyFramedOutputStream(java.io.OutputStream out) throws java.io.IOException
- Throws:
java.io.IOException
-
SnappyFramedOutputStream
public SnappyFramedOutputStream(java.io.OutputStream out, int blockSize, double minCompressionRatio) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
writeHeader
protected void writeHeader(java.io.OutputStream out) throws java.io.IOException
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
-
writeBlock
protected void writeBlock(java.io.OutputStream out, byte[] data, int offset, int length, boolean compressed, int crc32c) throws java.io.IOException
Each chunk consists first a single byte of chunk identifier, then a three-byte little-endian length of the chunk in bytes (from 0 to 16777215, inclusive), and then the data if any. The four bytes of chunk header is not counted in the data length.- 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
-
-