mirror of
https://github.com/xerial/snappy-java.git
synced 2025-07-27 07:54:17 +02:00
edit API comments
This commit is contained in:
parent
960481b965
commit
7a0663f528
@ -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);
|
||||||
|
@ -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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user