Package org.iq80.snappy
Class SnappyDecompressor
- java.lang.Object
-
- org.iq80.snappy.SnappyDecompressor
-
final class SnappyDecompressor extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private static int
MAX_INCREMENT_COPY_OVERFLOW
private static short[]
opLookupTable
private static int[]
wordmask
-
Constructor Summary
Constructors Constructor Description SnappyDecompressor()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static void
copyLiteral(byte[] input, int ipIndex, byte[] output, int opIndex, int length)
private static int
decompressAllTags(byte[] input, int inputOffset, int inputSize, byte[] output, int outputOffset)
private static int[]
decompressTagSlow(byte[] input, int ipIndex, byte[] output, int outputLimit, int outputOffset, int opIndex)
This is a second copy of the inner loop of decompressTags used when near the end of the input.static int
getUncompressedLength(byte[] compressed, int compressedOffset)
private static void
incrementalCopy(byte[] src, int srcIndex, byte[] op, int opIndex, int length)
Copy "len" bytes from "src" to "op", one byte at a time.private static void
incrementalCopyFastPath(byte[] output, int srcIndex, int opIndex, int length)
private static int
readTrailer(byte[] data, int index, int bytes)
private static int[]
readUncompressedLength(byte[] compressed, int compressedOffset)
Reads the variable length integer encoded a the specified offset, and returns this length with the number of bytes read.static byte[]
uncompress(byte[] compressed, int compressedOffset, int compressedSize)
static int
uncompress(byte[] compressed, int compressedOffset, int compressedSize, byte[] uncompressed, int uncompressedOffset)
-
-
-
Field Detail
-
MAX_INCREMENT_COPY_OVERFLOW
private static final int MAX_INCREMENT_COPY_OVERFLOW
- See Also:
- Constant Field Values
-
wordmask
private static final int[] wordmask
-
opLookupTable
private static final short[] opLookupTable
-
-
Method Detail
-
getUncompressedLength
public static int getUncompressedLength(byte[] compressed, int compressedOffset) throws CorruptionException
- Throws:
CorruptionException
-
uncompress
public static byte[] uncompress(byte[] compressed, int compressedOffset, int compressedSize) throws CorruptionException
- Throws:
CorruptionException
-
uncompress
public static int uncompress(byte[] compressed, int compressedOffset, int compressedSize, byte[] uncompressed, int uncompressedOffset) throws CorruptionException
- Throws:
CorruptionException
-
decompressAllTags
private static int decompressAllTags(byte[] input, int inputOffset, int inputSize, byte[] output, int outputOffset) throws CorruptionException
- Throws:
CorruptionException
-
decompressTagSlow
private static int[] decompressTagSlow(byte[] input, int ipIndex, byte[] output, int outputLimit, int outputOffset, int opIndex) throws CorruptionException
This is a second copy of the inner loop of decompressTags used when near the end of the input. The key difference is the reading of the trailer bytes. The fast code does a blind read of the next 4 bytes as an int, and this code assembles the int byte-by-byte to assure that the array is not over run. The reason this code path is separate is the if condition to choose between these two seemingly small differences costs like 10-20% of the throughput. I'm hoping in future versions of hot-spot this code can be integrated into the main loop but for now it is worth the extra maintenance pain to get the extra 10-20%.- Throws:
CorruptionException
-
readTrailer
private static int readTrailer(byte[] data, int index, int bytes)
-
copyLiteral
private static void copyLiteral(byte[] input, int ipIndex, byte[] output, int opIndex, int length) throws CorruptionException
- Throws:
CorruptionException
-
incrementalCopy
private static void incrementalCopy(byte[] src, int srcIndex, byte[] op, int opIndex, int length)
Copy "len" bytes from "src" to "op", one byte at a time. Used for handling COPY operations where the input and output regions may overlap. For example, suppose: src == "ab" op == src + 2 len == 20 After incrementalCopy, the result will have eleven copies of "ab" ababababababababababab Note that this does not match the semantics of either memcpy() or memmove().
-
incrementalCopyFastPath
private static void incrementalCopyFastPath(byte[] output, int srcIndex, int opIndex, int length)
-
readUncompressedLength
private static int[] readUncompressedLength(byte[] compressed, int compressedOffset) throws CorruptionException
Reads the variable length integer encoded a the specified offset, and returns this length with the number of bytes read.- Throws:
CorruptionException
-
-