public final class SnappyFramedOutputStream
extends java.io.OutputStream
implements java.nio.channels.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.
|
| Constructor and Description |
|---|
SnappyFramedOutputStream(java.io.OutputStream out)
Creates a new
SnappyFramedOutputStream using the DEFAULT_BLOCK_SIZE
and DEFAULT_MIN_COMPRESSION_RATIO. |
SnappyFramedOutputStream(java.io.OutputStream out,
BufferPool bufferPool)
Creates a new
SnappyFramedOutputStream using the DEFAULT_BLOCK_SIZE
and DEFAULT_MIN_COMPRESSION_RATIO. |
SnappyFramedOutputStream(java.io.OutputStream out,
int blockSize,
double minCompressionRatio)
Creates a new
SnappyFramedOutputStream instance. |
SnappyFramedOutputStream(java.io.OutputStream out,
int blockSize,
double minCompressionRatio,
BufferPool bufferPool)
Creates a new
SnappyFramedOutputStream instance. |
SnappyFramedOutputStream(java.nio.channels.WritableByteChannel out)
Creates a new
SnappyFramedOutputStream using the
DEFAULT_BLOCK_SIZE and DEFAULT_MIN_COMPRESSION_RATIO. |
SnappyFramedOutputStream(java.nio.channels.WritableByteChannel out,
BufferPool bufferPool)
Creates a new
SnappyFramedOutputStream using the
DEFAULT_BLOCK_SIZE and DEFAULT_MIN_COMPRESSION_RATIO. |
SnappyFramedOutputStream(java.nio.channels.WritableByteChannel out,
int blockSize,
double minCompressionRatio)
Creates a new
SnappyFramedOutputStream instance. |
SnappyFramedOutputStream(java.nio.channels.WritableByteChannel out,
int blockSize,
double minCompressionRatio,
BufferPool bufferPool)
Creates a new
SnappyFramedOutputStream instance. |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
flush() |
boolean |
isOpen() |
long |
transferFrom(java.io.InputStream is)
Transfers all the content from is to this
OutputStream. |
long |
transferFrom(java.nio.channels.ReadableByteChannel rbc)
Transfers all the content from rbc to this
WritableByteChannel. |
void |
write(byte[] input,
int offset,
int length) |
int |
write(java.nio.ByteBuffer src) |
void |
write(int b) |
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.
public static final int DEFAULT_BLOCK_SIZE
public static final double DEFAULT_MIN_COMPRESSION_RATIO
public SnappyFramedOutputStream(java.io.OutputStream out)
throws java.io.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.java.io.IOExceptionpublic SnappyFramedOutputStream(java.io.OutputStream out,
BufferPool bufferPool)
throws java.io.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.java.io.IOExceptionpublic SnappyFramedOutputStream(java.io.OutputStream out,
int blockSize,
double minCompressionRatio)
throws java.io.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].java.io.IOExceptionpublic SnappyFramedOutputStream(java.io.OutputStream out,
int blockSize,
double minCompressionRatio,
BufferPool bufferPool)
throws java.io.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.java.io.IOExceptionpublic SnappyFramedOutputStream(java.nio.channels.WritableByteChannel out)
throws java.io.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.java.io.IOExceptionpublic SnappyFramedOutputStream(java.nio.channels.WritableByteChannel out,
BufferPool bufferPool)
throws java.io.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.java.io.IOExceptionpublic SnappyFramedOutputStream(java.nio.channels.WritableByteChannel out,
int blockSize,
double minCompressionRatio)
throws java.io.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].java.io.IOExceptionpublic SnappyFramedOutputStream(java.nio.channels.WritableByteChannel out,
int blockSize,
double minCompressionRatio,
BufferPool bufferPool)
throws java.io.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.java.io.IOExceptionpublic boolean isOpen()
isOpen in interface java.nio.channels.Channelpublic void write(int b)
throws java.io.IOException
write in class java.io.OutputStreamjava.io.IOExceptionpublic void write(byte[] input,
int offset,
int length)
throws java.io.IOException
write in class java.io.OutputStreamjava.io.IOExceptionpublic int write(java.nio.ByteBuffer src)
throws java.io.IOException
write in interface java.nio.channels.WritableByteChanneljava.io.IOExceptionpublic long transferFrom(java.io.InputStream is)
throws java.io.IOException
OutputStream.
This potentially limits the amount of buffering required to compress
content.is - The source of data to compress.java.io.IOExceptionpublic long transferFrom(java.nio.channels.ReadableByteChannel rbc)
throws java.io.IOException
WritableByteChannel. This potentially limits the amount of
buffering required to compress content.rbc - The source of data to compress.java.io.IOExceptionpublic final void flush()
throws java.io.IOException
flush in interface java.io.Flushableflush in class java.io.OutputStreamjava.io.IOExceptionpublic final void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface java.nio.channels.Channelclose in class java.io.OutputStreamjava.io.IOException