This implementation uses an internal buffer in order to handle the back-references that are at the heart of the LZ77 algorithm. The size of the buffer must be at least as big as the biggest offset used in the compressed stream. The current version of the Snappy algorithm as defined by Google works on 32k blocks and doesn't contain offsets bigger than 32k which is the default block size used by this class.
| Modifier and Type | Class and Description |
|---|---|
| private static enum |
| Modifier and Type | Field and Description |
|---|---|
| public static final int | DEFAULT_BLOCK_SIZE
Default block size |
| private boolean | |
| private final int | size
Hides org. |
| private SnappyCompressorInputStream. | state
Current state of the stream |
| private static final int | TAG_MASK
Mask used to determine the type of "tag" is being processed |
| private int | uncompressedBytesRemaining
Number of uncompressed bytes still to be read. |
| Access | Constructor and Description |
|---|---|
| public | SnappyCompressorInputStream(final InputStream
An InputStream to read compressed data from is)Constructor using the default buffer size of 32k. |
| public | SnappyCompressorInputStream(final InputStream
An InputStream to read compressed data from is, final int The block size used in compression blockSize)Constructor using a configurable buffer size. |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| public int | Returns: the uncompressed sizeOverrides org. |
| public int | read(final byte[]
the buffer into which the data is read. b, final int the start offset in array off, final int b
at which the data is written.the maximum number of bytes to read. len)Overrides java. len bytes of data from the input stream into
an array of bytes.
|
| private int | |
| private long | Returns: The size of the uncompressed dataThe stream starts with the uncompressed length (up to a maximum of 2^32 - 1), stored as a little-endian varint. |
| DEFAULT_BLOCK_SIZE | back to summary |
|---|---|
| public static final int DEFAULT_BLOCK_SIZE Default block size | |
| endReached | back to summary |
|---|---|
| private boolean endReached | |
| size | back to summary |
|---|---|
| private final int size Hides org. The size of the uncompressed data | |
| state | back to summary |
|---|---|
| private SnappyCompressorInputStream. Current state of the stream | |
| TAG_MASK | back to summary |
|---|---|
| private static final int TAG_MASK Mask used to determine the type of "tag" is being processed | |
| uncompressedBytesRemaining | back to summary |
|---|---|
| private int uncompressedBytesRemaining Number of uncompressed bytes still to be read. | |
| SnappyCompressorInputStream | back to summary |
|---|---|
| public SnappyCompressorInputStream(final InputStream is) throws IOException Constructor using the default buffer size of 32k.
| |
| SnappyCompressorInputStream | back to summary |
|---|---|
| public SnappyCompressorInputStream(final InputStream is, final int blockSize) throws IOException Constructor using a configurable buffer size.
| |
| fill | back to summary |
|---|---|
| private void fill() throws IOException Try to fill the buffer with the next block of data. | |
| getSize | back to summary |
|---|---|
| public int getSize() Overrides org. Gets the uncompressed size of the stream
| |
| read | back to summary |
|---|---|
| public int read(final byte[] b, final int off, final int len) throws IOException Overrides java. Doc from java. Reads up to This method blocks until input data is available, end of file is detected, or an exception is thrown. If The first byte read is stored into element In every case, elements
| |
| readLiteralLength | back to summary |
|---|---|
| private int readLiteralLength(final int b) throws IOException | |
| readSize | back to summary |
|---|---|
| private long readSize() throws IOException The stream starts with the uncompressed length (up to a maximum of 2^32 - 1), stored as a little-endian varint. Varints consist of a series of bytes, where the lower 7 bits are data and the upper bit is set iff there are more bytes to be read. In other words, an uncompressed length of 64 would be stored as 0x40, and an uncompressed length of 2097150 (0x1FFFFE) would be stored as 0xFE 0xFF 0x7F.
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final SnappyCompressorInputStream. | |
| public static final SnappyCompressorInputStream. | |
| public static final SnappyCompressorInputStream. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static SnappyCompressorInputStream. | |
| public static SnappyCompressorInputStream. |
| IN_BACK_REFERENCE | back to summary |
|---|---|
| public static final SnappyCompressorInputStream. | |
| IN_LITERAL | back to summary |
|---|---|
| public static final SnappyCompressorInputStream. | |
| NO_BLOCK | back to summary |
|---|---|
| public static final SnappyCompressorInputStream. | |
| State | back to summary |
|---|---|
| private State() | |
| valueOf | back to summary |
|---|---|
| public static SnappyCompressorInputStream. | |
| values | back to summary |
|---|---|
| public static SnappyCompressorInputStream. | |