|
@@ -27,7 +27,6 @@
|
|
#include "lz4hc.h"
|
|
#include "lz4hc.h"
|
|
|
|
|
|
|
|
|
|
-static jfieldID Lz4Compressor_clazz;
|
|
|
|
static jfieldID Lz4Compressor_uncompressedDirectBuf;
|
|
static jfieldID Lz4Compressor_uncompressedDirectBuf;
|
|
static jfieldID Lz4Compressor_uncompressedDirectBufLen;
|
|
static jfieldID Lz4Compressor_uncompressedDirectBufLen;
|
|
static jfieldID Lz4Compressor_compressedDirectBuf;
|
|
static jfieldID Lz4Compressor_compressedDirectBuf;
|
|
@@ -37,8 +36,6 @@ static jfieldID Lz4Compressor_directBufferSize;
|
|
JNIEXPORT void JNICALL Java_org_apache_hadoop_io_compress_lz4_Lz4Compressor_initIDs
|
|
JNIEXPORT void JNICALL Java_org_apache_hadoop_io_compress_lz4_Lz4Compressor_initIDs
|
|
(JNIEnv *env, jclass clazz){
|
|
(JNIEnv *env, jclass clazz){
|
|
|
|
|
|
- Lz4Compressor_clazz = (*env)->GetStaticFieldID(env, clazz, "clazz",
|
|
|
|
- "Ljava/lang/Class;");
|
|
|
|
Lz4Compressor_uncompressedDirectBuf = (*env)->GetFieldID(env, clazz,
|
|
Lz4Compressor_uncompressedDirectBuf = (*env)->GetFieldID(env, clazz,
|
|
"uncompressedDirectBuf",
|
|
"uncompressedDirectBuf",
|
|
"Ljava/nio/Buffer;");
|
|
"Ljava/nio/Buffer;");
|
|
@@ -57,25 +54,20 @@ JNIEXPORT jint JNICALL Java_org_apache_hadoop_io_compress_lz4_Lz4Compressor_comp
|
|
char *compressed_bytes;
|
|
char *compressed_bytes;
|
|
|
|
|
|
// Get members of Lz4Compressor
|
|
// Get members of Lz4Compressor
|
|
- jobject clazz = (*env)->GetStaticObjectField(env, thisj, Lz4Compressor_clazz);
|
|
|
|
jobject uncompressed_direct_buf = (*env)->GetObjectField(env, thisj, Lz4Compressor_uncompressedDirectBuf);
|
|
jobject uncompressed_direct_buf = (*env)->GetObjectField(env, thisj, Lz4Compressor_uncompressedDirectBuf);
|
|
jint uncompressed_direct_buf_len = (*env)->GetIntField(env, thisj, Lz4Compressor_uncompressedDirectBufLen);
|
|
jint uncompressed_direct_buf_len = (*env)->GetIntField(env, thisj, Lz4Compressor_uncompressedDirectBufLen);
|
|
jobject compressed_direct_buf = (*env)->GetObjectField(env, thisj, Lz4Compressor_compressedDirectBuf);
|
|
jobject compressed_direct_buf = (*env)->GetObjectField(env, thisj, Lz4Compressor_compressedDirectBuf);
|
|
jint compressed_direct_buf_len = (*env)->GetIntField(env, thisj, Lz4Compressor_directBufferSize);
|
|
jint compressed_direct_buf_len = (*env)->GetIntField(env, thisj, Lz4Compressor_directBufferSize);
|
|
|
|
|
|
// Get the input direct buffer
|
|
// Get the input direct buffer
|
|
- LOCK_CLASS(env, clazz, "Lz4Compressor");
|
|
|
|
uncompressed_bytes = (const char*)(*env)->GetDirectBufferAddress(env, uncompressed_direct_buf);
|
|
uncompressed_bytes = (const char*)(*env)->GetDirectBufferAddress(env, uncompressed_direct_buf);
|
|
- UNLOCK_CLASS(env, clazz, "Lz4Compressor");
|
|
|
|
|
|
|
|
if (uncompressed_bytes == 0) {
|
|
if (uncompressed_bytes == 0) {
|
|
return (jint)0;
|
|
return (jint)0;
|
|
}
|
|
}
|
|
|
|
|
|
// Get the output direct buffer
|
|
// Get the output direct buffer
|
|
- LOCK_CLASS(env, clazz, "Lz4Compressor");
|
|
|
|
compressed_bytes = (char *)(*env)->GetDirectBufferAddress(env, compressed_direct_buf);
|
|
compressed_bytes = (char *)(*env)->GetDirectBufferAddress(env, compressed_direct_buf);
|
|
- UNLOCK_CLASS(env, clazz, "Lz4Compressor");
|
|
|
|
|
|
|
|
if (compressed_bytes == 0) {
|
|
if (compressed_bytes == 0) {
|
|
return (jint)0;
|
|
return (jint)0;
|
|
@@ -104,25 +96,20 @@ JNIEXPORT jint JNICALL Java_org_apache_hadoop_io_compress_lz4_Lz4Compressor_comp
|
|
char* compressed_bytes = NULL;
|
|
char* compressed_bytes = NULL;
|
|
|
|
|
|
// Get members of Lz4Compressor
|
|
// Get members of Lz4Compressor
|
|
- jobject clazz = (*env)->GetStaticObjectField(env, thisj, Lz4Compressor_clazz);
|
|
|
|
jobject uncompressed_direct_buf = (*env)->GetObjectField(env, thisj, Lz4Compressor_uncompressedDirectBuf);
|
|
jobject uncompressed_direct_buf = (*env)->GetObjectField(env, thisj, Lz4Compressor_uncompressedDirectBuf);
|
|
jint uncompressed_direct_buf_len = (*env)->GetIntField(env, thisj, Lz4Compressor_uncompressedDirectBufLen);
|
|
jint uncompressed_direct_buf_len = (*env)->GetIntField(env, thisj, Lz4Compressor_uncompressedDirectBufLen);
|
|
jobject compressed_direct_buf = (*env)->GetObjectField(env, thisj, Lz4Compressor_compressedDirectBuf);
|
|
jobject compressed_direct_buf = (*env)->GetObjectField(env, thisj, Lz4Compressor_compressedDirectBuf);
|
|
jint compressed_direct_buf_len = (*env)->GetIntField(env, thisj, Lz4Compressor_directBufferSize);
|
|
jint compressed_direct_buf_len = (*env)->GetIntField(env, thisj, Lz4Compressor_directBufferSize);
|
|
|
|
|
|
// Get the input direct buffer
|
|
// Get the input direct buffer
|
|
- LOCK_CLASS(env, clazz, "Lz4Compressor");
|
|
|
|
uncompressed_bytes = (const char*)(*env)->GetDirectBufferAddress(env, uncompressed_direct_buf);
|
|
uncompressed_bytes = (const char*)(*env)->GetDirectBufferAddress(env, uncompressed_direct_buf);
|
|
- UNLOCK_CLASS(env, clazz, "Lz4Compressor");
|
|
|
|
|
|
|
|
if (uncompressed_bytes == 0) {
|
|
if (uncompressed_bytes == 0) {
|
|
return (jint)0;
|
|
return (jint)0;
|
|
}
|
|
}
|
|
|
|
|
|
// Get the output direct buffer
|
|
// Get the output direct buffer
|
|
- LOCK_CLASS(env, clazz, "Lz4Compressor");
|
|
|
|
compressed_bytes = (char *)(*env)->GetDirectBufferAddress(env, compressed_direct_buf);
|
|
compressed_bytes = (char *)(*env)->GetDirectBufferAddress(env, compressed_direct_buf);
|
|
- UNLOCK_CLASS(env, clazz, "Lz4Compressor");
|
|
|
|
|
|
|
|
if (compressed_bytes == 0) {
|
|
if (compressed_bytes == 0) {
|
|
return (jint)0;
|
|
return (jint)0;
|