HADOOP-15859. ZStandardDecompressor.c mistakes a class for an instance. Contributed by Jason Lowe
(cherry picked from commit 9abda83947
)
This commit is contained in:
parent
9c350785d4
commit
65b27f8ed2
|
@ -298,7 +298,7 @@ public class ZStandardCompressor implements Compressor {
|
||||||
private native static void init(int level, long stream);
|
private native static void init(int level, long stream);
|
||||||
private native int deflateBytesDirect(ByteBuffer src, int srcOffset,
|
private native int deflateBytesDirect(ByteBuffer src, int srcOffset,
|
||||||
int srcLen, ByteBuffer dst, int dstLen);
|
int srcLen, ByteBuffer dst, int dstLen);
|
||||||
private static native int getStreamSize();
|
private native static int getStreamSize();
|
||||||
private native static void end(long strm);
|
private native static void end(long strm);
|
||||||
private native static void initIDs();
|
private native static void initIDs();
|
||||||
public native static String getLibraryName();
|
public native static String getLibraryName();
|
||||||
|
|
|
@ -139,7 +139,7 @@ JNIEXPORT void JNICALL Java_org_apache_hadoop_io_compress_zstd_ZStandardCompress
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the compression stream
|
// Create the compression stream
|
||||||
JNIEXPORT jlong JNICALL Java_org_apache_hadoop_io_compress_zstd_ZStandardCompressor_create (JNIEnv *env, jobject this) {
|
JNIEXPORT jlong JNICALL Java_org_apache_hadoop_io_compress_zstd_ZStandardCompressor_create (JNIEnv *env, jclass clazz) {
|
||||||
ZSTD_CStream* const stream = dlsym_ZSTD_createCStream();
|
ZSTD_CStream* const stream = dlsym_ZSTD_createCStream();
|
||||||
if (stream == NULL) {
|
if (stream == NULL) {
|
||||||
THROW(env, "java/lang/InternalError", "Error creating the stream");
|
THROW(env, "java/lang/InternalError", "Error creating the stream");
|
||||||
|
@ -149,7 +149,7 @@ JNIEXPORT jlong JNICALL Java_org_apache_hadoop_io_compress_zstd_ZStandardCompres
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the compression stream
|
// Initialize the compression stream
|
||||||
JNIEXPORT void JNICALL Java_org_apache_hadoop_io_compress_zstd_ZStandardCompressor_init (JNIEnv *env, jobject this, jint level, jlong stream) {
|
JNIEXPORT void JNICALL Java_org_apache_hadoop_io_compress_zstd_ZStandardCompressor_init (JNIEnv *env, jclass clazz, jint level, jlong stream) {
|
||||||
size_t result = dlsym_ZSTD_initCStream((ZSTD_CStream *) stream, level);
|
size_t result = dlsym_ZSTD_initCStream((ZSTD_CStream *) stream, level);
|
||||||
if (dlsym_ZSTD_isError(result)) {
|
if (dlsym_ZSTD_isError(result)) {
|
||||||
THROW(env, "java/lang/InternalError", dlsym_ZSTD_getErrorName(result));
|
THROW(env, "java/lang/InternalError", dlsym_ZSTD_getErrorName(result));
|
||||||
|
@ -158,7 +158,7 @@ JNIEXPORT void JNICALL Java_org_apache_hadoop_io_compress_zstd_ZStandardCompress
|
||||||
}
|
}
|
||||||
|
|
||||||
// free the compression stream
|
// free the compression stream
|
||||||
JNIEXPORT void JNICALL Java_org_apache_hadoop_io_compress_zstd_ZStandardCompressor_end (JNIEnv *env, jobject this, jlong stream) {
|
JNIEXPORT void JNICALL Java_org_apache_hadoop_io_compress_zstd_ZStandardCompressor_end (JNIEnv *env, jclass clazz, jlong stream) {
|
||||||
size_t result = dlsym_ZSTD_freeCStream((ZSTD_CStream *) stream);
|
size_t result = dlsym_ZSTD_freeCStream((ZSTD_CStream *) stream);
|
||||||
if (dlsym_ZSTD_isError(result)) {
|
if (dlsym_ZSTD_isError(result)) {
|
||||||
THROW(env, "java/lang/InternalError", dlsym_ZSTD_getErrorName(result));
|
THROW(env, "java/lang/InternalError", dlsym_ZSTD_getErrorName(result));
|
||||||
|
@ -227,7 +227,7 @@ JNIEXPORT jint Java_org_apache_hadoop_io_compress_zstd_ZStandardCompressor_defla
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jstring JNICALL Java_org_apache_hadoop_io_compress_zstd_ZStandardCompressor_getLibraryName
|
JNIEXPORT jstring JNICALL Java_org_apache_hadoop_io_compress_zstd_ZStandardCompressor_getLibraryName
|
||||||
(JNIEnv *env, jclass class) {
|
(JNIEnv *env, jclass clazz) {
|
||||||
#ifdef UNIX
|
#ifdef UNIX
|
||||||
if (dlsym_ZSTD_isError) {
|
if (dlsym_ZSTD_isError) {
|
||||||
Dl_info dl_info;
|
Dl_info dl_info;
|
||||||
|
@ -250,7 +250,7 @@ JNIEXPORT jstring JNICALL Java_org_apache_hadoop_io_compress_zstd_ZStandardCompr
|
||||||
|
|
||||||
// returns the max size of the recommended input and output buffers
|
// returns the max size of the recommended input and output buffers
|
||||||
JNIEXPORT jint JNICALL Java_org_apache_hadoop_io_compress_zstd_ZStandardCompressor_getStreamSize
|
JNIEXPORT jint JNICALL Java_org_apache_hadoop_io_compress_zstd_ZStandardCompressor_getStreamSize
|
||||||
(JNIEnv *env, jobject this) {
|
(JNIEnv *env, jclass clazz) {
|
||||||
int x = (int) dlsym_ZSTD_CStreamInSize();
|
int x = (int) dlsym_ZSTD_CStreamInSize();
|
||||||
int y = (int) dlsym_ZSTD_CStreamOutSize();
|
int y = (int) dlsym_ZSTD_CStreamOutSize();
|
||||||
return (x >= y) ? x : y;
|
return (x >= y) ? x : y;
|
||||||
|
|
|
@ -130,7 +130,7 @@ JNIEXPORT void JNICALL Java_org_apache_hadoop_io_compress_zstd_ZStandardDecompre
|
||||||
ZStandardDecompressor_remaining = (*env)->GetFieldID(env, clazz, "remaining", "I");
|
ZStandardDecompressor_remaining = (*env)->GetFieldID(env, clazz, "remaining", "I");
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jlong JNICALL Java_org_apache_hadoop_io_compress_zstd_ZStandardDecompressor_create(JNIEnv *env, jobject this) {
|
JNIEXPORT jlong JNICALL Java_org_apache_hadoop_io_compress_zstd_ZStandardDecompressor_create(JNIEnv *env, jclass clazz) {
|
||||||
ZSTD_DStream * stream = dlsym_ZSTD_createDStream();
|
ZSTD_DStream * stream = dlsym_ZSTD_createDStream();
|
||||||
if (stream == NULL) {
|
if (stream == NULL) {
|
||||||
THROW(env, "java/lang/InternalError", "Error creating stream");
|
THROW(env, "java/lang/InternalError", "Error creating stream");
|
||||||
|
@ -139,17 +139,16 @@ JNIEXPORT jlong JNICALL Java_org_apache_hadoop_io_compress_zstd_ZStandardDecompr
|
||||||
return (jlong) stream;
|
return (jlong) stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_apache_hadoop_io_compress_zstd_ZStandardDecompressor_init(JNIEnv *env, jobject this, jlong stream) {
|
JNIEXPORT void JNICALL Java_org_apache_hadoop_io_compress_zstd_ZStandardDecompressor_init(JNIEnv *env, jclass clazz, jlong stream) {
|
||||||
size_t result = dlsym_ZSTD_initDStream((ZSTD_DStream *) stream);
|
size_t result = dlsym_ZSTD_initDStream((ZSTD_DStream *) stream);
|
||||||
if (dlsym_ZSTD_isError(result)) {
|
if (dlsym_ZSTD_isError(result)) {
|
||||||
THROW(env, "java/lang/InternalError", dlsym_ZSTD_getErrorName(result));
|
THROW(env, "java/lang/InternalError", dlsym_ZSTD_getErrorName(result));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
(*env)->SetIntField(env, this, ZStandardDecompressor_remaining, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_apache_hadoop_io_compress_zstd_ZStandardDecompressor_free(JNIEnv *env, jclass obj, jlong stream) {
|
JNIEXPORT void JNICALL Java_org_apache_hadoop_io_compress_zstd_ZStandardDecompressor_free(JNIEnv *env, jclass clazz, jlong stream) {
|
||||||
size_t result = dlsym_ZSTD_freeDStream((ZSTD_DStream *) stream);
|
size_t result = dlsym_ZSTD_freeDStream((ZSTD_DStream *) stream);
|
||||||
if (dlsym_ZSTD_isError(result)) {
|
if (dlsym_ZSTD_isError(result)) {
|
||||||
THROW(env, "java/lang/InternalError", dlsym_ZSTD_getErrorName(result));
|
THROW(env, "java/lang/InternalError", dlsym_ZSTD_getErrorName(result));
|
||||||
|
@ -209,10 +208,10 @@ JNIEXPORT jint JNICALL Java_org_apache_hadoop_io_compress_zstd_ZStandardDecompre
|
||||||
|
|
||||||
// returns the max size of the recommended input and output buffers
|
// returns the max size of the recommended input and output buffers
|
||||||
JNIEXPORT jint JNICALL Java_org_apache_hadoop_io_compress_zstd_ZStandardDecompressor_getStreamSize
|
JNIEXPORT jint JNICALL Java_org_apache_hadoop_io_compress_zstd_ZStandardDecompressor_getStreamSize
|
||||||
(JNIEnv *env, jclass obj) {
|
(JNIEnv *env, jclass clazz) {
|
||||||
int x = (int) dlsym_ZSTD_DStreamInSize();
|
int x = (int) dlsym_ZSTD_DStreamInSize();
|
||||||
int y = (int) dlsym_ZSTD_DStreamOutSize();
|
int y = (int) dlsym_ZSTD_DStreamOutSize();
|
||||||
return (x >= y) ? x : y;
|
return (x >= y) ? x : y;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //define HADOOP_ZSTD_LIBRARY
|
#endif //define HADOOP_ZSTD_LIBRARY
|
||||||
|
|
Loading…
Reference in New Issue