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.
|
Constructor and Description |
---|
SnappyFramedOutputStream(OutputStream out)
Creates a new
SnappyFramedOutputStream using the DEFAULT_BLOCK_SIZE
and DEFAULT_MIN_COMPRESSION_RATIO . |
SnappyFramedOutputStream(OutputStream out,
int blockSize,
double minCompressionRatio)
Creates a new
SnappyFramedOutputStream instance. |
SnappyFramedOutputStream(WritableByteChannel out)
Creates a new
SnappyFramedOutputStream using the
DEFAULT_BLOCK_SIZE and DEFAULT_MIN_COMPRESSION_RATIO . |
SnappyFramedOutputStream(WritableByteChannel out,
int blockSize,
double minCompressionRatio)
Creates a new
SnappyFramedOutputStream instance. |
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) |
write
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(OutputStream out) throws IOException
SnappyFramedOutputStream
using the DEFAULT_BLOCK_SIZE
and DEFAULT_MIN_COMPRESSION_RATIO
.out
- The underlying OutputStream
to write to. Must not be
null
.IOException
public SnappyFramedOutputStream(OutputStream out, int blockSize, double minCompressionRatio) 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].IOException
public SnappyFramedOutputStream(WritableByteChannel out) throws IOException
SnappyFramedOutputStream
using the
DEFAULT_BLOCK_SIZE
and DEFAULT_MIN_COMPRESSION_RATIO
.out
- The underlying WritableByteChannel
to write to. Must
not be null
.IOException
public 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].IOException
public void write(int b) throws IOException
write
in class OutputStream
IOException
public void write(byte[] input, int offset, int length) throws IOException
write
in class OutputStream
IOException
public int write(ByteBuffer src) throws IOException
write
in interface WritableByteChannel
IOException
public 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.IOException
public 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.IOException
public final void flush() throws IOException
flush
in interface Flushable
flush
in class OutputStream
IOException
public final void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in interface Channel
close
in class OutputStream
IOException
Copyright © 2011–2024 xerial.org. All rights reserved.