Small JNI improvements (#7371)
Summary: * Avoid some unnecessary array copy operations on read/write * Remove some duplicated code * Don't leak arrays on some exceptions * Fixed some doc comments Pull Request resolved: https://github.com/facebook/rocksdb/pull/7371 Reviewed By: jay-zhuang Differential Revision: D24312932 Pulled By: pdillinger fbshipit-source-id: 422fe6b98bbdb922a148922ac0d2d965c715176e
This commit is contained in:
parent
1a83f5a8ac
commit
ccbf468cb1
@ -22,20 +22,14 @@
|
||||
* Signature: ([J[J)Ljava/util/Map;
|
||||
*/
|
||||
jobject Java_org_rocksdb_MemoryUtil_getApproximateMemoryUsageByType(
|
||||
JNIEnv *env, jclass /*jclazz*/, jlongArray jdb_handles, jlongArray jcache_handles) {
|
||||
std::vector<ROCKSDB_NAMESPACE::DB *> dbs;
|
||||
jsize db_handle_count = env->GetArrayLength(jdb_handles);
|
||||
if(db_handle_count > 0) {
|
||||
jlong *ptr_jdb_handles = env->GetLongArrayElements(jdb_handles, nullptr);
|
||||
if (ptr_jdb_handles == nullptr) {
|
||||
// exception thrown: OutOfMemoryError
|
||||
return nullptr;
|
||||
}
|
||||
for (jsize i = 0; i < db_handle_count; i++) {
|
||||
dbs.push_back(
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::DB *>(ptr_jdb_handles[i]));
|
||||
}
|
||||
env->ReleaseLongArrayElements(jdb_handles, ptr_jdb_handles, JNI_ABORT);
|
||||
JNIEnv *env, jclass, jlongArray jdb_handles, jlongArray jcache_handles) {
|
||||
jboolean has_exception = JNI_FALSE;
|
||||
std::vector<ROCKSDB_NAMESPACE::DB *> dbs =
|
||||
ROCKSDB_NAMESPACE::JniUtil::fromJPointers<ROCKSDB_NAMESPACE::DB>(
|
||||
env, jdb_handles, &has_exception);
|
||||
if (has_exception == JNI_TRUE) {
|
||||
// exception thrown: OutOfMemoryError
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unordered_set<const ROCKSDB_NAMESPACE::Cache *> cache_set;
|
||||
@ -103,5 +97,4 @@ jobject Java_org_rocksdb_MemoryUtil_getApproximateMemoryUsageByType(
|
||||
}
|
||||
|
||||
return jusage_by_type;
|
||||
|
||||
}
|
||||
|
@ -553,7 +553,8 @@ jlong Java_org_rocksdb_Options_dbPathsLen(
|
||||
void Java_org_rocksdb_Options_dbPaths(
|
||||
JNIEnv* env, jobject, jlong jhandle, jobjectArray jpaths,
|
||||
jlongArray jtarget_sizes) {
|
||||
jlong* ptr_jtarget_size = env->GetLongArrayElements(jtarget_sizes, nullptr);
|
||||
jboolean is_copy;
|
||||
jlong* ptr_jtarget_size = env->GetLongArrayElements(jtarget_sizes, &is_copy);
|
||||
if (ptr_jtarget_size == nullptr) {
|
||||
// exception thrown: OutOfMemoryError
|
||||
return;
|
||||
@ -581,7 +582,8 @@ void Java_org_rocksdb_Options_dbPaths(
|
||||
ptr_jtarget_size[i] = static_cast<jint>(db_path.target_size);
|
||||
}
|
||||
|
||||
env->ReleaseLongArrayElements(jtarget_sizes, ptr_jtarget_size, JNI_COMMIT);
|
||||
env->ReleaseLongArrayElements(jtarget_sizes, ptr_jtarget_size,
|
||||
is_copy == JNI_TRUE ? 0 : JNI_ABORT);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -5029,8 +5031,8 @@ void Java_org_rocksdb_ColumnFamilyOptions_setMaxBytesForLevelMultiplierAdditiona
|
||||
JNIEnv* env, jobject, jlong jhandle,
|
||||
jintArray jmax_bytes_for_level_multiplier_additional) {
|
||||
jsize len = env->GetArrayLength(jmax_bytes_for_level_multiplier_additional);
|
||||
jint* additionals =
|
||||
env->GetIntArrayElements(jmax_bytes_for_level_multiplier_additional, 0);
|
||||
jint* additionals = env->GetIntArrayElements(
|
||||
jmax_bytes_for_level_multiplier_additional, nullptr);
|
||||
if (additionals == nullptr) {
|
||||
// exception thrown: OutOfMemoryError
|
||||
return;
|
||||
@ -5682,7 +5684,8 @@ jlong Java_org_rocksdb_DBOptions_dbPathsLen(
|
||||
void Java_org_rocksdb_DBOptions_dbPaths(
|
||||
JNIEnv* env, jobject, jlong jhandle, jobjectArray jpaths,
|
||||
jlongArray jtarget_sizes) {
|
||||
jlong* ptr_jtarget_size = env->GetLongArrayElements(jtarget_sizes, nullptr);
|
||||
jboolean is_copy;
|
||||
jlong* ptr_jtarget_size = env->GetLongArrayElements(jtarget_sizes, &is_copy);
|
||||
if (ptr_jtarget_size == nullptr) {
|
||||
// exception thrown: OutOfMemoryError
|
||||
return;
|
||||
@ -5710,7 +5713,8 @@ void Java_org_rocksdb_DBOptions_dbPaths(
|
||||
ptr_jtarget_size[i] = static_cast<jint>(db_path.target_size);
|
||||
}
|
||||
|
||||
env->ReleaseLongArrayElements(jtarget_sizes, ptr_jtarget_size, JNI_COMMIT);
|
||||
env->ReleaseLongArrayElements(jtarget_sizes, ptr_jtarget_size,
|
||||
is_copy == JNI_TRUE ? 0 : JNI_ABORT);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -226,7 +226,7 @@ class CodeJni : public JavaClass {
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getValueMethod(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -264,7 +264,7 @@ class SubCodeJni : public JavaClass {
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getValueMethod(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -329,7 +329,7 @@ class StatusJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getCodeMethod(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -350,7 +350,7 @@ class StatusJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getSubCodeMethod(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -371,7 +371,7 @@ class StatusJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getStateMethod(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -941,7 +941,7 @@ class RocksDBExceptionJni :
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getStatusMethod(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -1032,7 +1032,7 @@ class ListJni : public JavaClass {
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getIteratorMethod(JNIEnv* env) {
|
||||
jclass jlist_clazz = getListClass(env);
|
||||
@ -1053,7 +1053,7 @@ class ListJni : public JavaClass {
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getHasNextMethod(JNIEnv* env) {
|
||||
jclass jiterator_clazz = getIteratorClass(env);
|
||||
@ -1073,7 +1073,7 @@ class ListJni : public JavaClass {
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getNextMethod(JNIEnv* env) {
|
||||
jclass jiterator_clazz = getIteratorClass(env);
|
||||
@ -1094,7 +1094,7 @@ class ListJni : public JavaClass {
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getArrayListConstructorMethodId(JNIEnv* env) {
|
||||
jclass jarray_list_clazz = getArrayListClass(env);
|
||||
@ -1114,7 +1114,7 @@ class ListJni : public JavaClass {
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getListAddMethodId(JNIEnv* env) {
|
||||
jclass jlist_clazz = getListClass(env);
|
||||
@ -1251,10 +1251,11 @@ class ByteBufferJni : public JavaClass {
|
||||
* Get the Java Method: ByteBuffer#allocate
|
||||
*
|
||||
* @param env A pointer to the Java environment
|
||||
* @param jbytebuffer_clazz if you have a reference to a ByteBuffer class, or nullptr
|
||||
* @param jbytebuffer_clazz if you have a reference to a ByteBuffer class, or
|
||||
* nullptr
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getAllocateMethodId(JNIEnv* env,
|
||||
jclass jbytebuffer_clazz = nullptr) {
|
||||
@ -1277,7 +1278,7 @@ class ByteBufferJni : public JavaClass {
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getArrayMethodId(JNIEnv* env,
|
||||
jclass jbytebuffer_clazz = nullptr) {
|
||||
@ -1486,7 +1487,7 @@ class StringBuilderJni : public JavaClass {
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getListAddMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -2373,7 +2374,7 @@ class MapJni : public JavaClass {
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getMapPutMethodId(JNIEnv* env) {
|
||||
jclass jlist_clazz = getJClass(env);
|
||||
@ -2905,7 +2906,7 @@ class WriteBatchHandlerJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getPutCfMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -2925,7 +2926,7 @@ class WriteBatchHandlerJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getPutMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -2945,7 +2946,7 @@ class WriteBatchHandlerJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getMergeCfMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -2965,7 +2966,7 @@ class WriteBatchHandlerJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getMergeMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -2985,7 +2986,7 @@ class WriteBatchHandlerJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getDeleteCfMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -3005,7 +3006,7 @@ class WriteBatchHandlerJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getDeleteMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -3025,7 +3026,7 @@ class WriteBatchHandlerJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getSingleDeleteCfMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -3045,7 +3046,7 @@ class WriteBatchHandlerJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getSingleDeleteMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -3065,7 +3066,7 @@ class WriteBatchHandlerJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getDeleteRangeCfMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -3085,7 +3086,7 @@ class WriteBatchHandlerJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getDeleteRangeMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -3105,7 +3106,7 @@ class WriteBatchHandlerJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getLogDataMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -3125,7 +3126,7 @@ class WriteBatchHandlerJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getPutBlobIndexCfMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -3145,7 +3146,7 @@ class WriteBatchHandlerJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getMarkBeginPrepareMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -3165,7 +3166,7 @@ class WriteBatchHandlerJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getMarkEndPrepareMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -3185,7 +3186,7 @@ class WriteBatchHandlerJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getMarkNoopMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -3205,7 +3206,7 @@ class WriteBatchHandlerJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getMarkRollbackMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -3225,7 +3226,7 @@ class WriteBatchHandlerJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getMarkCommitMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -3245,7 +3246,7 @@ class WriteBatchHandlerJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getContinueMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -3281,7 +3282,7 @@ class WriteBatchSavePointJni : public JavaClass {
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getConstructorMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -3372,7 +3373,7 @@ class HistogramDataJni : public JavaClass {
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getConstructorMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -3561,7 +3562,7 @@ class AbstractCompactionFilterFactoryJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getNameMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -3582,7 +3583,7 @@ class AbstractCompactionFilterFactoryJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getCreateCompactionFilterMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -3649,7 +3650,7 @@ class AbstractComparatorJniBridge : public JavaClass {
|
||||
* @param jclazz the AbstractComparatorJniBridge class
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getCompareInternalMethodId(JNIEnv* env, jclass jclazz) {
|
||||
static jmethodID mid =
|
||||
@ -3666,7 +3667,7 @@ class AbstractComparatorJniBridge : public JavaClass {
|
||||
* @param jclazz the AbstractComparatorJniBridge class
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getFindShortestSeparatorInternalMethodId(JNIEnv* env, jclass jclazz) {
|
||||
static jmethodID mid =
|
||||
@ -3683,7 +3684,7 @@ class AbstractComparatorJniBridge : public JavaClass {
|
||||
* @param jclazz the AbstractComparatorJniBridge class
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getFindShortSuccessorInternalMethodId(JNIEnv* env, jclass jclazz) {
|
||||
static jmethodID mid =
|
||||
@ -3719,7 +3720,7 @@ class AbstractComparatorJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getNameMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -4016,7 +4017,7 @@ class WBWIRocksIteratorJni : public JavaClass {
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Field ID or nullptr if the class or field id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jfieldID getWriteEntryField(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -4337,7 +4338,7 @@ class LoggerJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getLogMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -5718,7 +5719,8 @@ class TransactionJni : public JavaClass {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
jlong *body = env->GetLongArrayElements(jtransaction_ids, nullptr);
|
||||
jboolean is_copy;
|
||||
jlong* body = env->GetLongArrayElements(jtransaction_ids, &is_copy);
|
||||
if(body == nullptr) {
|
||||
// exception thrown: OutOfMemoryError
|
||||
env->DeleteLocalRef(jkey);
|
||||
@ -5728,7 +5730,8 @@ class TransactionJni : public JavaClass {
|
||||
for(size_t i = 0; i < len; ++i) {
|
||||
body[i] = static_cast<jlong>(transaction_ids[i]);
|
||||
}
|
||||
env->ReleaseLongArrayElements(jtransaction_ids, body, 0);
|
||||
env->ReleaseLongArrayElements(jtransaction_ids, body,
|
||||
is_copy == JNI_TRUE ? 0 : JNI_ABORT);
|
||||
|
||||
jobject jwaiting_transactions = env->CallObjectMethod(jtransaction,
|
||||
mid, static_cast<jlong>(column_family_id), jkey, jtransaction_ids);
|
||||
@ -5999,7 +6002,7 @@ class AbstractTableFilterJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getFilterMethod(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -6269,7 +6272,7 @@ class ColumnFamilyDescriptorJni : public JavaClass {
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getColumnFamilyNameMethod(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -6289,7 +6292,7 @@ class ColumnFamilyDescriptorJni : public JavaClass {
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getColumnFamilyOptionsMethod(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -6783,7 +6786,8 @@ class ThreadStatusJni : public JavaClass {
|
||||
env->DeleteLocalRef(jcf_name);
|
||||
return nullptr;
|
||||
}
|
||||
jlong *body = env->GetLongArrayElements(joperation_properties, nullptr);
|
||||
jboolean is_copy;
|
||||
jlong* body = env->GetLongArrayElements(joperation_properties, &is_copy);
|
||||
if (body == nullptr) {
|
||||
// exception thrown: OutOfMemoryError
|
||||
env->DeleteLocalRef(jdb_name);
|
||||
@ -6794,7 +6798,8 @@ class ThreadStatusJni : public JavaClass {
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
body[i] = static_cast<jlong>(thread_status->op_properties[i]);
|
||||
}
|
||||
env->ReleaseLongArrayElements(joperation_properties, body, 0);
|
||||
env->ReleaseLongArrayElements(joperation_properties, body,
|
||||
is_copy == JNI_TRUE ? 0 : JNI_ABORT);
|
||||
|
||||
jobject jcfd = env->NewObject(jclazz, mid,
|
||||
static_cast<jlong>(thread_status->thread_id),
|
||||
@ -7415,7 +7420,7 @@ class AbstractTraceWriterJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getWriteProxyMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -7436,7 +7441,7 @@ class AbstractTraceWriterJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getCloseWriterProxyMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -7457,7 +7462,7 @@ class AbstractTraceWriterJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getGetFileSizeMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -7498,7 +7503,7 @@ class AbstractWalFilterJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getColumnFamilyLogNumberMapMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -7520,7 +7525,7 @@ class AbstractWalFilterJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getLogRecordFoundProxyMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
@ -7541,7 +7546,7 @@ class AbstractWalFilterJni
|
||||
* @param env A pointer to the Java environment
|
||||
*
|
||||
* @return The Java Method ID or nullptr if the class or method id could not
|
||||
* be retieved
|
||||
* be retrieved
|
||||
*/
|
||||
static jmethodID getNameMethodId(JNIEnv* env) {
|
||||
jclass jclazz = getJClass(env);
|
||||
|
@ -421,8 +421,8 @@ jlongArray Java_org_rocksdb_RocksDB_createColumnFamilies__J_3J_3_3B(
|
||||
std::vector<ROCKSDB_NAMESPACE::ColumnFamilyDescriptor> cf_descriptors;
|
||||
cf_descriptors.reserve(jlen);
|
||||
|
||||
jboolean jcf_options_handles_is_copy = JNI_FALSE;
|
||||
jlong *jcf_options_handles_elems = env->GetLongArrayElements(jcf_options_handles, &jcf_options_handles_is_copy);
|
||||
jlong* jcf_options_handles_elems =
|
||||
env->GetLongArrayElements(jcf_options_handles, nullptr);
|
||||
if(jcf_options_handles_elems == nullptr) {
|
||||
// exception thrown: OutOfMemoryError
|
||||
return nullptr;
|
||||
@ -2343,9 +2343,7 @@ jlongArray Java_org_rocksdb_RocksDB_getApproximateSizes(
|
||||
const jsize jlen = env->GetArrayLength(jrange_slice_handles);
|
||||
const size_t range_count = jlen / 2;
|
||||
|
||||
jboolean jranges_is_copy = JNI_FALSE;
|
||||
jlong* jranges = env->GetLongArrayElements(jrange_slice_handles,
|
||||
&jranges_is_copy);
|
||||
jlong* jranges = env->GetLongArrayElements(jrange_slice_handles, nullptr);
|
||||
if (jranges == nullptr) {
|
||||
// exception thrown: OutOfMemoryError
|
||||
return nullptr;
|
||||
@ -3256,9 +3254,8 @@ jobject Java_org_rocksdb_RocksDB_getPropertiesOfTablesInRange(
|
||||
reinterpret_cast<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>(jcf_handle);
|
||||
}
|
||||
const jsize jlen = env->GetArrayLength(jrange_slice_handles);
|
||||
jboolean jrange_slice_handles_is_copy = JNI_FALSE;
|
||||
jlong *jrange_slice_handle = env->GetLongArrayElements(
|
||||
jrange_slice_handles, &jrange_slice_handles_is_copy);
|
||||
jlong* jrange_slice_handle =
|
||||
env->GetLongArrayElements(jrange_slice_handles, nullptr);
|
||||
if (jrange_slice_handle == nullptr) {
|
||||
// exception occurred
|
||||
return nullptr;
|
||||
|
@ -689,6 +689,7 @@ void txn_write_kv_parts_helper(JNIEnv* env,
|
||||
// out of memory
|
||||
env->DeleteLocalRef(jobj_value_part);
|
||||
env->DeleteLocalRef(jobj_key_part);
|
||||
env->ReleaseByteArrayElements(jba_key_part, jkey_part, JNI_ABORT);
|
||||
free_parts(env, jparts_to_free);
|
||||
return;
|
||||
}
|
||||
@ -698,6 +699,7 @@ void txn_write_kv_parts_helper(JNIEnv* env,
|
||||
env->ReleaseByteArrayElements(jba_value_part, jvalue_part, JNI_ABORT);
|
||||
env->DeleteLocalRef(jobj_value_part);
|
||||
env->DeleteLocalRef(jobj_key_part);
|
||||
env->ReleaseByteArrayElements(jba_key_part, jkey_part, JNI_ABORT);
|
||||
free_parts(env, jparts_to_free);
|
||||
return;
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ jlong Java_org_rocksdb_TtlDB_createColumnFamilyWithTtl(
|
||||
*cfOptions, std::string(reinterpret_cast<char*>(cfname), len), &handle,
|
||||
jttl);
|
||||
|
||||
env->ReleaseByteArrayElements(jcolumn_name, cfname, 0);
|
||||
env->ReleaseByteArrayElements(jcolumn_name, cfname, JNI_ABORT);
|
||||
|
||||
if (s.ok()) {
|
||||
return reinterpret_cast<jlong>(handle);
|
||||
|
Loading…
Reference in New Issue
Block a user