From 36f0208eb19df31488ba9c3db98a6c263dea0503 Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Sat, 2 Jul 2011 14:01:49 +0900 Subject: [PATCH] Fixes issue 22 Thanks for the report. getUncompressedLength() was an experimental method, that tries to migrate C++ code of the Snappy into Java. I removed this method. --- src/main/java/org/xerial/snappy/Snappy.java | 57 --------------------- 1 file changed, 57 deletions(-) diff --git a/src/main/java/org/xerial/snappy/Snappy.java b/src/main/java/org/xerial/snappy/Snappy.java index 9127b2d..c4683f6 100755 --- a/src/main/java/org/xerial/snappy/Snappy.java +++ b/src/main/java/org/xerial/snappy/Snappy.java @@ -419,63 +419,6 @@ public class Snappy return impl.uncompressedLength(input, offset, length); } - public static class CompressedDataLength - { - public final int cursor; - public final int uncompressedLength; - - public CompressedDataLength(int cursor, int uncompressedLength) { - this.cursor = cursor; - this.uncompressedLength = uncompressedLength; - } - } - - public static CompressedDataLength getUncompressedLength(byte[] input, int offset, int limit) throws IOException { - if (input == null) - throw new NullPointerException("input is null"); - - long b = 0; - long result = 0; - int cursor = offset; - if (cursor >= limit) - return null; - for (;;) { - b = input[cursor++]; - result = b & 127; - if (b < 128) - break; - if (cursor >= limit) - return null; - b = input[cursor++]; - result |= (b & 127) << 7; - if (b < 128) - break; - if (cursor >= limit) - return null; - b = input[cursor++]; - result |= (b & 127) << 14; - if (b < 128) - break; - if (cursor >= limit) - return null; - b = input[cursor++]; - result |= (b & 127) << 21; - if (b < 128) - break; - if (cursor >= limit) - return null; - b = input[cursor++]; - result |= (b & 127) << 28; - if (b < 16) - break; - return null; // Value is too long to be a varint32 - } - if (result > Integer.MAX_VALUE) - throw new IllegalStateException("cannot uncompress byte array longer than 2^31-1: " + result); - - return new CompressedDataLength(cursor, (int) result); - } - /** * Get the uncompressed byte size of the given compressed input. This * operation taks O(1) time.