Fixes #26. Add throws IOException to rawCompress

This commit is contained in:
Taro L. Saito 2013-03-28 12:53:23 +09:00
parent e1b593d6c2
commit 64c35c7081
4 changed files with 27 additions and 3 deletions

View File

@ -354,7 +354,7 @@ public class Snappy
* the input byte size * the input byte size
* @return compressed data * @return compressed data
*/ */
public static byte[] rawCompress(Object data, int byteSize) { public static byte[] rawCompress(Object data, int byteSize) throws IOException {
byte[] buf = new byte[Snappy.maxCompressedLength(byteSize)]; byte[] buf = new byte[Snappy.maxCompressedLength(byteSize)];
int compressedByteSize = ((SnappyNativeAPI) impl).rawCompress(data, 0, byteSize, buf, 0); int compressedByteSize = ((SnappyNativeAPI) impl).rawCompress(data, 0, byteSize, buf, 0);
byte[] result = new byte[compressedByteSize]; byte[] result = new byte[compressedByteSize];

View File

@ -15,6 +15,22 @@ extern "C" {
JNIEXPORT jstring JNICALL Java_org_xerial_snappy_SnappyNative_nativeLibraryVersion JNIEXPORT jstring JNICALL Java_org_xerial_snappy_SnappyNative_nativeLibraryVersion
(JNIEnv *, jobject); (JNIEnv *, jobject);
/*
* Class: org_xerial_snappy_SnappyNative
* Method: rawCompress
* Signature: (JJJ)J
*/
JNIEXPORT jlong JNICALL Java_org_xerial_snappy_SnappyNative_rawCompress__JJJ
(JNIEnv *, jobject, jlong, jlong, jlong);
/*
* Class: org_xerial_snappy_SnappyNative
* Method: rawUncompress
* Signature: (JJJ)J
*/
JNIEXPORT jlong JNICALL Java_org_xerial_snappy_SnappyNative_rawUncompress__JJJ
(JNIEnv *, jobject, jlong, jlong, jlong);
/* /*
* Class: org_xerial_snappy_SnappyNative * Class: org_xerial_snappy_SnappyNative
* Method: rawCompress * Method: rawCompress
@ -71,6 +87,14 @@ JNIEXPORT jint JNICALL Java_org_xerial_snappy_SnappyNative_uncompressedLength__L
JNIEXPORT jint JNICALL Java_org_xerial_snappy_SnappyNative_uncompressedLength__Ljava_lang_Object_2II JNIEXPORT jint JNICALL Java_org_xerial_snappy_SnappyNative_uncompressedLength__Ljava_lang_Object_2II
(JNIEnv *, jobject, jobject, jint, jint); (JNIEnv *, jobject, jobject, jint, jint);
/*
* Class: org_xerial_snappy_SnappyNative
* Method: uncompressedLength
* Signature: (JJ)J
*/
JNIEXPORT jlong JNICALL Java_org_xerial_snappy_SnappyNative_uncompressedLength__JJ
(JNIEnv *, jobject, jlong, jlong);
/* /*
* Class: org_xerial_snappy_SnappyNative * Class: org_xerial_snappy_SnappyNative
* Method: isValidCompressedBuffer * Method: isValidCompressedBuffer

View File

@ -54,7 +54,7 @@ public class SnappyNative implements SnappyNativeAPI
public native int rawCompress(ByteBuffer input, int inputOffset, int inputLength, ByteBuffer compressed, public native int rawCompress(ByteBuffer input, int inputOffset, int inputLength, ByteBuffer compressed,
int outputOffset) throws IOException; int outputOffset) throws IOException;
public native int rawCompress(Object input, int inputOffset, int inputByteLength, Object output, int outputOffset); public native int rawCompress(Object input, int inputOffset, int inputByteLength, Object output, int outputOffset) throws IOException;
public native int rawUncompress(ByteBuffer compressed, int inputOffset, int inputLength, ByteBuffer uncompressed, public native int rawUncompress(ByteBuffer compressed, int inputOffset, int inputLength, ByteBuffer uncompressed,
int outputOffset) throws IOException; int outputOffset) throws IOException;

View File

@ -51,7 +51,7 @@ public interface SnappyNativeAPI
public int rawCompress(ByteBuffer input, int inputOffset, int inputLength, ByteBuffer compressed, int outputOffset) public int rawCompress(ByteBuffer input, int inputOffset, int inputLength, ByteBuffer compressed, int outputOffset)
throws IOException; throws IOException;
public int rawCompress(Object input, int inputOffset, int inputByteLength, Object output, int outputOffset); public int rawCompress(Object input, int inputOffset, int inputByteLength, Object output, int outputOffset) throws IOException;
public int rawUncompress(ByteBuffer compressed, int inputOffset, int inputLength, ByteBuffer uncompressed, public int rawUncompress(ByteBuffer compressed, int inputOffset, int inputLength, ByteBuffer uncompressed,
int outputOffset) throws IOException; int outputOffset) throws IOException;