Package org.iq80.snappy
Class SnappyFramedOutputStream
java.lang.Object
java.io.OutputStream
org.iq80.snappy.AbstractSnappyOutputStream
org.iq80.snappy.SnappyFramedOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
Implements the x-snappy-framed as an
OutputStream.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final doublestatic final intWe place an additional restriction that the uncompressed data in a chunk must be no longer than 65536 bytes. -
Constructor Summary
ConstructorsConstructorDescriptionSnappyFramedOutputStream(OutputStream out, int blockSize, double minCompressionRatio) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidwriteBlock(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 voidwriteHeader(OutputStream out) Writes the implementation specific header or "marker bytes" to out.Methods inherited from class org.iq80.snappy.AbstractSnappyOutputStream
calculateCRC32C, close, flush, write, writeMethods inherited from class java.io.OutputStream
nullOutputStream, write
-
Field Details
-
MAX_BLOCK_SIZE
public static final int MAX_BLOCK_SIZEWe 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:
-
DEFAULT_BLOCK_SIZE
public static final int DEFAULT_BLOCK_SIZE- See Also:
-
DEFAULT_MIN_COMPRESSION_RATIO
public static final double DEFAULT_MIN_COMPRESSION_RATIO- See Also:
-
-
Constructor Details
-
SnappyFramedOutputStream
- Throws:
IOException
-
SnappyFramedOutputStream
public SnappyFramedOutputStream(OutputStream out, int blockSize, double minCompressionRatio) throws IOException - Throws:
IOException
-
-
Method Details
-
writeHeader
Description copied from class:AbstractSnappyOutputStreamWrites the implementation specific header or "marker bytes" to out.- Specified by:
writeHeaderin classAbstractSnappyOutputStream- Parameters:
out- The underlyingOutputStream.- Throws:
IOException
-
writeBlock
protected void writeBlock(OutputStream out, byte[] data, int offset, int length, boolean compressed, int crc32c) throws 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:
writeBlockin classAbstractSnappyOutputStream- Parameters:
out- TheOutputStreamto 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:
IOException
-