public final class SnappyFramedOutputStream extends OutputStream
OutputStream.| Modifier and Type | Field and 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 and Description |
|---|
SnappyFramedOutputStream(OutputStream out) |
SnappyFramedOutputStream(OutputStream out,
int blockSize,
double minCompressionRatio) |
| Modifier and Type | Method and Description |
|---|---|
protected int |
calculateCRC32C(byte[] data,
int offset,
int length)
Calculates a CRC32C checksum over the data.
|
void |
close() |
void |
flush() |
void |
write(byte[] input,
int offset,
int length) |
void |
write(int b) |
protected void |
writeBlock(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(OutputStream out)
Writes the implementation specific header or "marker bytes" to
out.
|
writepublic static final int MAX_BLOCK_SIZE
public static final int DEFAULT_BLOCK_SIZE
public static final double DEFAULT_MIN_COMPRESSION_RATIO
public SnappyFramedOutputStream(OutputStream out) throws IOException
IOExceptionpublic SnappyFramedOutputStream(OutputStream out, int blockSize, double minCompressionRatio) throws IOException
IOExceptionprotected void writeHeader(OutputStream out) throws IOException
out - The underlying OutputStream.IOExceptionprotected void writeBlock(OutputStream out, byte[] data, int offset, int length, boolean compressed, int crc32c) throws IOException
out - The OutputStream 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.IOExceptionpublic void write(int b)
throws IOException
write in class OutputStreamIOExceptionpublic void write(byte[] input,
int offset,
int length)
throws IOException
write in class OutputStreamIOExceptionpublic final void flush()
throws IOException
flush in interface Flushableflush in class OutputStreamIOExceptionpublic final void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOExceptionprotected int calculateCRC32C(byte[] data,
int offset,
int length)
This can be overridden to provider alternative implementations (such as returning 0 if checksums are not desired).
Copyright © 2011–2019. All rights reserved.