ac956f2bea
Summary: Fix ColumnFamilyOptionsTest.cfPaths and OptionsTest.cfPaths in 6.15 branch (and probably other branches including master) has_exception variable was not initialized which was causing test failures and incorrect behavior on s390 platform (and maybe others as variable content is undefined). adamretter please take a look. Pull Request resolved: https://github.com/facebook/rocksdb/pull/7853 Reviewed By: akankshamahajan15 Differential Revision: D25901639 Pulled By: jay-zhuang fbshipit-source-id: 151b5db27b495fc6d8ed54c0eccbde2508215ac5
91 lines
3.0 KiB
C++
91 lines
3.0 KiB
C++
#include "rocksdb/concurrent_task_limiter.h"
|
|
|
|
#include <jni.h>
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
#include "include/org_rocksdb_ConcurrentTaskLimiterImpl.h"
|
|
#include "rocksjni/portal.h"
|
|
|
|
/*
|
|
* Class: org_rocksdb_ConcurrentTaskLimiterImpl
|
|
* Method: newConcurrentTaskLimiterImpl0
|
|
* Signature: (Ljava/lang/String;I)J
|
|
*/
|
|
jlong Java_org_rocksdb_ConcurrentTaskLimiterImpl_newConcurrentTaskLimiterImpl0(
|
|
JNIEnv* env, jclass, jstring jname, jint limit) {
|
|
jboolean has_exception = JNI_FALSE;
|
|
std::string name =
|
|
ROCKSDB_NAMESPACE::JniUtil::copyStdString(env, jname, &has_exception);
|
|
if (JNI_TRUE == has_exception) {
|
|
return 0;
|
|
}
|
|
|
|
auto* ptr = new std::shared_ptr<ROCKSDB_NAMESPACE::ConcurrentTaskLimiter>(
|
|
ROCKSDB_NAMESPACE::NewConcurrentTaskLimiter(name, limit));
|
|
|
|
return reinterpret_cast<jlong>(ptr);
|
|
}
|
|
|
|
/*
|
|
* Class: org_rocksdb_ConcurrentTaskLimiterImpl
|
|
* Method: name
|
|
* Signature: (J)Ljava/lang/String;
|
|
*/
|
|
jstring Java_org_rocksdb_ConcurrentTaskLimiterImpl_name(JNIEnv* env, jclass,
|
|
jlong handle) {
|
|
const auto& limiter = *reinterpret_cast<
|
|
std::shared_ptr<ROCKSDB_NAMESPACE::ConcurrentTaskLimiter>*>(handle);
|
|
return ROCKSDB_NAMESPACE::JniUtil::toJavaString(env, &limiter->GetName());
|
|
}
|
|
|
|
/*
|
|
* Class: org_rocksdb_ConcurrentTaskLimiterImpl
|
|
* Method: setMaxOutstandingTask
|
|
* Signature: (JI)V
|
|
*/
|
|
void Java_org_rocksdb_ConcurrentTaskLimiterImpl_setMaxOutstandingTask(
|
|
JNIEnv*, jclass, jlong handle, jint max_outstanding_task) {
|
|
const auto& limiter = *reinterpret_cast<
|
|
std::shared_ptr<ROCKSDB_NAMESPACE::ConcurrentTaskLimiter>*>(handle);
|
|
limiter->SetMaxOutstandingTask(static_cast<int32_t>(max_outstanding_task));
|
|
}
|
|
|
|
/*
|
|
* Class: org_rocksdb_ConcurrentTaskLimiterImpl
|
|
* Method: resetMaxOutstandingTask
|
|
* Signature: (J)V
|
|
*/
|
|
void Java_org_rocksdb_ConcurrentTaskLimiterImpl_resetMaxOutstandingTask(
|
|
JNIEnv*, jclass, jlong handle) {
|
|
const auto& limiter = *reinterpret_cast<
|
|
std::shared_ptr<ROCKSDB_NAMESPACE::ConcurrentTaskLimiter>*>(handle);
|
|
limiter->ResetMaxOutstandingTask();
|
|
}
|
|
|
|
/*
|
|
* Class: org_rocksdb_ConcurrentTaskLimiterImpl
|
|
* Method: outstandingTask
|
|
* Signature: (J)I
|
|
*/
|
|
jint Java_org_rocksdb_ConcurrentTaskLimiterImpl_outstandingTask(JNIEnv*, jclass,
|
|
jlong handle) {
|
|
const auto& limiter = *reinterpret_cast<
|
|
std::shared_ptr<ROCKSDB_NAMESPACE::ConcurrentTaskLimiter>*>(handle);
|
|
return static_cast<jint>(limiter->GetOutstandingTask());
|
|
}
|
|
|
|
/*
|
|
* Class: org_rocksdb_ConcurrentTaskLimiterImpl
|
|
* Method: disposeInternal
|
|
* Signature: (J)V
|
|
*/
|
|
void Java_org_rocksdb_ConcurrentTaskLimiterImpl_disposeInternal(JNIEnv*,
|
|
jobject,
|
|
jlong jhandle) {
|
|
auto* ptr = reinterpret_cast<
|
|
std::shared_ptr<ROCKSDB_NAMESPACE::ConcurrentTaskLimiter>*>(jhandle);
|
|
delete ptr; // delete std::shared_ptr
|
|
}
|