public class SnappyOutputStream
extends java.io.OutputStream
The input data is blocked into 32kb size (in default), and each block is
compressed and then passed to the given OutputStream
.
SnappyCodec
(8 bytes)
SnappyOutputStream
cannot be
uncompressed by Snappy.uncompress(byte[])
since the output formats of
Snappy.compress(byte[])
and SnappyOutputStream
are different.
Use SnappyInputStream
for uncompress the data generated by
SnappyOutputStream
.Modifier and Type | Field and Description |
---|---|
private int |
blockSize |
private boolean |
closed |
(package private) static int |
DEFAULT_BLOCK_SIZE |
protected byte[] |
inputBuffer |
private BufferAllocator |
inputBufferAllocator |
private int |
inputCursor |
(package private) static int |
MIN_BLOCK_SIZE |
protected java.io.OutputStream |
out |
protected byte[] |
outputBuffer |
private BufferAllocator |
outputBufferAllocator |
private int |
outputCursor |
Constructor and Description |
---|
SnappyOutputStream(java.io.OutputStream out) |
SnappyOutputStream(java.io.OutputStream out,
int blockSize) |
SnappyOutputStream(java.io.OutputStream out,
int blockSize,
BufferAllocatorFactory bufferAllocatorFactory) |
Modifier and Type | Method and Description |
---|---|
void |
close()
close the stream
|
protected void |
compressInput() |
protected void |
dumpOutput() |
void |
flush() |
private boolean |
hasSufficientOutputBufferFor(int inputSize) |
void |
rawWrite(java.lang.Object array,
int byteOffset,
int byteLength)
Compress the raw byte array data.
|
(package private) static int |
readInt(byte[] buffer,
int pos) |
void |
write(byte[] b,
int byteOffset,
int byteLength) |
void |
write(double[] f)
Compress the input array data
|
void |
write(double[] f,
int off,
int len)
Compress the input double array data
|
void |
write(float[] f)
Compress the input array data
|
void |
write(float[] f,
int off,
int len)
Compress the input float array data
|
void |
write(int b)
Writes the specified byte to this output stream.
|
void |
write(int[] f)
Compress the input array data
|
void |
write(int[] f,
int off,
int len)
Compress the input int array data
|
void |
write(long[] d)
Compress the input array data
|
void |
write(long[] d,
int off,
int len)
Compress the input long array data
|
void |
write(short[] f)
Compress the input array data
|
void |
write(short[] f,
int off,
int len)
Compress the input short array data
|
(package private) static void |
writeInt(byte[] dst,
int offset,
int v) |
static final int MIN_BLOCK_SIZE
static final int DEFAULT_BLOCK_SIZE
protected final java.io.OutputStream out
private final int blockSize
private final BufferAllocator inputBufferAllocator
private final BufferAllocator outputBufferAllocator
protected byte[] inputBuffer
protected byte[] outputBuffer
private int inputCursor
private int outputCursor
private boolean closed
public SnappyOutputStream(java.io.OutputStream out)
public SnappyOutputStream(java.io.OutputStream out, int blockSize)
out
- blockSize
- byte size of the internal buffer sizejava.io.IOException
public SnappyOutputStream(java.io.OutputStream out, int blockSize, BufferAllocatorFactory bufferAllocatorFactory)
public void write(byte[] b, int byteOffset, int byteLength) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public void write(long[] d, int off, int len) throws java.io.IOException
d
- input arrayoff
- offset in the arraylen
- the number of elements in the array to copyjava.io.IOException
public void write(double[] f, int off, int len) throws java.io.IOException
f
- input arrayoff
- offset in the arraylen
- the number of elements in the array to copyjava.io.IOException
public void write(float[] f, int off, int len) throws java.io.IOException
f
- input arrayoff
- offset in the arraylen
- the number of elements in the array to copyjava.io.IOException
public void write(int[] f, int off, int len) throws java.io.IOException
f
- input arrayoff
- offset in the arraylen
- the number of elements in the array to copyjava.io.IOException
public void write(short[] f, int off, int len) throws java.io.IOException
f
- input arrayoff
- offset in the arraylen
- the number of elements in the array to copyjava.io.IOException
public void write(long[] d) throws java.io.IOException
d
- java.io.IOException
public void write(double[] f) throws java.io.IOException
f
- java.io.IOException
public void write(float[] f) throws java.io.IOException
f
- java.io.IOException
public void write(int[] f) throws java.io.IOException
f
- java.io.IOException
public void write(short[] f) throws java.io.IOException
f
- java.io.IOException
private boolean hasSufficientOutputBufferFor(int inputSize)
public void rawWrite(java.lang.Object array, int byteOffset, int byteLength) throws java.io.IOException
array
- array data of any type (e.g., byte[], float[], long[], ...)byteOffset
- byteLength
- java.io.IOException
public void write(int b) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.OutputStream
java.io.IOException
static void writeInt(byte[] dst, int offset, int v)
static int readInt(byte[] buffer, int pos)
protected void dumpOutput() throws java.io.IOException
java.io.IOException
protected void compressInput() throws java.io.IOException
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.OutputStream
java.io.IOException