abstract class AbstractSnappyInputStream
extends java.io.InputStream
Modifier and Type | Class and Description |
---|---|
(package private) static class |
AbstractSnappyInputStream.FrameAction |
static class |
AbstractSnappyInputStream.FrameData |
static class |
AbstractSnappyInputStream.FrameMetaData |
Modifier and Type | Field and Description |
---|---|
private byte[] |
buffer
Buffer is a reference to the real buffer of uncompressed data for the
current block: uncompressed if the block is compressed, or input if it is
not.
|
private boolean |
closed
Indicates if this instance has been closed.
|
private boolean |
eof
Indicates if we have reached the EOF on
in . |
private byte[] |
frameHeader |
private java.io.InputStream |
in |
private byte[] |
input
A single frame read from the underlying
InputStream . |
private int |
position
The next position to read from
buffer . |
private BufferRecycler |
recycler |
private byte[] |
uncompressed
The decompressed data from
input . |
private int |
valid
The position in
input to read to. |
private boolean |
verifyChecksums |
Constructor and Description |
---|
AbstractSnappyInputStream(java.io.InputStream in,
int maxBlockSize,
int frameHeaderSize,
boolean verifyChecksums,
byte[] expectedHeader)
Creates a Snappy input stream to read data from the specified underlying
input stream.
|
Modifier and Type | Method and Description |
---|---|
private void |
allocateBuffersBasedOnSize(int size) |
int |
available() |
void |
close() |
private boolean |
ensureBuffer() |
protected abstract AbstractSnappyInputStream.FrameData |
getFrameData(byte[] frameHeader,
byte[] content,
int length)
Take the frame header and the content of the frame to describe metadata
about the content.
|
protected abstract AbstractSnappyInputStream.FrameMetaData |
getFrameMetaData(byte[] frameHeader)
Use the content of the frameHeader to describe what type of frame we have
and the action to take.
|
int |
read() |
int |
read(byte[] output,
int offset,
int length) |
private boolean |
readBlockHeader() |
private final java.io.InputStream in
private final byte[] frameHeader
private final boolean verifyChecksums
private final BufferRecycler recycler
private byte[] input
InputStream
.private byte[] uncompressed
input
.private boolean closed
private boolean eof
in
.private int valid
input
to read to.private int position
buffer
.private byte[] buffer
public AbstractSnappyInputStream(java.io.InputStream in, int maxBlockSize, int frameHeaderSize, boolean verifyChecksums, byte[] expectedHeader) throws java.io.IOException
in
- the underlying input streamverifyChecksums
- if true, checksums in input stream will be verifiedexpectedHeader
- the expected stream headerjava.io.IOException
private void allocateBuffersBasedOnSize(int size)
public int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public int read(byte[] output, int offset, int length) throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public int available() throws java.io.IOException
available
in class java.io.InputStream
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.InputStream
java.io.IOException
private boolean ensureBuffer() throws java.io.IOException
java.io.IOException
protected abstract AbstractSnappyInputStream.FrameMetaData getFrameMetaData(byte[] frameHeader) throws java.io.IOException
java.io.IOException
protected abstract AbstractSnappyInputStream.FrameData getFrameData(byte[] frameHeader, byte[] content, int length)
frameHeader
- The frame header.content
- The content of the of the frame. Content begins at index 0
.length
- The length of the content.private boolean readBlockHeader() throws java.io.IOException
java.io.IOException