public final class SnappyFramedOutputStream extends OutputStream implements WritableByteChannel
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_BLOCK_SIZE
The default block size to use.
|
static double |
DEFAULT_MIN_COMPRESSION_RATIO
The default min compression ratio to use.
|
static int |
MAX_BLOCK_SIZE
The x-snappy-framed specification allows for a chunk size up to
16,777,211 bytes in length.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
flush() |
boolean |
isOpen() |
long |
transferFrom(InputStream is)
Transfers all the content from is to this
OutputStream. |
long |
transferFrom(ReadableByteChannel rbc)
Transfers all the content from rbc to this
WritableByteChannel. |
void |
write(byte[] input,
int offset,
int length) |
int |
write(ByteBuffer src) |
void |
write(int b) |
writepublic 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.
public static final int DEFAULT_BLOCK_SIZE
public static final double DEFAULT_MIN_COMPRESSION_RATIO
public SnappyFramedOutputStream(OutputStream out) throws IOException
SnappyFramedOutputStream using the DEFAULT_BLOCK_SIZE
and DEFAULT_MIN_COMPRESSION_RATIO.
Uses DefaultPoolFactory to obtain BufferPool for buffers.
out - The underlying OutputStream to write to. Must not be
null.IOExceptionpublic SnappyFramedOutputStream(OutputStream out, BufferPool bufferPool) throws IOException
SnappyFramedOutputStream using the DEFAULT_BLOCK_SIZE
and DEFAULT_MIN_COMPRESSION_RATIO.out - The underlying OutputStream to write to. Must not be
null.bufferPool - Used to obtain buffer instances. Must not be null.IOExceptionpublic SnappyFramedOutputStream(OutputStream out, int blockSize, double minCompressionRatio) throws IOException
SnappyFramedOutputStream instance.
Uses DefaultPoolFactory to obtain BufferPool for buffers.
out - The underlying OutputStream to write to. Must not be
null.blockSize - The block size (of raw data) to compress before writing frames
to out. Must be in (0, 65536].minCompressionRatio - Defines the minimum compression ratio (
compressedLength / rawLength) that must be achieved to
write the compressed data. This must be in (0, 1.0].IOExceptionpublic SnappyFramedOutputStream(OutputStream out, int blockSize, double minCompressionRatio, BufferPool bufferPool) throws IOException
SnappyFramedOutputStream instance.out - The underlying OutputStream to write to. Must not be
null.blockSize - The block size (of raw data) to compress before writing frames
to out. Must be in (0, 65536].minCompressionRatio - Defines the minimum compression ratio (
compressedLength / rawLength) that must be achieved to
write the compressed data. This must be in (0, 1.0].bufferPool - Used to obtain buffer instances. Must not be null.IOExceptionpublic SnappyFramedOutputStream(WritableByteChannel out) throws IOException
SnappyFramedOutputStream using the
DEFAULT_BLOCK_SIZE and DEFAULT_MIN_COMPRESSION_RATIO.
Uses DefaultPoolFactory to obtain BufferPool for buffers.
out - The underlying WritableByteChannel to write to. Must
not be null.IOExceptionpublic SnappyFramedOutputStream(WritableByteChannel out, BufferPool bufferPool) throws IOException
SnappyFramedOutputStream using the
DEFAULT_BLOCK_SIZE and DEFAULT_MIN_COMPRESSION_RATIO.
Uses DefaultPoolFactory to obtain BufferPool for buffers.
out - The underlying WritableByteChannel to write to. Must
not be null.bufferPool - Used to obtain buffer instances. Must not be null.IOExceptionpublic SnappyFramedOutputStream(WritableByteChannel out, int blockSize, double minCompressionRatio) throws IOException
SnappyFramedOutputStream instance.out - The underlying WritableByteChannel to write to. Must
not be null.blockSize - The block size (of raw data) to compress before writing frames
to out. Must be in (0, 65536].minCompressionRatio - Defines the minimum compression ratio (
compressedLength / rawLength) that must be achieved to
write the compressed data. This must be in (0, 1.0].IOExceptionpublic SnappyFramedOutputStream(WritableByteChannel out, int blockSize, double minCompressionRatio, BufferPool bufferPool) throws IOException
SnappyFramedOutputStream instance.out - The underlying WritableByteChannel to write to. Must
not be null.blockSize - The block size (of raw data) to compress before writing frames
to out. Must be in (0, 65536].minCompressionRatio - Defines the minimum compression ratio (
compressedLength / rawLength) that must be achieved to
write the compressed data. This must be in (0, 1.0].bufferPool - Used to obtain buffer instances. Must not be null.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 int write(ByteBuffer src) throws IOException
write in interface WritableByteChannelIOExceptionpublic long transferFrom(InputStream is) throws IOException
OutputStream.
This potentially limits the amount of buffering required to compress
content.is - The source of data to compress.IOExceptionpublic long transferFrom(ReadableByteChannel rbc) throws IOException
WritableByteChannel. This potentially limits the amount of
buffering required to compress content.rbc - The source of data to compress.IOExceptionpublic 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 interface Channelclose in class OutputStreamIOExceptionCopyright © 2025 xerial.org. All rights reserved.