Package org.xerial.snappy
Class SnappyInputStream
java.lang.Object
java.io.InputStream
org.xerial.snappy.SnappyInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
A stream filter for reading data compressed by
SnappyOutputStream.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate byte[]private booleanprivate byte[]protected final InputStreamstatic final intprivate final intprivate byte[]private intprivate int -
Constructor Summary
ConstructorsConstructorDescriptionSnappyInputStream(InputStream input) Create a filter for reading compressed data as a uncompressed streamSnappyInputStream(InputStream input, int maxChunkSize) Create a filter for reading compressed data as a uncompressed stream with provided maximum chunk size -
Method Summary
Modifier and TypeMethodDescriptionintvoidclose()Close the streamprotected booleanprivate static booleanisValidHeader(byte[] header) intRead uncompressed data into the specified arrayintread()Reads the next byte of uncompressed data from the input stream.intread(byte[] b, int byteOffset, int byteLength) Reads up to len bytes of data from the input stream into an array of bytes.intread(double[] d) Read double array from the streamintread(double[] d, int off, int len) Read double array from the streamintread(float[] d) Read float array from the streamintread(float[] d, int off, int len) Read float array from the streamintread(int[] d) Read int array from the streamintread(int[] d, int off, int len) Read int array from the streamintread(long[] d) Read long array from the streamintread(long[] d, int off, int len) Read long array from the streamintread(short[] d) Read short array from the streamintread(short[] d, int off, int len) Read short array from the streamprotected voidreadFully(byte[] fragment, int fragmentLength) protected voidprivate intreadNext(byte[] dest, int offset, int len) Read next len bytesMethods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Field Details
-
MAX_CHUNK_SIZE
public static final int MAX_CHUNK_SIZE- See Also:
-
finishedReading
private boolean finishedReading -
in
-
maxChunkSize
private final int maxChunkSize -
compressed
private byte[] compressed -
uncompressed
private byte[] uncompressed -
uncompressedCursor
private int uncompressedCursor -
uncompressedLimit
private int uncompressedLimit -
header
private byte[] header
-
-
Constructor Details
-
SnappyInputStream
Create a filter for reading compressed data as a uncompressed stream- Parameters:
input-- Throws:
IOException
-
SnappyInputStream
Create a filter for reading compressed data as a uncompressed stream with provided maximum chunk size- Parameters:
input-maxChunkSize-- Throws:
IOException
-
-
Method Details
-
close
Close the stream- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
readHeader
- Throws:
IOException
-
isValidHeader
- Throws:
IOException
-
readFully
- Throws:
IOException
-
read
Reads up to len bytes of data from the input stream into an array of bytes.- Overrides:
readin classInputStream- Throws:
IOException
-
rawRead
Read uncompressed data into the specified array- Parameters:
array-byteOffset-byteLength-- Returns:
- written bytes
- Throws:
IOException
-
read
Read long array from the stream- Parameters:
d- inputoff- offsetlen- the number of long elements to read- Returns:
- the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
- Throws:
IOException
-
read
Read long array from the stream- Parameters:
d-- Returns:
- the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
- Throws:
IOException
-
read
Read double array from the stream- Parameters:
d- inputoff- offsetlen- the number of double elements to read- Returns:
- the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
- Throws:
IOException
-
read
Read double array from the stream- Parameters:
d-- Returns:
- the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
- Throws:
IOException
-
read
Read int array from the stream- Parameters:
d-- Returns:
- the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
- Throws:
IOException
-
read
Read int array from the stream- Parameters:
d- inputoff- offsetlen- the number of int elements to read- Returns:
- the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
- Throws:
IOException
-
read
Read float array from the stream- Parameters:
d- inputoff- offsetlen- the number of float elements to read- Returns:
- the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
- Throws:
IOException
-
read
Read float array from the stream- Parameters:
d-- Returns:
- the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
- Throws:
IOException
-
read
Read short array from the stream- Parameters:
d- inputoff- offsetlen- the number of short elements to read- Returns:
- the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
- Throws:
IOException
-
read
Read short array from the stream- Parameters:
d-- Returns:
- the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
- Throws:
IOException
-
readNext
Read next len bytes- Parameters:
dest-offset-len-- Returns:
- read bytes
- Throws:
IOException
-
hasNextChunk
- Throws:
IOException
-
read
Reads the next byte of uncompressed data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.- Specified by:
readin classInputStream- Throws:
IOException
-
available
- Overrides:
availablein classInputStream- Throws:
IOException
-