edit API comments

This commit is contained in:
Taro L. Saito 2011-03-30 15:30:09 +09:00
parent 960481b965
commit 7a0663f528
2 changed files with 10 additions and 9 deletions

View File

@ -54,18 +54,20 @@ public class Snappy
} }
/** /**
* Uncompress the compressed buffer to the specified output buffer
*
* @param compressed * @param compressed
* input is at buffer[pos() ... limit()) * input is at buffer[pos() ... limit())
* @param uncompressed * @param uncompressed
* output decompressed data to buffer[pot()) * output the uncompressed data to buffer[pot())
* @return decompressed data size * @return uncompressed data size
* *
*/ */
public static int uncompress(ByteBuffer compressed, ByteBuffer decompressed) throws SnappyException { public static int uncompress(ByteBuffer compressed, ByteBuffer uncompressed) throws SnappyException {
if (!compressed.isDirect()) if (!compressed.isDirect())
throw new IllegalArgumentException("input is not a direct buffer"); throw new IllegalArgumentException("input is not a direct buffer");
if (!decompressed.isDirect()) if (!uncompressed.isDirect())
throw new IllegalArgumentException("destination is not a direct buffer"); throw new IllegalArgumentException("destination is not a direct buffer");
int cPos = compressed.position(); int cPos = compressed.position();
@ -74,14 +76,14 @@ public class Snappy
// pos limit // pos limit
// [ ......UUUUUU.........] // [ ......UUUUUU.........]
int decompressedSize = SnappyNative int decompressedSize = SnappyNative
.rawUncompress(compressed, cPos, cLen, decompressed, decompressed.position()); .rawUncompress(compressed, cPos, cLen, uncompressed, uncompressed.position());
decompressed.limit(decompressed.position() + decompressedSize); uncompressed.limit(uncompressed.position() + decompressedSize);
return decompressedSize; return decompressedSize;
} }
/** /**
* Get the uncompressed size of the compressed input * Get the uncompressed size of the given compressed input
* *
* @param compressed * @param compressed
* data [pos() ... limit()) * data [pos() ... limit())
@ -99,7 +101,7 @@ public class Snappy
* *
* @param byteSize * @param byteSize
* byte size of the data to compress * byte size of the data to compress
* @return maxmum byte size of the compressed data * @return maximum byte size of the compressed data
*/ */
public static int maxCompressedLength(int byteSize) { public static int maxCompressedLength(int byteSize) {
return SnappyNative.maxCompressedLength(byteSize); return SnappyNative.maxCompressedLength(byteSize);

View File

@ -69,7 +69,6 @@ public class SnappyTest
_logger.info("uncompressed length: " + uncompressedLen); _logger.info("uncompressed length: " + uncompressedLen);
ByteBuffer extract = ByteBuffer.allocateDirect(uncompressedLen); ByteBuffer extract = ByteBuffer.allocateDirect(uncompressedLen);
Snappy.uncompress(compressed, extract); Snappy.uncompress(compressed, extract);
extract.limit(uncompressedLen);
byte[] b = new byte[uncompressedLen]; byte[] b = new byte[uncompressedLen];
extract.get(b); extract.get(b);