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 boolean
private byte[]
protected final InputStream
static final int
private final int
private byte[]
private int
private 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 TypeMethodDescriptionint
void
close()
Close the streamprotected boolean
private static boolean
isValidHeader
(byte[] header) int
Read uncompressed data into the specified arrayint
read()
Reads the next byte of uncompressed data from the input stream.int
read
(byte[] b, int byteOffset, int byteLength) Reads up to len bytes of data from the input stream into an array of bytes.int
read
(double[] d) Read double array from the streamint
read
(double[] d, int off, int len) Read double array from the streamint
read
(float[] d) Read float array from the streamint
read
(float[] d, int off, int len) Read float array from the streamint
read
(int[] d) Read int array from the streamint
read
(int[] d, int off, int len) Read int array from the streamint
read
(long[] d) Read long array from the streamint
read
(long[] d, int off, int len) Read long array from the streamint
read
(short[] d) Read short array from the streamint
read
(short[] d, int off, int len) Read short array from the streamprotected void
readFully
(byte[] fragment, int fragmentLength) protected void
private int
readNext
(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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in 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:
read
in 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:
read
in classInputStream
- Throws:
IOException
-
available
- Overrides:
available
in classInputStream
- Throws:
IOException
-