public class SnappyOutputStream extends 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 |
|---|---|
static int |
DEFAULT_BLOCK_SIZE |
protected byte[] |
inputBuffer |
static int |
MAX_BLOCK_SIZE |
static int |
MIN_BLOCK_SIZE |
protected OutputStream |
out |
protected byte[] |
outputBuffer |
| Constructor and Description |
|---|
SnappyOutputStream(OutputStream out) |
SnappyOutputStream(OutputStream out,
int blockSize) |
SnappyOutputStream(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() |
void |
rawWrite(Object array,
int byteOffset,
int byteLength)
Compress the raw byte array data.
|
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
|
protected void |
writeBlockPreemble()
Optionally write a preemble before a block.
|
protected void |
writeCurrentDataSize() |
protected int |
writeHeader() |
writepublic static final int MAX_BLOCK_SIZE
public static final int MIN_BLOCK_SIZE
public static final int DEFAULT_BLOCK_SIZE
protected final OutputStream out
protected byte[] inputBuffer
protected byte[] outputBuffer
public SnappyOutputStream(OutputStream out)
public SnappyOutputStream(OutputStream out, int blockSize)
out - blockSize - byte size of the internal buffer sizeIllegalArgumentException - when blockSize is larger than 512 MiBpublic SnappyOutputStream(OutputStream out, int blockSize, BufferAllocatorFactory bufferAllocatorFactory)
public void write(byte[] b,
int byteOffset,
int byteLength)
throws IOException
write in class OutputStreamIOExceptionpublic void write(long[] d,
int off,
int len)
throws IOException
d - input arrayoff - offset in the arraylen - the number of elements in the array to copyIOExceptionpublic void write(double[] f,
int off,
int len)
throws IOException
f - input arrayoff - offset in the arraylen - the number of elements in the array to copyIOExceptionpublic void write(float[] f,
int off,
int len)
throws IOException
f - input arrayoff - offset in the arraylen - the number of elements in the array to copyIOExceptionpublic void write(int[] f,
int off,
int len)
throws IOException
f - input arrayoff - offset in the arraylen - the number of elements in the array to copyIOExceptionpublic void write(short[] f,
int off,
int len)
throws IOException
f - input arrayoff - offset in the arraylen - the number of elements in the array to copyIOExceptionpublic void write(long[] d)
throws IOException
d - IOExceptionpublic void write(double[] f)
throws IOException
f - IOExceptionpublic void write(float[] f)
throws IOException
f - IOExceptionpublic void write(int[] f)
throws IOException
f - IOExceptionpublic void write(short[] f)
throws IOException
f - IOExceptionpublic void rawWrite(Object array, int byteOffset, int byteLength) throws IOException
array - array data of any type (e.g., byte[], float[], long[], ...)byteOffset - byteLength - IOExceptionpublic void write(int b)
throws IOException
write in class OutputStreamIOExceptionpublic void flush()
throws IOException
flush in interface Flushableflush in class OutputStreamIOExceptionprotected void dumpOutput()
throws IOException
IOExceptionprotected void compressInput()
throws IOException
IOExceptionprotected int writeHeader()
protected void writeBlockPreemble()
writeCurrentDataSize().protected void writeCurrentDataSize()
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOExceptionCopyright © 2025 xerial.org. All rights reserved.