Run format check for *.h and *.cc files under java/ (#10851)

Summary:
Run format check for .h and .cc files to clean the format

Pull Request resolved: https://github.com/facebook/rocksdb/pull/10851

Test Plan: Watch CI tests to pass

Reviewed By: ajkr

Differential Revision: D40649723

fbshipit-source-id: 62d32cead0b3b8e6540e86d25451bd72642109eb
This commit is contained in:
sdong 2022-10-25 09:26:51 -07:00 committed by Facebook GitHub Bot
parent de34e7196f
commit 2a551976f4
52 changed files with 3296 additions and 3245 deletions

View file

@ -24,7 +24,6 @@ jlong Java_org_rocksdb_CompactRangeOptions_newCompactRangeOptions(
return GET_CPLUSPLUS_POINTER(options); return GET_CPLUSPLUS_POINTER(options);
} }
/* /*
* Class: org_rocksdb_CompactRangeOptions * Class: org_rocksdb_CompactRangeOptions
* Method: exclusiveManualCompaction * Method: exclusiveManualCompaction
@ -43,13 +42,14 @@ jboolean Java_org_rocksdb_CompactRangeOptions_exclusiveManualCompaction(
* Signature: (JZ)V * Signature: (JZ)V
*/ */
void Java_org_rocksdb_CompactRangeOptions_setExclusiveManualCompaction( void Java_org_rocksdb_CompactRangeOptions_setExclusiveManualCompaction(
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jboolean exclusive_manual_compaction) { JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jboolean exclusive_manual_compaction) {
auto* options = auto* options =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactRangeOptions*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactRangeOptions*>(jhandle);
options->exclusive_manual_compaction = static_cast<bool>(exclusive_manual_compaction); options->exclusive_manual_compaction =
static_cast<bool>(exclusive_manual_compaction);
} }
/* /*
* Class: org_rocksdb_CompactRangeOptions * Class: org_rocksdb_CompactRangeOptions
* Method: bottommostLevelCompaction * Method: bottommostLevelCompaction
@ -83,8 +83,9 @@ void Java_org_rocksdb_CompactRangeOptions_setBottommostLevelCompaction(
* Method: changeLevel * Method: changeLevel
* Signature: (J)Z * Signature: (J)Z
*/ */
jboolean Java_org_rocksdb_CompactRangeOptions_changeLevel jboolean Java_org_rocksdb_CompactRangeOptions_changeLevel(JNIEnv* /*env*/,
(JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) { jobject /*jobj*/,
jlong jhandle) {
auto* options = auto* options =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactRangeOptions*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactRangeOptions*>(jhandle);
return static_cast<jboolean>(options->change_level); return static_cast<jboolean>(options->change_level);
@ -95,8 +96,8 @@ jboolean Java_org_rocksdb_CompactRangeOptions_changeLevel
* Method: setChangeLevel * Method: setChangeLevel
* Signature: (JZ)V * Signature: (JZ)V
*/ */
void Java_org_rocksdb_CompactRangeOptions_setChangeLevel void Java_org_rocksdb_CompactRangeOptions_setChangeLevel(
(JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jboolean change_level) { JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jboolean change_level) {
auto* options = auto* options =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactRangeOptions*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactRangeOptions*>(jhandle);
options->change_level = static_cast<bool>(change_level); options->change_level = static_cast<bool>(change_level);
@ -107,8 +108,9 @@ void Java_org_rocksdb_CompactRangeOptions_setChangeLevel
* Method: targetLevel * Method: targetLevel
* Signature: (J)I * Signature: (J)I
*/ */
jint Java_org_rocksdb_CompactRangeOptions_targetLevel jint Java_org_rocksdb_CompactRangeOptions_targetLevel(JNIEnv* /*env*/,
(JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) { jobject /*jobj*/,
jlong jhandle) {
auto* options = auto* options =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactRangeOptions*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactRangeOptions*>(jhandle);
return static_cast<jint>(options->target_level); return static_cast<jint>(options->target_level);
@ -119,8 +121,10 @@ jint Java_org_rocksdb_CompactRangeOptions_targetLevel
* Method: setTargetLevel * Method: setTargetLevel
* Signature: (JI)V * Signature: (JI)V
*/ */
void Java_org_rocksdb_CompactRangeOptions_setTargetLevel void Java_org_rocksdb_CompactRangeOptions_setTargetLevel(JNIEnv* /*env*/,
(JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jint target_level) { jobject /*jobj*/,
jlong jhandle,
jint target_level) {
auto* options = auto* options =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactRangeOptions*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactRangeOptions*>(jhandle);
options->target_level = static_cast<int>(target_level); options->target_level = static_cast<int>(target_level);
@ -131,8 +135,9 @@ void Java_org_rocksdb_CompactRangeOptions_setTargetLevel
* Method: targetPathId * Method: targetPathId
* Signature: (J)I * Signature: (J)I
*/ */
jint Java_org_rocksdb_CompactRangeOptions_targetPathId jint Java_org_rocksdb_CompactRangeOptions_targetPathId(JNIEnv* /*env*/,
(JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) { jobject /*jobj*/,
jlong jhandle) {
auto* options = auto* options =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactRangeOptions*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactRangeOptions*>(jhandle);
return static_cast<jint>(options->target_path_id); return static_cast<jint>(options->target_path_id);
@ -143,8 +148,10 @@ jint Java_org_rocksdb_CompactRangeOptions_targetPathId
* Method: setTargetPathId * Method: setTargetPathId
* Signature: (JI)V * Signature: (JI)V
*/ */
void Java_org_rocksdb_CompactRangeOptions_setTargetPathId void Java_org_rocksdb_CompactRangeOptions_setTargetPathId(JNIEnv* /*env*/,
(JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jint target_path_id) { jobject /*jobj*/,
jlong jhandle,
jint target_path_id) {
auto* options = auto* options =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactRangeOptions*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactRangeOptions*>(jhandle);
options->target_path_id = static_cast<uint32_t>(target_path_id); options->target_path_id = static_cast<uint32_t>(target_path_id);
@ -155,8 +162,9 @@ void Java_org_rocksdb_CompactRangeOptions_setTargetPathId
* Method: allowWriteStall * Method: allowWriteStall
* Signature: (J)Z * Signature: (J)Z
*/ */
jboolean Java_org_rocksdb_CompactRangeOptions_allowWriteStall jboolean Java_org_rocksdb_CompactRangeOptions_allowWriteStall(JNIEnv* /*env*/,
(JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) { jobject /*jobj*/,
jlong jhandle) {
auto* options = auto* options =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactRangeOptions*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactRangeOptions*>(jhandle);
return static_cast<jboolean>(options->allow_write_stall); return static_cast<jboolean>(options->allow_write_stall);
@ -167,21 +175,22 @@ jboolean Java_org_rocksdb_CompactRangeOptions_allowWriteStall
* Method: setAllowWriteStall * Method: setAllowWriteStall
* Signature: (JZ)V * Signature: (JZ)V
*/ */
void Java_org_rocksdb_CompactRangeOptions_setAllowWriteStall void Java_org_rocksdb_CompactRangeOptions_setAllowWriteStall(
(JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jboolean allow_write_stall) { JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jboolean allow_write_stall) {
auto* options = auto* options =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactRangeOptions*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactRangeOptions*>(jhandle);
options->allow_write_stall = static_cast<bool>(allow_write_stall); options->allow_write_stall = static_cast<bool>(allow_write_stall);
} }
/* /*
* Class: org_rocksdb_CompactRangeOptions * Class: org_rocksdb_CompactRangeOptions
* Method: maxSubcompactions * Method: maxSubcompactions
* Signature: (J)I * Signature: (J)I
*/ */
jint Java_org_rocksdb_CompactRangeOptions_maxSubcompactions jint Java_org_rocksdb_CompactRangeOptions_maxSubcompactions(JNIEnv* /*env*/,
(JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) { jobject /*jobj*/,
jlong jhandle) {
auto* options = auto* options =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactRangeOptions*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactRangeOptions*>(jhandle);
return static_cast<jint>(options->max_subcompactions); return static_cast<jint>(options->max_subcompactions);
@ -192,8 +201,8 @@ jint Java_org_rocksdb_CompactRangeOptions_maxSubcompactions
* Method: setMaxSubcompactions * Method: setMaxSubcompactions
* Signature: (JI)V * Signature: (JI)V
*/ */
void Java_org_rocksdb_CompactRangeOptions_setMaxSubcompactions void Java_org_rocksdb_CompactRangeOptions_setMaxSubcompactions(
(JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jint max_subcompactions) { JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jint max_subcompactions) {
auto* options = auto* options =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactRangeOptions*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactRangeOptions*>(jhandle);
options->max_subcompactions = static_cast<uint32_t>(max_subcompactions); options->max_subcompactions = static_cast<uint32_t>(max_subcompactions);
@ -204,8 +213,9 @@ void Java_org_rocksdb_CompactRangeOptions_setMaxSubcompactions
* Method: disposeInternal * Method: disposeInternal
* Signature: (J)V * Signature: (J)V
*/ */
void Java_org_rocksdb_CompactRangeOptions_disposeInternal( void Java_org_rocksdb_CompactRangeOptions_disposeInternal(JNIEnv* /*env*/,
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) { jobject /*jobj*/,
jlong jhandle) {
auto* options = auto* options =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactRangeOptions*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactRangeOptions*>(jhandle);
delete options; delete options;

View file

@ -6,10 +6,11 @@
// This file implements the "bridge" between Java and C++ for // This file implements the "bridge" between Java and C++ for
// ROCKSDB_NAMESPACE::CompactionFilter. // ROCKSDB_NAMESPACE::CompactionFilter.
#include "rocksdb/compaction_filter.h"
#include <jni.h> #include <jni.h>
#include "include/org_rocksdb_AbstractCompactionFilter.h" #include "include/org_rocksdb_AbstractCompactionFilter.h"
#include "rocksdb/compaction_filter.h"
// <editor-fold desc="org.rocksdb.AbstractCompactionFilter"> // <editor-fold desc="org.rocksdb.AbstractCompactionFilter">

View file

@ -7,13 +7,13 @@
// ROCKSDB_NAMESPACE::CompactionFilterFactory. // ROCKSDB_NAMESPACE::CompactionFilterFactory.
#include "rocksjni/compaction_filter_factory_jnicallback.h" #include "rocksjni/compaction_filter_factory_jnicallback.h"
#include "rocksjni/portal.h" #include "rocksjni/portal.h"
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
CompactionFilterFactoryJniCallback::CompactionFilterFactoryJniCallback( CompactionFilterFactoryJniCallback::CompactionFilterFactoryJniCallback(
JNIEnv* env, jobject jcompaction_filter_factory) JNIEnv* env, jobject jcompaction_filter_factory)
: JniCallback(env, jcompaction_filter_factory) { : JniCallback(env, jcompaction_filter_factory) {
// Note: The name of a CompactionFilterFactory will not change during // Note: The name of a CompactionFilterFactory will not change during
// it's lifetime, so we cache it in a global var // it's lifetime, so we cache it in a global var
jmethodID jname_method_id = jmethodID jname_method_id =
@ -30,14 +30,16 @@ CompactionFilterFactoryJniCallback::CompactionFilterFactoryJniCallback(
return; return;
} }
jboolean has_exception = JNI_FALSE; jboolean has_exception = JNI_FALSE;
m_name = JniUtil::copyString(env, jname, &has_exception); // also releases jname m_name =
JniUtil::copyString(env, jname, &has_exception); // also releases jname
if (has_exception == JNI_TRUE) { if (has_exception == JNI_TRUE) {
// exception thrown // exception thrown
return; return;
} }
m_jcreate_compaction_filter_methodid = m_jcreate_compaction_filter_methodid =
AbstractCompactionFilterFactoryJni::getCreateCompactionFilterMethodId(env); AbstractCompactionFilterFactoryJni::getCreateCompactionFilterMethodId(
env);
if (m_jcreate_compaction_filter_methodid == nullptr) { if (m_jcreate_compaction_filter_methodid == nullptr) {
// exception thrown: NoSuchMethodException or OutOfMemoryError // exception thrown: NoSuchMethodException or OutOfMemoryError
return; return;
@ -48,14 +50,15 @@ const char* CompactionFilterFactoryJniCallback::Name() const {
return m_name.get(); return m_name.get();
} }
std::unique_ptr<CompactionFilter> CompactionFilterFactoryJniCallback::CreateCompactionFilter( std::unique_ptr<CompactionFilter>
CompactionFilterFactoryJniCallback::CreateCompactionFilter(
const CompactionFilter::Context& context) { const CompactionFilter::Context& context) {
jboolean attached_thread = JNI_FALSE; jboolean attached_thread = JNI_FALSE;
JNIEnv* env = getJniEnv(&attached_thread); JNIEnv* env = getJniEnv(&attached_thread);
assert(env != nullptr); assert(env != nullptr);
jlong addr_compaction_filter = env->CallLongMethod(m_jcallback_obj, jlong addr_compaction_filter =
m_jcreate_compaction_filter_methodid, env->CallLongMethod(m_jcallback_obj, m_jcreate_compaction_filter_methodid,
static_cast<jboolean>(context.is_full_compaction), static_cast<jboolean>(context.is_full_compaction),
static_cast<jboolean>(context.is_manual_compaction)); static_cast<jboolean>(context.is_manual_compaction));

View file

@ -10,6 +10,7 @@
#define JAVA_ROCKSJNI_COMPACTION_FILTER_FACTORY_JNICALLBACK_H_ #define JAVA_ROCKSJNI_COMPACTION_FILTER_FACTORY_JNICALLBACK_H_
#include <jni.h> #include <jni.h>
#include <memory> #include <memory>
#include "rocksdb/compaction_filter.h" #include "rocksdb/compaction_filter.h"
@ -17,10 +18,11 @@
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
class CompactionFilterFactoryJniCallback : public JniCallback, public CompactionFilterFactory { class CompactionFilterFactoryJniCallback : public JniCallback,
public CompactionFilterFactory {
public: public:
CompactionFilterFactoryJniCallback( CompactionFilterFactoryJniCallback(JNIEnv* env,
JNIEnv* env, jobject jcompaction_filter_factory); jobject jcompaction_filter_factory);
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter( virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& context); const CompactionFilter::Context& context);
virtual const char* Name() const; virtual const char* Name() const;

View file

@ -18,8 +18,7 @@
* Method: newCompactionJobInfo * Method: newCompactionJobInfo
* Signature: ()J * Signature: ()J
*/ */
jlong Java_org_rocksdb_CompactionJobInfo_newCompactionJobInfo( jlong Java_org_rocksdb_CompactionJobInfo_newCompactionJobInfo(JNIEnv*, jclass) {
JNIEnv*, jclass) {
auto* compact_job_info = new ROCKSDB_NAMESPACE::CompactionJobInfo(); auto* compact_job_info = new ROCKSDB_NAMESPACE::CompactionJobInfo();
return GET_CPLUSPLUS_POINTER(compact_job_info); return GET_CPLUSPLUS_POINTER(compact_job_info);
} }
@ -29,8 +28,8 @@ jlong Java_org_rocksdb_CompactionJobInfo_newCompactionJobInfo(
* Method: disposeInternal * Method: disposeInternal
* Signature: (J)V * Signature: (J)V
*/ */
void Java_org_rocksdb_CompactionJobInfo_disposeInternal( void Java_org_rocksdb_CompactionJobInfo_disposeInternal(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
auto* compact_job_info = auto* compact_job_info =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle);
delete compact_job_info; delete compact_job_info;
@ -41,8 +40,9 @@ void Java_org_rocksdb_CompactionJobInfo_disposeInternal(
* Method: columnFamilyName * Method: columnFamilyName
* Signature: (J)[B * Signature: (J)[B
*/ */
jbyteArray Java_org_rocksdb_CompactionJobInfo_columnFamilyName( jbyteArray Java_org_rocksdb_CompactionJobInfo_columnFamilyName(JNIEnv* env,
JNIEnv* env, jclass, jlong jhandle) { jclass,
jlong jhandle) {
auto* compact_job_info = auto* compact_job_info =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle);
return ROCKSDB_NAMESPACE::JniUtil::copyBytes(env, compact_job_info->cf_name); return ROCKSDB_NAMESPACE::JniUtil::copyBytes(env, compact_job_info->cf_name);
@ -53,8 +53,8 @@ jbyteArray Java_org_rocksdb_CompactionJobInfo_columnFamilyName(
* Method: status * Method: status
* Signature: (J)Lorg/rocksdb/Status; * Signature: (J)Lorg/rocksdb/Status;
*/ */
jobject Java_org_rocksdb_CompactionJobInfo_status( jobject Java_org_rocksdb_CompactionJobInfo_status(JNIEnv* env, jclass,
JNIEnv* env, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_job_info = auto* compact_job_info =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle);
return ROCKSDB_NAMESPACE::StatusJni::construct(env, compact_job_info->status); return ROCKSDB_NAMESPACE::StatusJni::construct(env, compact_job_info->status);
@ -65,8 +65,8 @@ jobject Java_org_rocksdb_CompactionJobInfo_status(
* Method: threadId * Method: threadId
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_CompactionJobInfo_threadId( jlong Java_org_rocksdb_CompactionJobInfo_threadId(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_job_info = auto* compact_job_info =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle);
return static_cast<jlong>(compact_job_info->thread_id); return static_cast<jlong>(compact_job_info->thread_id);
@ -77,8 +77,7 @@ jlong Java_org_rocksdb_CompactionJobInfo_threadId(
* Method: jobId * Method: jobId
* Signature: (J)I * Signature: (J)I
*/ */
jint Java_org_rocksdb_CompactionJobInfo_jobId( jint Java_org_rocksdb_CompactionJobInfo_jobId(JNIEnv*, jclass, jlong jhandle) {
JNIEnv*, jclass, jlong jhandle) {
auto* compact_job_info = auto* compact_job_info =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle);
return static_cast<jint>(compact_job_info->job_id); return static_cast<jint>(compact_job_info->job_id);
@ -89,8 +88,8 @@ jint Java_org_rocksdb_CompactionJobInfo_jobId(
* Method: baseInputLevel * Method: baseInputLevel
* Signature: (J)I * Signature: (J)I
*/ */
jint Java_org_rocksdb_CompactionJobInfo_baseInputLevel( jint Java_org_rocksdb_CompactionJobInfo_baseInputLevel(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_job_info = auto* compact_job_info =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle);
return static_cast<jint>(compact_job_info->base_input_level); return static_cast<jint>(compact_job_info->base_input_level);
@ -101,8 +100,8 @@ jint Java_org_rocksdb_CompactionJobInfo_baseInputLevel(
* Method: outputLevel * Method: outputLevel
* Signature: (J)I * Signature: (J)I
*/ */
jint Java_org_rocksdb_CompactionJobInfo_outputLevel( jint Java_org_rocksdb_CompactionJobInfo_outputLevel(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_job_info = auto* compact_job_info =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle);
return static_cast<jint>(compact_job_info->output_level); return static_cast<jint>(compact_job_info->output_level);
@ -113,8 +112,8 @@ jint Java_org_rocksdb_CompactionJobInfo_outputLevel(
* Method: inputFiles * Method: inputFiles
* Signature: (J)[Ljava/lang/String; * Signature: (J)[Ljava/lang/String;
*/ */
jobjectArray Java_org_rocksdb_CompactionJobInfo_inputFiles( jobjectArray Java_org_rocksdb_CompactionJobInfo_inputFiles(JNIEnv* env, jclass,
JNIEnv* env, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_job_info = auto* compact_job_info =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle);
return ROCKSDB_NAMESPACE::JniUtil::toJavaStrings( return ROCKSDB_NAMESPACE::JniUtil::toJavaStrings(
@ -126,8 +125,8 @@ jobjectArray Java_org_rocksdb_CompactionJobInfo_inputFiles(
* Method: outputFiles * Method: outputFiles
* Signature: (J)[Ljava/lang/String; * Signature: (J)[Ljava/lang/String;
*/ */
jobjectArray Java_org_rocksdb_CompactionJobInfo_outputFiles( jobjectArray Java_org_rocksdb_CompactionJobInfo_outputFiles(JNIEnv* env, jclass,
JNIEnv* env, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_job_info = auto* compact_job_info =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle);
return ROCKSDB_NAMESPACE::JniUtil::toJavaStrings( return ROCKSDB_NAMESPACE::JniUtil::toJavaStrings(
@ -139,8 +138,8 @@ jobjectArray Java_org_rocksdb_CompactionJobInfo_outputFiles(
* Method: tableProperties * Method: tableProperties
* Signature: (J)Ljava/util/Map; * Signature: (J)Ljava/util/Map;
*/ */
jobject Java_org_rocksdb_CompactionJobInfo_tableProperties( jobject Java_org_rocksdb_CompactionJobInfo_tableProperties(JNIEnv* env, jclass,
JNIEnv* env, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_job_info = auto* compact_job_info =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle);
auto* map = &compact_job_info->table_properties; auto* map = &compact_job_info->table_properties;
@ -196,8 +195,8 @@ jobject Java_org_rocksdb_CompactionJobInfo_tableProperties(
* Method: compactionReason * Method: compactionReason
* Signature: (J)B * Signature: (J)B
*/ */
jbyte Java_org_rocksdb_CompactionJobInfo_compactionReason( jbyte Java_org_rocksdb_CompactionJobInfo_compactionReason(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_job_info = auto* compact_job_info =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle);
return ROCKSDB_NAMESPACE::CompactionReasonJni::toJavaCompactionReason( return ROCKSDB_NAMESPACE::CompactionReasonJni::toJavaCompactionReason(
@ -209,8 +208,8 @@ jbyte Java_org_rocksdb_CompactionJobInfo_compactionReason(
* Method: compression * Method: compression
* Signature: (J)B * Signature: (J)B
*/ */
jbyte Java_org_rocksdb_CompactionJobInfo_compression( jbyte Java_org_rocksdb_CompactionJobInfo_compression(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_job_info = auto* compact_job_info =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle);
return ROCKSDB_NAMESPACE::CompressionTypeJni::toJavaCompressionType( return ROCKSDB_NAMESPACE::CompressionTypeJni::toJavaCompressionType(
@ -222,8 +221,7 @@ jbyte Java_org_rocksdb_CompactionJobInfo_compression(
* Method: stats * Method: stats
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_CompactionJobInfo_stats( jlong Java_org_rocksdb_CompactionJobInfo_stats(JNIEnv*, jclass, jlong jhandle) {
JNIEnv *, jclass, jlong jhandle) {
auto* compact_job_info = auto* compact_job_info =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle);
auto* stats = new ROCKSDB_NAMESPACE::CompactionJobStats(); auto* stats = new ROCKSDB_NAMESPACE::CompactionJobStats();

View file

@ -19,8 +19,8 @@
* Method: newCompactionJobStats * Method: newCompactionJobStats
* Signature: ()J * Signature: ()J
*/ */
jlong Java_org_rocksdb_CompactionJobStats_newCompactionJobStats( jlong Java_org_rocksdb_CompactionJobStats_newCompactionJobStats(JNIEnv*,
JNIEnv*, jclass) { jclass) {
auto* compact_job_stats = new ROCKSDB_NAMESPACE::CompactionJobStats(); auto* compact_job_stats = new ROCKSDB_NAMESPACE::CompactionJobStats();
return GET_CPLUSPLUS_POINTER(compact_job_stats); return GET_CPLUSPLUS_POINTER(compact_job_stats);
} }
@ -30,8 +30,8 @@ jlong Java_org_rocksdb_CompactionJobStats_newCompactionJobStats(
* Method: disposeInternal * Method: disposeInternal
* Signature: (J)V * Signature: (J)V
*/ */
void Java_org_rocksdb_CompactionJobStats_disposeInternal( void Java_org_rocksdb_CompactionJobStats_disposeInternal(JNIEnv*, jobject,
JNIEnv *, jobject, jlong jhandle) { jlong jhandle) {
auto* compact_job_stats = auto* compact_job_stats =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle);
delete compact_job_stats; delete compact_job_stats;
@ -42,8 +42,7 @@ void Java_org_rocksdb_CompactionJobStats_disposeInternal(
* Method: reset * Method: reset
* Signature: (J)V * Signature: (J)V
*/ */
void Java_org_rocksdb_CompactionJobStats_reset( void Java_org_rocksdb_CompactionJobStats_reset(JNIEnv*, jclass, jlong jhandle) {
JNIEnv*, jclass, jlong jhandle) {
auto* compact_job_stats = auto* compact_job_stats =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle);
compact_job_stats->Reset(); compact_job_stats->Reset();
@ -54,8 +53,8 @@ void Java_org_rocksdb_CompactionJobStats_reset(
* Method: add * Method: add
* Signature: (JJ)V * Signature: (JJ)V
*/ */
void Java_org_rocksdb_CompactionJobStats_add( void Java_org_rocksdb_CompactionJobStats_add(JNIEnv*, jclass, jlong jhandle,
JNIEnv*, jclass, jlong jhandle, jlong jother_handle) { jlong jother_handle) {
auto* compact_job_stats = auto* compact_job_stats =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle);
auto* other_compact_job_stats = auto* other_compact_job_stats =
@ -68,8 +67,8 @@ void Java_org_rocksdb_CompactionJobStats_add(
* Method: elapsedMicros * Method: elapsedMicros
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_CompactionJobStats_elapsedMicros( jlong Java_org_rocksdb_CompactionJobStats_elapsedMicros(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_job_stats = auto* compact_job_stats =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle);
return static_cast<jlong>(compact_job_stats->elapsed_micros); return static_cast<jlong>(compact_job_stats->elapsed_micros);
@ -80,8 +79,8 @@ jlong Java_org_rocksdb_CompactionJobStats_elapsedMicros(
* Method: numInputRecords * Method: numInputRecords
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_CompactionJobStats_numInputRecords( jlong Java_org_rocksdb_CompactionJobStats_numInputRecords(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_job_stats = auto* compact_job_stats =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle);
return static_cast<jlong>(compact_job_stats->num_input_records); return static_cast<jlong>(compact_job_stats->num_input_records);
@ -92,8 +91,8 @@ jlong Java_org_rocksdb_CompactionJobStats_numInputRecords(
* Method: numInputFiles * Method: numInputFiles
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_CompactionJobStats_numInputFiles( jlong Java_org_rocksdb_CompactionJobStats_numInputFiles(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_job_stats = auto* compact_job_stats =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle);
return static_cast<jlong>(compact_job_stats->num_input_files); return static_cast<jlong>(compact_job_stats->num_input_files);
@ -108,8 +107,7 @@ jlong Java_org_rocksdb_CompactionJobStats_numInputFilesAtOutputLevel(
JNIEnv*, jclass, jlong jhandle) { JNIEnv*, jclass, jlong jhandle) {
auto* compact_job_stats = auto* compact_job_stats =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle);
return static_cast<jlong>( return static_cast<jlong>(compact_job_stats->num_input_files_at_output_level);
compact_job_stats->num_input_files_at_output_level);
} }
/* /*
@ -117,12 +115,11 @@ jlong Java_org_rocksdb_CompactionJobStats_numInputFilesAtOutputLevel(
* Method: numOutputRecords * Method: numOutputRecords
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_CompactionJobStats_numOutputRecords( jlong Java_org_rocksdb_CompactionJobStats_numOutputRecords(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_job_stats = auto* compact_job_stats =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle);
return static_cast<jlong>( return static_cast<jlong>(compact_job_stats->num_output_records);
compact_job_stats->num_output_records);
} }
/* /*
@ -130,12 +127,11 @@ jlong Java_org_rocksdb_CompactionJobStats_numOutputRecords(
* Method: numOutputFiles * Method: numOutputFiles
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_CompactionJobStats_numOutputFiles( jlong Java_org_rocksdb_CompactionJobStats_numOutputFiles(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_job_stats = auto* compact_job_stats =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle);
return static_cast<jlong>( return static_cast<jlong>(compact_job_stats->num_output_files);
compact_job_stats->num_output_files);
} }
/* /*
@ -143,8 +139,8 @@ jlong Java_org_rocksdb_CompactionJobStats_numOutputFiles(
* Method: isManualCompaction * Method: isManualCompaction
* Signature: (J)Z * Signature: (J)Z
*/ */
jboolean Java_org_rocksdb_CompactionJobStats_isManualCompaction( jboolean Java_org_rocksdb_CompactionJobStats_isManualCompaction(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_job_stats = auto* compact_job_stats =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle);
if (compact_job_stats->is_manual_compaction) { if (compact_job_stats->is_manual_compaction) {
@ -159,12 +155,11 @@ jboolean Java_org_rocksdb_CompactionJobStats_isManualCompaction(
* Method: totalInputBytes * Method: totalInputBytes
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_CompactionJobStats_totalInputBytes( jlong Java_org_rocksdb_CompactionJobStats_totalInputBytes(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_job_stats = auto* compact_job_stats =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle);
return static_cast<jlong>( return static_cast<jlong>(compact_job_stats->total_input_bytes);
compact_job_stats->total_input_bytes);
} }
/* /*
@ -172,12 +167,11 @@ jlong Java_org_rocksdb_CompactionJobStats_totalInputBytes(
* Method: totalOutputBytes * Method: totalOutputBytes
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_CompactionJobStats_totalOutputBytes( jlong Java_org_rocksdb_CompactionJobStats_totalOutputBytes(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_job_stats = auto* compact_job_stats =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle);
return static_cast<jlong>( return static_cast<jlong>(compact_job_stats->total_output_bytes);
compact_job_stats->total_output_bytes);
} }
/* /*
@ -185,12 +179,11 @@ jlong Java_org_rocksdb_CompactionJobStats_totalOutputBytes(
* Method: numRecordsReplaced * Method: numRecordsReplaced
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_CompactionJobStats_numRecordsReplaced( jlong Java_org_rocksdb_CompactionJobStats_numRecordsReplaced(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_job_stats = auto* compact_job_stats =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle);
return static_cast<jlong>( return static_cast<jlong>(compact_job_stats->num_records_replaced);
compact_job_stats->num_records_replaced);
} }
/* /*
@ -198,12 +191,11 @@ jlong Java_org_rocksdb_CompactionJobStats_numRecordsReplaced(
* Method: totalInputRawKeyBytes * Method: totalInputRawKeyBytes
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_CompactionJobStats_totalInputRawKeyBytes( jlong Java_org_rocksdb_CompactionJobStats_totalInputRawKeyBytes(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_job_stats = auto* compact_job_stats =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle);
return static_cast<jlong>( return static_cast<jlong>(compact_job_stats->total_input_raw_key_bytes);
compact_job_stats->total_input_raw_key_bytes);
} }
/* /*
@ -215,8 +207,7 @@ jlong Java_org_rocksdb_CompactionJobStats_totalInputRawValueBytes(
JNIEnv*, jclass, jlong jhandle) { JNIEnv*, jclass, jlong jhandle) {
auto* compact_job_stats = auto* compact_job_stats =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle);
return static_cast<jlong>( return static_cast<jlong>(compact_job_stats->total_input_raw_value_bytes);
compact_job_stats->total_input_raw_value_bytes);
} }
/* /*
@ -228,8 +219,7 @@ jlong Java_org_rocksdb_CompactionJobStats_numInputDeletionRecords(
JNIEnv*, jclass, jlong jhandle) { JNIEnv*, jclass, jlong jhandle) {
auto* compact_job_stats = auto* compact_job_stats =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle);
return static_cast<jlong>( return static_cast<jlong>(compact_job_stats->num_input_deletion_records);
compact_job_stats->num_input_deletion_records);
} }
/* /*
@ -241,8 +231,7 @@ jlong Java_org_rocksdb_CompactionJobStats_numExpiredDeletionRecords(
JNIEnv*, jclass, jlong jhandle) { JNIEnv*, jclass, jlong jhandle) {
auto* compact_job_stats = auto* compact_job_stats =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle);
return static_cast<jlong>( return static_cast<jlong>(compact_job_stats->num_expired_deletion_records);
compact_job_stats->num_expired_deletion_records);
} }
/* /*
@ -250,12 +239,11 @@ jlong Java_org_rocksdb_CompactionJobStats_numExpiredDeletionRecords(
* Method: numCorruptKeys * Method: numCorruptKeys
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_CompactionJobStats_numCorruptKeys( jlong Java_org_rocksdb_CompactionJobStats_numCorruptKeys(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_job_stats = auto* compact_job_stats =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle);
return static_cast<jlong>( return static_cast<jlong>(compact_job_stats->num_corrupt_keys);
compact_job_stats->num_corrupt_keys);
} }
/* /*
@ -263,12 +251,11 @@ jlong Java_org_rocksdb_CompactionJobStats_numCorruptKeys(
* Method: fileWriteNanos * Method: fileWriteNanos
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_CompactionJobStats_fileWriteNanos( jlong Java_org_rocksdb_CompactionJobStats_fileWriteNanos(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_job_stats = auto* compact_job_stats =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle);
return static_cast<jlong>( return static_cast<jlong>(compact_job_stats->file_write_nanos);
compact_job_stats->file_write_nanos);
} }
/* /*
@ -276,12 +263,11 @@ jlong Java_org_rocksdb_CompactionJobStats_fileWriteNanos(
* Method: fileRangeSyncNanos * Method: fileRangeSyncNanos
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_CompactionJobStats_fileRangeSyncNanos( jlong Java_org_rocksdb_CompactionJobStats_fileRangeSyncNanos(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_job_stats = auto* compact_job_stats =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle);
return static_cast<jlong>( return static_cast<jlong>(compact_job_stats->file_range_sync_nanos);
compact_job_stats->file_range_sync_nanos);
} }
/* /*
@ -289,12 +275,11 @@ jlong Java_org_rocksdb_CompactionJobStats_fileRangeSyncNanos(
* Method: fileFsyncNanos * Method: fileFsyncNanos
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_CompactionJobStats_fileFsyncNanos( jlong Java_org_rocksdb_CompactionJobStats_fileFsyncNanos(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_job_stats = auto* compact_job_stats =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle);
return static_cast<jlong>( return static_cast<jlong>(compact_job_stats->file_fsync_nanos);
compact_job_stats->file_fsync_nanos);
} }
/* /*
@ -302,12 +287,11 @@ jlong Java_org_rocksdb_CompactionJobStats_fileFsyncNanos(
* Method: filePrepareWriteNanos * Method: filePrepareWriteNanos
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_CompactionJobStats_filePrepareWriteNanos( jlong Java_org_rocksdb_CompactionJobStats_filePrepareWriteNanos(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_job_stats = auto* compact_job_stats =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle);
return static_cast<jlong>( return static_cast<jlong>(compact_job_stats->file_prepare_write_nanos);
compact_job_stats->file_prepare_write_nanos);
} }
/* /*
@ -341,12 +325,11 @@ jbyteArray Java_org_rocksdb_CompactionJobStats_largestOutputKeyPrefix(
* Method: numSingleDelFallthru * Method: numSingleDelFallthru
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_CompactionJobStats_numSingleDelFallthru( jlong Java_org_rocksdb_CompactionJobStats_numSingleDelFallthru(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_job_stats = auto* compact_job_stats =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle);
return static_cast<jlong>( return static_cast<jlong>(compact_job_stats->num_single_del_fallthru);
compact_job_stats->num_single_del_fallthru);
} }
/* /*
@ -354,10 +337,9 @@ jlong Java_org_rocksdb_CompactionJobStats_numSingleDelFallthru(
* Method: numSingleDelMismatch * Method: numSingleDelMismatch
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_CompactionJobStats_numSingleDelMismatch( jlong Java_org_rocksdb_CompactionJobStats_numSingleDelMismatch(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_job_stats = auto* compact_job_stats =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobStats*>(jhandle);
return static_cast<jlong>( return static_cast<jlong>(compact_job_stats->num_single_del_mismatch);
compact_job_stats->num_single_del_mismatch);
} }

View file

@ -18,8 +18,7 @@
* Method: newCompactionOptions * Method: newCompactionOptions
* Signature: ()J * Signature: ()J
*/ */
jlong Java_org_rocksdb_CompactionOptions_newCompactionOptions( jlong Java_org_rocksdb_CompactionOptions_newCompactionOptions(JNIEnv*, jclass) {
JNIEnv*, jclass) {
auto* compact_opts = new ROCKSDB_NAMESPACE::CompactionOptions(); auto* compact_opts = new ROCKSDB_NAMESPACE::CompactionOptions();
return GET_CPLUSPLUS_POINTER(compact_opts); return GET_CPLUSPLUS_POINTER(compact_opts);
} }
@ -29,8 +28,8 @@ jlong Java_org_rocksdb_CompactionOptions_newCompactionOptions(
* Method: disposeInternal * Method: disposeInternal
* Signature: (J)V * Signature: (J)V
*/ */
void Java_org_rocksdb_CompactionOptions_disposeInternal( void Java_org_rocksdb_CompactionOptions_disposeInternal(JNIEnv*, jobject,
JNIEnv *, jobject, jlong jhandle) { jlong jhandle) {
auto* compact_opts = auto* compact_opts =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionOptions*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionOptions*>(jhandle);
delete compact_opts; delete compact_opts;
@ -41,8 +40,8 @@ void Java_org_rocksdb_CompactionOptions_disposeInternal(
* Method: compression * Method: compression
* Signature: (J)B * Signature: (J)B
*/ */
jbyte Java_org_rocksdb_CompactionOptions_compression( jbyte Java_org_rocksdb_CompactionOptions_compression(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_opts = auto* compact_opts =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionOptions*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionOptions*>(jhandle);
return ROCKSDB_NAMESPACE::CompressionTypeJni::toJavaCompressionType( return ROCKSDB_NAMESPACE::CompressionTypeJni::toJavaCompressionType(
@ -68,12 +67,11 @@ void Java_org_rocksdb_CompactionOptions_setCompression(
* Method: outputFileSizeLimit * Method: outputFileSizeLimit
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_CompactionOptions_outputFileSizeLimit( jlong Java_org_rocksdb_CompactionOptions_outputFileSizeLimit(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_opts = auto* compact_opts =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionOptions*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionOptions*>(jhandle);
return static_cast<jlong>( return static_cast<jlong>(compact_opts->output_file_size_limit);
compact_opts->output_file_size_limit);
} }
/* /*
@ -94,12 +92,11 @@ void Java_org_rocksdb_CompactionOptions_setOutputFileSizeLimit(
* Method: maxSubcompactions * Method: maxSubcompactions
* Signature: (J)I * Signature: (J)I
*/ */
jint Java_org_rocksdb_CompactionOptions_maxSubcompactions( jint Java_org_rocksdb_CompactionOptions_maxSubcompactions(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jhandle) { jlong jhandle) {
auto* compact_opts = auto* compact_opts =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionOptions*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionOptions*>(jhandle);
return static_cast<jint>( return static_cast<jint>(compact_opts->max_subcompactions);
compact_opts->max_subcompactions);
} }
/* /*
@ -111,6 +108,5 @@ void Java_org_rocksdb_CompactionOptions_setMaxSubcompactions(
JNIEnv*, jclass, jlong jhandle, jint jmax_subcompactions) { JNIEnv*, jclass, jlong jhandle, jint jmax_subcompactions) {
auto* compact_opts = auto* compact_opts =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionOptions*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionOptions*>(jhandle);
compact_opts->max_subcompactions = compact_opts->max_subcompactions = static_cast<uint32_t>(jmax_subcompactions);
static_cast<uint32_t>(jmax_subcompactions);
} }

View file

@ -17,8 +17,8 @@
* Method: newCompactionOptionsFIFO * Method: newCompactionOptionsFIFO
* Signature: ()J * Signature: ()J
*/ */
jlong Java_org_rocksdb_CompactionOptionsFIFO_newCompactionOptionsFIFO( jlong Java_org_rocksdb_CompactionOptionsFIFO_newCompactionOptionsFIFO(JNIEnv*,
JNIEnv*, jclass) { jclass) {
const auto* opt = new ROCKSDB_NAMESPACE::CompactionOptionsFIFO(); const auto* opt = new ROCKSDB_NAMESPACE::CompactionOptionsFIFO();
return GET_CPLUSPLUS_POINTER(opt); return GET_CPLUSPLUS_POINTER(opt);
} }
@ -40,8 +40,8 @@ void Java_org_rocksdb_CompactionOptionsFIFO_setMaxTableFilesSize(
* Method: maxTableFilesSize * Method: maxTableFilesSize
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_CompactionOptionsFIFO_maxTableFilesSize( jlong Java_org_rocksdb_CompactionOptionsFIFO_maxTableFilesSize(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
auto* opt = auto* opt =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionOptionsFIFO*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionOptionsFIFO*>(jhandle);
return static_cast<jlong>(opt->max_table_files_size); return static_cast<jlong>(opt->max_table_files_size);
@ -64,8 +64,9 @@ void Java_org_rocksdb_CompactionOptionsFIFO_setAllowCompaction(
* Method: allowCompaction * Method: allowCompaction
* Signature: (J)Z * Signature: (J)Z
*/ */
jboolean Java_org_rocksdb_CompactionOptionsFIFO_allowCompaction( jboolean Java_org_rocksdb_CompactionOptionsFIFO_allowCompaction(JNIEnv*,
JNIEnv*, jobject, jlong jhandle) { jobject,
jlong jhandle) {
auto* opt = auto* opt =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionOptionsFIFO*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionOptionsFIFO*>(jhandle);
return static_cast<jboolean>(opt->allow_compaction); return static_cast<jboolean>(opt->allow_compaction);
@ -76,7 +77,7 @@ jboolean Java_org_rocksdb_CompactionOptionsFIFO_allowCompaction(
* Method: disposeInternal * Method: disposeInternal
* Signature: (J)V * Signature: (J)V
*/ */
void Java_org_rocksdb_CompactionOptionsFIFO_disposeInternal( void Java_org_rocksdb_CompactionOptionsFIFO_disposeInternal(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
delete reinterpret_cast<ROCKSDB_NAMESPACE::CompactionOptionsFIFO*>(jhandle); delete reinterpret_cast<ROCKSDB_NAMESPACE::CompactionOptionsFIFO*>(jhandle);
} }

View file

@ -41,8 +41,8 @@ void Java_org_rocksdb_CompactionOptionsUniversal_setSizeRatio(
* Method: sizeRatio * Method: sizeRatio
* Signature: (J)I * Signature: (J)I
*/ */
jint Java_org_rocksdb_CompactionOptionsUniversal_sizeRatio( jint Java_org_rocksdb_CompactionOptionsUniversal_sizeRatio(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
auto* opt = auto* opt =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionOptionsUniversal*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionOptionsUniversal*>(jhandle);
return static_cast<jint>(opt->size_ratio); return static_cast<jint>(opt->size_ratio);
@ -65,8 +65,8 @@ void Java_org_rocksdb_CompactionOptionsUniversal_setMinMergeWidth(
* Method: minMergeWidth * Method: minMergeWidth
* Signature: (J)I * Signature: (J)I
*/ */
jint Java_org_rocksdb_CompactionOptionsUniversal_minMergeWidth( jint Java_org_rocksdb_CompactionOptionsUniversal_minMergeWidth(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
auto* opt = auto* opt =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionOptionsUniversal*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionOptionsUniversal*>(jhandle);
return static_cast<jint>(opt->min_merge_width); return static_cast<jint>(opt->min_merge_width);
@ -89,8 +89,8 @@ void Java_org_rocksdb_CompactionOptionsUniversal_setMaxMergeWidth(
* Method: maxMergeWidth * Method: maxMergeWidth
* Signature: (J)I * Signature: (J)I
*/ */
jint Java_org_rocksdb_CompactionOptionsUniversal_maxMergeWidth( jint Java_org_rocksdb_CompactionOptionsUniversal_maxMergeWidth(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
auto* opt = auto* opt =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionOptionsUniversal*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionOptionsUniversal*>(jhandle);
return static_cast<jint>(opt->max_merge_width); return static_cast<jint>(opt->max_merge_width);
@ -127,8 +127,7 @@ jint Java_org_rocksdb_CompactionOptionsUniversal_maxSizeAmplificationPercent(
* Signature: (JI)V * Signature: (JI)V
*/ */
void Java_org_rocksdb_CompactionOptionsUniversal_setCompressionSizePercent( void Java_org_rocksdb_CompactionOptionsUniversal_setCompressionSizePercent(
JNIEnv*, jobject, jlong jhandle, JNIEnv*, jobject, jlong jhandle, jint jcompression_size_percent) {
jint jcompression_size_percent) {
auto* opt = auto* opt =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionOptionsUniversal*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionOptionsUniversal*>(jhandle);
opt->compression_size_percent = opt->compression_size_percent =
@ -166,8 +165,8 @@ void Java_org_rocksdb_CompactionOptionsUniversal_setStopStyle(
* Method: stopStyle * Method: stopStyle
* Signature: (J)B * Signature: (J)B
*/ */
jbyte Java_org_rocksdb_CompactionOptionsUniversal_stopStyle( jbyte Java_org_rocksdb_CompactionOptionsUniversal_stopStyle(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
auto* opt = auto* opt =
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionOptionsUniversal*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::CompactionOptionsUniversal*>(jhandle);
return ROCKSDB_NAMESPACE::CompactionStopStyleJni::toJavaCompactionStopStyle( return ROCKSDB_NAMESPACE::CompactionStopStyleJni::toJavaCompactionStopStyle(

View file

@ -39,8 +39,9 @@ jlong Java_org_rocksdb_AbstractComparator_createNewComparator(
* Method: usingDirectBuffers * Method: usingDirectBuffers
* Signature: (J)Z * Signature: (J)Z
*/ */
jboolean Java_org_rocksdb_AbstractComparator_usingDirectBuffers( jboolean Java_org_rocksdb_AbstractComparator_usingDirectBuffers(JNIEnv*,
JNIEnv*, jobject, jlong jhandle) { jobject,
jlong jhandle) {
auto* c = auto* c =
reinterpret_cast<ROCKSDB_NAMESPACE::ComparatorJniCallback*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::ComparatorJniCallback*>(jhandle);
return static_cast<jboolean>(c->m_options->direct_buffer); return static_cast<jboolean>(c->m_options->direct_buffer);

View file

@ -7,18 +7,18 @@
// ROCKSDB_NAMESPACE::Comparator. // ROCKSDB_NAMESPACE::Comparator.
#include "rocksjni/comparatorjnicallback.h" #include "rocksjni/comparatorjnicallback.h"
#include "rocksjni/portal.h" #include "rocksjni/portal.h"
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
ComparatorJniCallback::ComparatorJniCallback( ComparatorJniCallback::ComparatorJniCallback(
JNIEnv* env, jobject jcomparator, JNIEnv* env, jobject jcomparator,
const ComparatorJniCallbackOptions* options) const ComparatorJniCallbackOptions* options)
: JniCallback(env, jcomparator), : JniCallback(env, jcomparator), m_options(options) {
m_options(options) { // cache the AbstractComparatorJniBridge class as we will reuse it many times
// for each callback
// cache the AbstractComparatorJniBridge class as we will reuse it many times for each callback m_abstract_comparator_jni_bridge_clazz = static_cast<jclass>(
m_abstract_comparator_jni_bridge_clazz = env->NewGlobalRef(AbstractComparatorJniBridge::getJClass(env)));
static_cast<jclass>(env->NewGlobalRef(AbstractComparatorJniBridge::getJClass(env)));
// Note: The name of a Comparator will not change during it's lifetime, // Note: The name of a Comparator will not change during it's lifetime,
// so we cache it in a global var // so we cache it in a global var
@ -60,8 +60,8 @@ ComparatorJniCallback::ComparatorJniCallback(
} }
m_jshort_mid = m_jshort_mid =
AbstractComparatorJniBridge::getFindShortSuccessorInternalMethodId(env, AbstractComparatorJniBridge::getFindShortSuccessorInternalMethodId(
m_abstract_comparator_jni_bridge_clazz); env, m_abstract_comparator_jni_bridge_clazz);
if (m_jshort_mid == nullptr) { if (m_jshort_mid == nullptr) {
// exception thrown: NoSuchMethodException or OutOfMemoryError // exception thrown: NoSuchMethodException or OutOfMemoryError
return; return;
@ -69,9 +69,8 @@ ComparatorJniCallback::ComparatorJniCallback(
// do we need reusable buffers? // do we need reusable buffers?
if (m_options->max_reused_buffer_size > -1) { if (m_options->max_reused_buffer_size > -1) {
if (m_options->reused_synchronisation_type ==
if (m_options->reused_synchronisation_type ReusedSynchronisationType::THREAD_LOCAL) {
== ReusedSynchronisationType::THREAD_LOCAL) {
// buffers reused per thread // buffers reused per thread
UnrefHandler unref = [](void* ptr) { UnrefHandler unref = [](void* ptr) {
ThreadLocalBuf* tlb = reinterpret_cast<ThreadLocalBuf*>(ptr); ThreadLocalBuf* tlb = reinterpret_cast<ThreadLocalBuf*>(ptr);
@ -98,8 +97,8 @@ ComparatorJniCallback::ComparatorJniCallback(
} else { } else {
// buffers reused and shared across threads // buffers reused and shared across threads
const bool adaptive = const bool adaptive = m_options->reused_synchronisation_type ==
m_options->reused_synchronisation_type == ReusedSynchronisationType::ADAPTIVE_MUTEX; ReusedSynchronisationType::ADAPTIVE_MUTEX;
mtx_compare = std::unique_ptr<port::Mutex>(new port::Mutex(adaptive)); mtx_compare = std::unique_ptr<port::Mutex>(new port::Mutex(adaptive));
mtx_shortest = std::unique_ptr<port::Mutex>(new port::Mutex(adaptive)); mtx_shortest = std::unique_ptr<port::Mutex>(new port::Mutex(adaptive));
mtx_short = std::unique_ptr<port::Mutex>(new port::Mutex(adaptive)); mtx_short = std::unique_ptr<port::Mutex>(new port::Mutex(adaptive));
@ -220,9 +219,7 @@ ComparatorJniCallback::~ComparatorJniCallback() {
releaseJniEnv(attached_thread); releaseJniEnv(attached_thread);
} }
const char* ComparatorJniCallback::Name() const { const char* ComparatorJniCallback::Name() const { return m_name.get(); }
return m_name.get();
}
int ComparatorJniCallback::Compare(const Slice& a, const Slice& b) const { int ComparatorJniCallback::Compare(const Slice& a, const Slice& b) const {
jboolean attached_thread = JNI_FALSE; jboolean attached_thread = JNI_FALSE;
@ -236,7 +233,8 @@ int ComparatorJniCallback::Compare(const Slice& a, const Slice& b) const {
MaybeLockForReuse(mtx_compare, reuse_jbuf_a || reuse_jbuf_b); MaybeLockForReuse(mtx_compare, reuse_jbuf_a || reuse_jbuf_b);
jobject jcompare_buf_a = GetBuffer(env, a, reuse_jbuf_a, m_tl_buf_a, m_jcompare_buf_a); jobject jcompare_buf_a =
GetBuffer(env, a, reuse_jbuf_a, m_tl_buf_a, m_jcompare_buf_a);
if (jcompare_buf_a == nullptr) { if (jcompare_buf_a == nullptr) {
// exception occurred // exception occurred
MaybeUnlockForReuse(mtx_compare, reuse_jbuf_a || reuse_jbuf_b); MaybeUnlockForReuse(mtx_compare, reuse_jbuf_a || reuse_jbuf_b);
@ -245,7 +243,8 @@ int ComparatorJniCallback::Compare(const Slice& a, const Slice& b) const {
return 0; return 0;
} }
jobject jcompare_buf_b = GetBuffer(env, b, reuse_jbuf_b, m_tl_buf_b, m_jcompare_buf_b); jobject jcompare_buf_b =
GetBuffer(env, b, reuse_jbuf_b, m_tl_buf_b, m_jcompare_buf_b);
if (jcompare_buf_b == nullptr) { if (jcompare_buf_b == nullptr) {
// exception occurred // exception occurred
if (!reuse_jbuf_a) { if (!reuse_jbuf_a) {
@ -257,12 +256,10 @@ int ComparatorJniCallback::Compare(const Slice& a, const Slice& b) const {
return 0; return 0;
} }
jint result = jint result = env->CallStaticIntMethod(
env->CallStaticIntMethod( m_abstract_comparator_jni_bridge_clazz, m_jcompare_mid, m_jcallback_obj,
m_abstract_comparator_jni_bridge_clazz, m_jcompare_mid, jcompare_buf_a, reuse_jbuf_a ? a.size() : -1, jcompare_buf_b,
m_jcallback_obj, reuse_jbuf_b ? b.size() : -1);
jcompare_buf_a, reuse_jbuf_a ? a.size() : -1,
jcompare_buf_b, reuse_jbuf_b ? b.size() : -1);
if (env->ExceptionCheck()) { if (env->ExceptionCheck()) {
// exception thrown from CallIntMethod // exception thrown from CallIntMethod
@ -284,8 +281,8 @@ int ComparatorJniCallback::Compare(const Slice& a, const Slice& b) const {
return result; return result;
} }
void ComparatorJniCallback::FindShortestSeparator( void ComparatorJniCallback::FindShortestSeparator(std::string* start,
std::string* start, const Slice& limit) const { const Slice& limit) const {
if (start == nullptr) { if (start == nullptr) {
return; return;
} }
@ -294,15 +291,16 @@ void ComparatorJniCallback::FindShortestSeparator(
JNIEnv* env = getJniEnv(&attached_thread); JNIEnv* env = getJniEnv(&attached_thread);
assert(env != nullptr); assert(env != nullptr);
const bool reuse_jbuf_start = const bool reuse_jbuf_start = static_cast<int64_t>(start->length()) <=
static_cast<int64_t>(start->length()) <= m_options->max_reused_buffer_size; m_options->max_reused_buffer_size;
const bool reuse_jbuf_limit = const bool reuse_jbuf_limit =
static_cast<int64_t>(limit.size()) <= m_options->max_reused_buffer_size; static_cast<int64_t>(limit.size()) <= m_options->max_reused_buffer_size;
MaybeLockForReuse(mtx_shortest, reuse_jbuf_start || reuse_jbuf_limit); MaybeLockForReuse(mtx_shortest, reuse_jbuf_start || reuse_jbuf_limit);
Slice sstart(start->data(), start->length()); Slice sstart(start->data(), start->length());
jobject j_start_buf = GetBuffer(env, sstart, reuse_jbuf_start, m_tl_buf_a, m_jshortest_buf_start); jobject j_start_buf = GetBuffer(env, sstart, reuse_jbuf_start, m_tl_buf_a,
m_jshortest_buf_start);
if (j_start_buf == nullptr) { if (j_start_buf == nullptr) {
// exception occurred // exception occurred
MaybeUnlockForReuse(mtx_shortest, reuse_jbuf_start || reuse_jbuf_limit); MaybeUnlockForReuse(mtx_shortest, reuse_jbuf_start || reuse_jbuf_limit);
@ -311,7 +309,8 @@ void ComparatorJniCallback::FindShortestSeparator(
return; return;
} }
jobject j_limit_buf = GetBuffer(env, limit, reuse_jbuf_limit, m_tl_buf_b, m_jshortest_buf_limit); jobject j_limit_buf = GetBuffer(env, limit, reuse_jbuf_limit, m_tl_buf_b,
m_jshortest_buf_limit);
if (j_limit_buf == nullptr) { if (j_limit_buf == nullptr) {
// exception occurred // exception occurred
if (!reuse_jbuf_start) { if (!reuse_jbuf_start) {
@ -324,10 +323,9 @@ void ComparatorJniCallback::FindShortestSeparator(
} }
jint jstart_len = env->CallStaticIntMethod( jint jstart_len = env->CallStaticIntMethod(
m_abstract_comparator_jni_bridge_clazz, m_jshortest_mid, m_abstract_comparator_jni_bridge_clazz, m_jshortest_mid, m_jcallback_obj,
m_jcallback_obj, j_start_buf, reuse_jbuf_start ? start->length() : -1, j_limit_buf,
j_start_buf, reuse_jbuf_start ? start->length() : -1, reuse_jbuf_limit ? limit.size() : -1);
j_limit_buf, reuse_jbuf_limit ? limit.size() : -1);
if (env->ExceptionCheck()) { if (env->ExceptionCheck()) {
// exception thrown from CallIntMethod // exception thrown from CallIntMethod
@ -348,7 +346,8 @@ void ComparatorJniCallback::FindShortestSeparator(
if (!reuse_jbuf_limit) { if (!reuse_jbuf_limit) {
DeleteBuffer(env, j_limit_buf); DeleteBuffer(env, j_limit_buf);
} }
MaybeUnlockForReuse(mtx_shortest, reuse_jbuf_start || reuse_jbuf_limit); MaybeUnlockForReuse(mtx_shortest,
reuse_jbuf_start || reuse_jbuf_limit);
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew( ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(
env, "Unable to get Direct Buffer Address"); env, "Unable to get Direct Buffer Address");
env->ExceptionDescribe(); // print out exception to stderr env->ExceptionDescribe(); // print out exception to stderr
@ -358,14 +357,14 @@ void ComparatorJniCallback::FindShortestSeparator(
start->assign(static_cast<const char*>(start_buf), jstart_len); start->assign(static_cast<const char*>(start_buf), jstart_len);
} else { } else {
// reused non-direct buffer // reused non-direct buffer
copy_from_non_direct = true; copy_from_non_direct = true;
} }
} else { } else {
// there was a new buffer // there was a new buffer
if (m_options->direct_buffer) { if (m_options->direct_buffer) {
// it was direct... don't forget to potentially truncate the `start` string // it was direct... don't forget to potentially truncate the `start`
// string
start->resize(jstart_len); start->resize(jstart_len);
} else { } else {
// it was non-direct // it was non-direct
@ -374,8 +373,8 @@ void ComparatorJniCallback::FindShortestSeparator(
} }
if (copy_from_non_direct) { if (copy_from_non_direct) {
jbyteArray jarray = ByteBufferJni::array(env, j_start_buf, jbyteArray jarray =
m_jbytebuffer_clazz); ByteBufferJni::array(env, j_start_buf, m_jbytebuffer_clazz);
if (jarray == nullptr) { if (jarray == nullptr) {
if (!reuse_jbuf_start) { if (!reuse_jbuf_start) {
DeleteBuffer(env, j_start_buf); DeleteBuffer(env, j_start_buf);
@ -389,9 +388,12 @@ void ComparatorJniCallback::FindShortestSeparator(
return; return;
} }
jboolean has_exception = JNI_FALSE; jboolean has_exception = JNI_FALSE;
JniUtil::byteString<std::string>(env, jarray, [start, jstart_len](const char* data, const size_t) { JniUtil::byteString<std::string>(
env, jarray,
[start, jstart_len](const char* data, const size_t) {
return start->assign(data, static_cast<size_t>(jstart_len)); return start->assign(data, static_cast<size_t>(jstart_len));
}, &has_exception); },
&has_exception);
env->DeleteLocalRef(jarray); env->DeleteLocalRef(jarray);
if (has_exception == JNI_TRUE) { if (has_exception == JNI_TRUE) {
if (!reuse_jbuf_start) { if (!reuse_jbuf_start) {
@ -420,8 +422,7 @@ void ComparatorJniCallback::FindShortestSeparator(
releaseJniEnv(attached_thread); releaseJniEnv(attached_thread);
} }
void ComparatorJniCallback::FindShortSuccessor( void ComparatorJniCallback::FindShortSuccessor(std::string* key) const {
std::string* key) const {
if (key == nullptr) { if (key == nullptr) {
return; return;
} }
@ -436,7 +437,8 @@ void ComparatorJniCallback::FindShortSuccessor(
MaybeLockForReuse(mtx_short, reuse_jbuf_key); MaybeLockForReuse(mtx_short, reuse_jbuf_key);
Slice skey(key->data(), key->length()); Slice skey(key->data(), key->length());
jobject j_key_buf = GetBuffer(env, skey, reuse_jbuf_key, m_tl_buf_a, m_jshort_buf_key); jobject j_key_buf =
GetBuffer(env, skey, reuse_jbuf_key, m_tl_buf_a, m_jshort_buf_key);
if (j_key_buf == nullptr) { if (j_key_buf == nullptr) {
// exception occurred // exception occurred
MaybeUnlockForReuse(mtx_short, reuse_jbuf_key); MaybeUnlockForReuse(mtx_short, reuse_jbuf_key);
@ -446,8 +448,7 @@ void ComparatorJniCallback::FindShortSuccessor(
} }
jint jkey_len = env->CallStaticIntMethod( jint jkey_len = env->CallStaticIntMethod(
m_abstract_comparator_jni_bridge_clazz, m_jshort_mid, m_abstract_comparator_jni_bridge_clazz, m_jshort_mid, m_jcallback_obj,
m_jcallback_obj,
j_key_buf, reuse_jbuf_key ? key->length() : -1); j_key_buf, reuse_jbuf_key ? key->length() : -1);
if (env->ExceptionCheck()) { if (env->ExceptionCheck()) {
@ -459,7 +460,6 @@ void ComparatorJniCallback::FindShortSuccessor(
env->ExceptionDescribe(); // print out exception to stderr env->ExceptionDescribe(); // print out exception to stderr
releaseJniEnv(attached_thread); releaseJniEnv(attached_thread);
return; return;
} }
if (static_cast<size_t>(jkey_len) != key->length()) { if (static_cast<size_t>(jkey_len) != key->length()) {
@ -489,7 +489,8 @@ void ComparatorJniCallback::FindShortSuccessor(
} else { } else {
// there was a new buffer // there was a new buffer
if (m_options->direct_buffer) { if (m_options->direct_buffer) {
// it was direct... don't forget to potentially truncate the `key` string // it was direct... don't forget to potentially truncate the `key`
// string
key->resize(jkey_len); key->resize(jkey_len);
} else { } else {
// it was non-direct // it was non-direct
@ -498,10 +499,9 @@ void ComparatorJniCallback::FindShortSuccessor(
} }
if (copy_from_non_direct) { if (copy_from_non_direct) {
jbyteArray jarray = ByteBufferJni::array(env, j_key_buf, jbyteArray jarray =
m_jbytebuffer_clazz); ByteBufferJni::array(env, j_key_buf, m_jbytebuffer_clazz);
if (jarray == nullptr) { if (jarray == nullptr) {
if (!reuse_jbuf_key) { if (!reuse_jbuf_key) {
DeleteBuffer(env, j_key_buf); DeleteBuffer(env, j_key_buf);
} }
@ -511,9 +511,12 @@ void ComparatorJniCallback::FindShortSuccessor(
return; return;
} }
jboolean has_exception = JNI_FALSE; jboolean has_exception = JNI_FALSE;
JniUtil::byteString<std::string>(env, jarray, [key, jkey_len](const char* data, const size_t) { JniUtil::byteString<std::string>(
env, jarray,
[key, jkey_len](const char* data, const size_t) {
return key->assign(data, static_cast<size_t>(jkey_len)); return key->assign(data, static_cast<size_t>(jkey_len));
}, &has_exception); },
&has_exception);
env->DeleteLocalRef(jarray); env->DeleteLocalRef(jarray);
if (has_exception == JNI_TRUE) { if (has_exception == JNI_TRUE) {
if (!reuse_jbuf_key) { if (!reuse_jbuf_key) {
@ -539,8 +542,9 @@ void ComparatorJniCallback::FindShortSuccessor(
inline void ComparatorJniCallback::MaybeLockForReuse( inline void ComparatorJniCallback::MaybeLockForReuse(
const std::unique_ptr<port::Mutex>& mutex, const bool cond) const { const std::unique_ptr<port::Mutex>& mutex, const bool cond) const {
// no need to lock if using thread_local // no need to lock if using thread_local
if (m_options->reused_synchronisation_type != ReusedSynchronisationType::THREAD_LOCAL if (m_options->reused_synchronisation_type !=
&& cond) { ReusedSynchronisationType::THREAD_LOCAL &&
cond) {
mutex.get()->Lock(); mutex.get()->Lock();
} }
} }
@ -548,18 +552,20 @@ inline void ComparatorJniCallback::MaybeLockForReuse(
inline void ComparatorJniCallback::MaybeUnlockForReuse( inline void ComparatorJniCallback::MaybeUnlockForReuse(
const std::unique_ptr<port::Mutex>& mutex, const bool cond) const { const std::unique_ptr<port::Mutex>& mutex, const bool cond) const {
// no need to unlock if using thread_local // no need to unlock if using thread_local
if (m_options->reused_synchronisation_type != ReusedSynchronisationType::THREAD_LOCAL if (m_options->reused_synchronisation_type !=
&& cond) { ReusedSynchronisationType::THREAD_LOCAL &&
cond) {
mutex.get()->Unlock(); mutex.get()->Unlock();
} }
} }
jobject ComparatorJniCallback::GetBuffer(JNIEnv* env, const Slice& src, jobject ComparatorJniCallback::GetBuffer(JNIEnv* env, const Slice& src,
bool reuse_buffer, ThreadLocalPtr* tl_buf, jobject jreuse_buffer) const { bool reuse_buffer,
ThreadLocalPtr* tl_buf,
jobject jreuse_buffer) const {
if (reuse_buffer) { if (reuse_buffer) {
if (m_options->reused_synchronisation_type if (m_options->reused_synchronisation_type ==
== ReusedSynchronisationType::THREAD_LOCAL) { ReusedSynchronisationType::THREAD_LOCAL) {
// reuse thread-local bufffer // reuse thread-local bufffer
ThreadLocalBuf* tlb = reinterpret_cast<ThreadLocalBuf*>(tl_buf->Get()); ThreadLocalBuf* tlb = reinterpret_cast<ThreadLocalBuf*>(tl_buf->Get());
if (tlb == nullptr) { if (tlb == nullptr) {
@ -576,25 +582,25 @@ jobject ComparatorJniCallback::GetBuffer(JNIEnv* env, const Slice& src,
} }
return ReuseBuffer(env, src, tlb->jbuf); return ReuseBuffer(env, src, tlb->jbuf);
} else { } else {
// reuse class member buffer // reuse class member buffer
return ReuseBuffer(env, src, jreuse_buffer); return ReuseBuffer(env, src, jreuse_buffer);
} }
} else { } else {
// new buffer // new buffer
return NewBuffer(env, src); return NewBuffer(env, src);
} }
} }
jobject ComparatorJniCallback::ReuseBuffer( jobject ComparatorJniCallback::ReuseBuffer(JNIEnv* env, const Slice& src,
JNIEnv* env, const Slice& src, jobject jreuse_buffer) const { jobject jreuse_buffer) const {
// we can reuse the buffer // we can reuse the buffer
if (m_options->direct_buffer) { if (m_options->direct_buffer) {
// copy into direct buffer // copy into direct buffer
void* buf = env->GetDirectBufferAddress(jreuse_buffer); void* buf = env->GetDirectBufferAddress(jreuse_buffer);
if (buf == nullptr) { if (buf == nullptr) {
// either memory region is undefined, given object is not a direct java.nio.Buffer, or JNI access to direct buffers is not supported by this virtual machine. // either memory region is undefined, given object is not a direct
// java.nio.Buffer, or JNI access to direct buffers is not supported by
// this virtual machine.
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew( ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(
env, "Unable to get Direct Buffer Address"); env, "Unable to get Direct Buffer Address");
return nullptr; return nullptr;
@ -602,13 +608,14 @@ jobject ComparatorJniCallback::ReuseBuffer(
memcpy(buf, src.data(), src.size()); memcpy(buf, src.data(), src.size());
} else { } else {
// copy into non-direct buffer // copy into non-direct buffer
const jbyteArray jarray = ByteBufferJni::array(env, jreuse_buffer, const jbyteArray jarray =
m_jbytebuffer_clazz); ByteBufferJni::array(env, jreuse_buffer, m_jbytebuffer_clazz);
if (jarray == nullptr) { if (jarray == nullptr) {
// exception occurred // exception occurred
return nullptr; return nullptr;
} }
env->SetByteArrayRegion(jarray, 0, static_cast<jsize>(src.size()), env->SetByteArrayRegion(
jarray, 0, static_cast<jsize>(src.size()),
const_cast<jbyte*>(reinterpret_cast<const jbyte*>(src.data()))); const_cast<jbyte*>(reinterpret_cast<const jbyte*>(src.data())));
if (env->ExceptionCheck()) { if (env->ExceptionCheck()) {
// exception occurred // exception occurred
@ -622,8 +629,9 @@ jobject ComparatorJniCallback::ReuseBuffer(
jobject ComparatorJniCallback::NewBuffer(JNIEnv* env, const Slice& src) const { jobject ComparatorJniCallback::NewBuffer(JNIEnv* env, const Slice& src) const {
// we need a new buffer // we need a new buffer
jobject jbuf = ByteBufferJni::constructWith(env, m_options->direct_buffer, jobject jbuf =
src.data(), src.size(), m_jbytebuffer_clazz); ByteBufferJni::constructWith(env, m_options->direct_buffer, src.data(),
src.size(), m_jbytebuffer_clazz);
if (jbuf == nullptr) { if (jbuf == nullptr) {
// exception occurred // exception occurred
return nullptr; return nullptr;

View file

@ -10,12 +10,14 @@
#define JAVA_ROCKSJNI_COMPARATORJNICALLBACK_H_ #define JAVA_ROCKSJNI_COMPARATORJNICALLBACK_H_
#include <jni.h> #include <jni.h>
#include <memory> #include <memory>
#include <string> #include <string>
#include "rocksjni/jnicallback.h"
#include "port/port.h"
#include "rocksdb/comparator.h" #include "rocksdb/comparator.h"
#include "rocksdb/slice.h" #include "rocksdb/slice.h"
#include "port/port.h" #include "rocksjni/jnicallback.h"
#include "util/thread_local.h" #include "util/thread_local.h"
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
@ -41,7 +43,6 @@ enum ReusedSynchronisationType {
}; };
struct ComparatorJniCallbackOptions { struct ComparatorJniCallbackOptions {
// Set the synchronisation type used to guard the reused buffers. // Set the synchronisation type used to guard the reused buffers.
// Only used if max_reused_buffer_size > 0. // Only used if max_reused_buffer_size > 0.
// Default: ADAPTIVE_MUTEX // Default: ADAPTIVE_MUTEX
@ -83,21 +84,20 @@ struct ComparatorJniCallbackOptions {
*/ */
class ComparatorJniCallback : public JniCallback, public Comparator { class ComparatorJniCallback : public JniCallback, public Comparator {
public: public:
ComparatorJniCallback( ComparatorJniCallback(JNIEnv* env, jobject jcomparator,
JNIEnv* env, jobject jcomparator,
const ComparatorJniCallbackOptions* options); const ComparatorJniCallbackOptions* options);
~ComparatorJniCallback(); ~ComparatorJniCallback();
virtual const char* Name() const; virtual const char* Name() const;
virtual int Compare(const Slice& a, const Slice& b) const; virtual int Compare(const Slice& a, const Slice& b) const;
virtual void FindShortestSeparator( virtual void FindShortestSeparator(std::string* start,
std::string* start, const Slice& limit) const; const Slice& limit) const;
virtual void FindShortSuccessor(std::string* key) const; virtual void FindShortSuccessor(std::string* key) const;
const ComparatorJniCallbackOptions* m_options; const ComparatorJniCallbackOptions* m_options;
private: private:
struct ThreadLocalBuf { struct ThreadLocalBuf {
ThreadLocalBuf(JavaVM* _jvm, bool _direct_buffer, jobject _jbuf) : ThreadLocalBuf(JavaVM* _jvm, bool _direct_buffer, jobject _jbuf)
jvm(_jvm), direct_buffer(_direct_buffer), jbuf(_jbuf) {} : jvm(_jvm), direct_buffer(_direct_buffer), jbuf(_jbuf) {}
JavaVM* jvm; JavaVM* jvm;
bool direct_buffer; bool direct_buffer;
jobject jbuf; jobject jbuf;
@ -119,8 +119,12 @@ class ComparatorJniCallback : public JniCallback, public Comparator {
// used for synchronisation in findShortSuccessor method // used for synchronisation in findShortSuccessor method
std::unique_ptr<port::Mutex> mtx_short; std::unique_ptr<port::Mutex> mtx_short;
std::unique_ptr<const char[]> m_name; std::unique_ptr<const char[]> m_name;
jclass m_abstract_comparator_jni_bridge_clazz; // TODO(AR) could we make this static somehow? jclass m_abstract_comparator_jni_bridge_clazz; // TODO(AR) could we make this
jclass m_jbytebuffer_clazz; // TODO(AR) we could cache this globally for the entire VM if we switch more APIs to use ByteBuffer // TODO(AR) could we make this static somehow? // static somehow?
jclass m_jbytebuffer_clazz; // TODO(AR) we could cache this globally for the
// entire VM if we switch more APIs to use
// ByteBuffer // TODO(AR) could we make this
// static somehow?
jmethodID m_jcompare_mid; // TODO(AR) could we make this static somehow? jmethodID m_jcompare_mid; // TODO(AR) could we make this static somehow?
jmethodID m_jshortest_mid; // TODO(AR) could we make this static somehow? jmethodID m_jshortest_mid; // TODO(AR) could we make this static somehow?
jmethodID m_jshort_mid; // TODO(AR) could we make this static somehow? jmethodID m_jshort_mid; // TODO(AR) could we make this static somehow?

View file

@ -17,8 +17,8 @@
* Method: newCompressionOptions * Method: newCompressionOptions
* Signature: ()J * Signature: ()J
*/ */
jlong Java_org_rocksdb_CompressionOptions_newCompressionOptions( jlong Java_org_rocksdb_CompressionOptions_newCompressionOptions(JNIEnv*,
JNIEnv*, jclass) { jclass) {
const auto* opt = new ROCKSDB_NAMESPACE::CompressionOptions(); const auto* opt = new ROCKSDB_NAMESPACE::CompressionOptions();
return GET_CPLUSPLUS_POINTER(opt); return GET_CPLUSPLUS_POINTER(opt);
} }
@ -28,8 +28,9 @@ jlong Java_org_rocksdb_CompressionOptions_newCompressionOptions(
* Method: setWindowBits * Method: setWindowBits
* Signature: (JI)V * Signature: (JI)V
*/ */
void Java_org_rocksdb_CompressionOptions_setWindowBits( void Java_org_rocksdb_CompressionOptions_setWindowBits(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle, jint jwindow_bits) { jlong jhandle,
jint jwindow_bits) {
auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle); auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle);
opt->window_bits = static_cast<int>(jwindow_bits); opt->window_bits = static_cast<int>(jwindow_bits);
} }
@ -39,8 +40,8 @@ void Java_org_rocksdb_CompressionOptions_setWindowBits(
* Method: windowBits * Method: windowBits
* Signature: (J)I * Signature: (J)I
*/ */
jint Java_org_rocksdb_CompressionOptions_windowBits( jint Java_org_rocksdb_CompressionOptions_windowBits(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle); auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle);
return static_cast<jint>(opt->window_bits); return static_cast<jint>(opt->window_bits);
} }
@ -50,8 +51,8 @@ jint Java_org_rocksdb_CompressionOptions_windowBits(
* Method: setLevel * Method: setLevel
* Signature: (JI)V * Signature: (JI)V
*/ */
void Java_org_rocksdb_CompressionOptions_setLevel( void Java_org_rocksdb_CompressionOptions_setLevel(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle, jint jlevel) { jlong jhandle, jint jlevel) {
auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle); auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle);
opt->level = static_cast<int>(jlevel); opt->level = static_cast<int>(jlevel);
} }
@ -61,8 +62,8 @@ void Java_org_rocksdb_CompressionOptions_setLevel(
* Method: level * Method: level
* Signature: (J)I * Signature: (J)I
*/ */
jint Java_org_rocksdb_CompressionOptions_level( jint Java_org_rocksdb_CompressionOptions_level(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle); auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle);
return static_cast<jint>(opt->level); return static_cast<jint>(opt->level);
} }
@ -72,8 +73,9 @@ jint Java_org_rocksdb_CompressionOptions_level(
* Method: setStrategy * Method: setStrategy
* Signature: (JI)V * Signature: (JI)V
*/ */
void Java_org_rocksdb_CompressionOptions_setStrategy( void Java_org_rocksdb_CompressionOptions_setStrategy(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle, jint jstrategy) { jlong jhandle,
jint jstrategy) {
auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle); auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle);
opt->strategy = static_cast<int>(jstrategy); opt->strategy = static_cast<int>(jstrategy);
} }
@ -83,8 +85,8 @@ void Java_org_rocksdb_CompressionOptions_setStrategy(
* Method: strategy * Method: strategy
* Signature: (J)I * Signature: (J)I
*/ */
jint Java_org_rocksdb_CompressionOptions_strategy( jint Java_org_rocksdb_CompressionOptions_strategy(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle); auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle);
return static_cast<jint>(opt->strategy); return static_cast<jint>(opt->strategy);
} }
@ -94,8 +96,9 @@ jint Java_org_rocksdb_CompressionOptions_strategy(
* Method: setMaxDictBytes * Method: setMaxDictBytes
* Signature: (JI)V * Signature: (JI)V
*/ */
void Java_org_rocksdb_CompressionOptions_setMaxDictBytes( void Java_org_rocksdb_CompressionOptions_setMaxDictBytes(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle, jint jmax_dict_bytes) { jlong jhandle,
jint jmax_dict_bytes) {
auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle); auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle);
opt->max_dict_bytes = static_cast<uint32_t>(jmax_dict_bytes); opt->max_dict_bytes = static_cast<uint32_t>(jmax_dict_bytes);
} }
@ -105,8 +108,8 @@ void Java_org_rocksdb_CompressionOptions_setMaxDictBytes(
* Method: maxDictBytes * Method: maxDictBytes
* Signature: (J)I * Signature: (J)I
*/ */
jint Java_org_rocksdb_CompressionOptions_maxDictBytes( jint Java_org_rocksdb_CompressionOptions_maxDictBytes(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle); auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle);
return static_cast<jint>(opt->max_dict_bytes); return static_cast<jint>(opt->max_dict_bytes);
} }
@ -127,8 +130,8 @@ void Java_org_rocksdb_CompressionOptions_setZstdMaxTrainBytes(
* Method: zstdMaxTrainBytes * Method: zstdMaxTrainBytes
* Signature: (J)I * Signature: (J)I
*/ */
jint Java_org_rocksdb_CompressionOptions_zstdMaxTrainBytes( jint Java_org_rocksdb_CompressionOptions_zstdMaxTrainBytes(JNIEnv*, jobject,
JNIEnv *, jobject, jlong jhandle) { jlong jhandle) {
auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle); auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle);
return static_cast<jint>(opt->zstd_max_train_bytes); return static_cast<jint>(opt->zstd_max_train_bytes);
} }
@ -183,8 +186,9 @@ jboolean Java_org_rocksdb_CompressionOptions_useZstdDictTrainer(JNIEnv*,
* Method: setEnabled * Method: setEnabled
* Signature: (JZ)V * Signature: (JZ)V
*/ */
void Java_org_rocksdb_CompressionOptions_setEnabled( void Java_org_rocksdb_CompressionOptions_setEnabled(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle, jboolean jenabled) { jlong jhandle,
jboolean jenabled) {
auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle); auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle);
opt->enabled = jenabled == JNI_TRUE; opt->enabled = jenabled == JNI_TRUE;
} }
@ -194,8 +198,8 @@ void Java_org_rocksdb_CompressionOptions_setEnabled(
* Method: enabled * Method: enabled
* Signature: (J)Z * Signature: (J)Z
*/ */
jboolean Java_org_rocksdb_CompressionOptions_enabled( jboolean Java_org_rocksdb_CompressionOptions_enabled(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle); auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle);
return static_cast<bool>(opt->enabled); return static_cast<bool>(opt->enabled);
} }
@ -204,7 +208,7 @@ jboolean Java_org_rocksdb_CompressionOptions_enabled(
* Method: disposeInternal * Method: disposeInternal
* Signature: (J)V * Signature: (J)V
*/ */
void Java_org_rocksdb_CompressionOptions_disposeInternal( void Java_org_rocksdb_CompressionOptions_disposeInternal(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
delete reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle); delete reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle);
} }

View file

@ -85,5 +85,6 @@ void Java_org_rocksdb_ConfigOptions_setInputStringsEscaped(JNIEnv *, jclass,
void Java_org_rocksdb_ConfigOptions_setSanityLevel(JNIEnv *, jclass, void Java_org_rocksdb_ConfigOptions_setSanityLevel(JNIEnv *, jclass,
jlong handle, jbyte level) { jlong handle, jbyte level) {
auto *cfg_opt = reinterpret_cast<ROCKSDB_NAMESPACE::ConfigOptions *>(handle); auto *cfg_opt = reinterpret_cast<ROCKSDB_NAMESPACE::ConfigOptions *>(handle);
cfg_opt->sanity_level = ROCKSDB_NAMESPACE::SanityLevelJni::toCppSanityLevel(level); cfg_opt->sanity_level =
ROCKSDB_NAMESPACE::SanityLevelJni::toCppSanityLevel(level);
} }

View file

@ -24,8 +24,7 @@
* Method: getDefaultEnvInternal * Method: getDefaultEnvInternal
* Signature: ()J * Signature: ()J
*/ */
jlong Java_org_rocksdb_Env_getDefaultEnvInternal( jlong Java_org_rocksdb_Env_getDefaultEnvInternal(JNIEnv*, jclass) {
JNIEnv*, jclass) {
return GET_CPLUSPLUS_POINTER(ROCKSDB_NAMESPACE::Env::Default()); return GET_CPLUSPLUS_POINTER(ROCKSDB_NAMESPACE::Env::Default());
} }
@ -34,8 +33,8 @@ jlong Java_org_rocksdb_Env_getDefaultEnvInternal(
* Method: disposeInternal * Method: disposeInternal
* Signature: (J)V * Signature: (J)V
*/ */
void Java_org_rocksdb_RocksEnv_disposeInternal( void Java_org_rocksdb_RocksEnv_disposeInternal(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
auto* e = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle); auto* e = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle);
assert(e != nullptr); assert(e != nullptr);
delete e; delete e;
@ -46,8 +45,9 @@ void Java_org_rocksdb_RocksEnv_disposeInternal(
* Method: setBackgroundThreads * Method: setBackgroundThreads
* Signature: (JIB)V * Signature: (JIB)V
*/ */
void Java_org_rocksdb_Env_setBackgroundThreads( void Java_org_rocksdb_Env_setBackgroundThreads(JNIEnv*, jobject, jlong jhandle,
JNIEnv*, jobject, jlong jhandle, jint jnum, jbyte jpriority_value) { jint jnum,
jbyte jpriority_value) {
auto* rocks_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle); auto* rocks_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle);
rocks_env->SetBackgroundThreads( rocks_env->SetBackgroundThreads(
static_cast<int>(jnum), static_cast<int>(jnum),
@ -59,8 +59,8 @@ void Java_org_rocksdb_Env_setBackgroundThreads(
* Method: getBackgroundThreads * Method: getBackgroundThreads
* Signature: (JB)I * Signature: (JB)I
*/ */
jint Java_org_rocksdb_Env_getBackgroundThreads( jint Java_org_rocksdb_Env_getBackgroundThreads(JNIEnv*, jobject, jlong jhandle,
JNIEnv*, jobject, jlong jhandle, jbyte jpriority_value) { jbyte jpriority_value) {
auto* rocks_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle); auto* rocks_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle);
const int num = rocks_env->GetBackgroundThreads( const int num = rocks_env->GetBackgroundThreads(
ROCKSDB_NAMESPACE::PriorityJni::toCppPriority(jpriority_value)); ROCKSDB_NAMESPACE::PriorityJni::toCppPriority(jpriority_value));
@ -72,8 +72,8 @@ jint Java_org_rocksdb_Env_getBackgroundThreads(
* Method: getThreadPoolQueueLen * Method: getThreadPoolQueueLen
* Signature: (JB)I * Signature: (JB)I
*/ */
jint Java_org_rocksdb_Env_getThreadPoolQueueLen( jint Java_org_rocksdb_Env_getThreadPoolQueueLen(JNIEnv*, jobject, jlong jhandle,
JNIEnv*, jobject, jlong jhandle, jbyte jpriority_value) { jbyte jpriority_value) {
auto* rocks_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle); auto* rocks_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle);
const int queue_len = rocks_env->GetThreadPoolQueueLen( const int queue_len = rocks_env->GetThreadPoolQueueLen(
ROCKSDB_NAMESPACE::PriorityJni::toCppPriority(jpriority_value)); ROCKSDB_NAMESPACE::PriorityJni::toCppPriority(jpriority_value));
@ -85,8 +85,9 @@ jint Java_org_rocksdb_Env_getThreadPoolQueueLen(
* Method: incBackgroundThreadsIfNeeded * Method: incBackgroundThreadsIfNeeded
* Signature: (JIB)V * Signature: (JIB)V
*/ */
void Java_org_rocksdb_Env_incBackgroundThreadsIfNeeded( void Java_org_rocksdb_Env_incBackgroundThreadsIfNeeded(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle, jint jnum, jbyte jpriority_value) { jlong jhandle, jint jnum,
jbyte jpriority_value) {
auto* rocks_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle); auto* rocks_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle);
rocks_env->IncBackgroundThreadsIfNeeded( rocks_env->IncBackgroundThreadsIfNeeded(
static_cast<int>(jnum), static_cast<int>(jnum),
@ -98,8 +99,9 @@ void Java_org_rocksdb_Env_incBackgroundThreadsIfNeeded(
* Method: lowerThreadPoolIOPriority * Method: lowerThreadPoolIOPriority
* Signature: (JB)V * Signature: (JB)V
*/ */
void Java_org_rocksdb_Env_lowerThreadPoolIOPriority( void Java_org_rocksdb_Env_lowerThreadPoolIOPriority(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle, jbyte jpriority_value) { jlong jhandle,
jbyte jpriority_value) {
auto* rocks_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle); auto* rocks_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle);
rocks_env->LowerThreadPoolIOPriority( rocks_env->LowerThreadPoolIOPriority(
ROCKSDB_NAMESPACE::PriorityJni::toCppPriority(jpriority_value)); ROCKSDB_NAMESPACE::PriorityJni::toCppPriority(jpriority_value));
@ -110,8 +112,9 @@ void Java_org_rocksdb_Env_lowerThreadPoolIOPriority(
* Method: lowerThreadPoolCPUPriority * Method: lowerThreadPoolCPUPriority
* Signature: (JB)V * Signature: (JB)V
*/ */
void Java_org_rocksdb_Env_lowerThreadPoolCPUPriority( void Java_org_rocksdb_Env_lowerThreadPoolCPUPriority(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle, jbyte jpriority_value) { jlong jhandle,
jbyte jpriority_value) {
auto* rocks_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle); auto* rocks_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle);
rocks_env->LowerThreadPoolCPUPriority( rocks_env->LowerThreadPoolCPUPriority(
ROCKSDB_NAMESPACE::PriorityJni::toCppPriority(jpriority_value)); ROCKSDB_NAMESPACE::PriorityJni::toCppPriority(jpriority_value));
@ -122,8 +125,8 @@ void Java_org_rocksdb_Env_lowerThreadPoolCPUPriority(
* Method: getThreadList * Method: getThreadList
* Signature: (J)[Lorg/rocksdb/ThreadStatus; * Signature: (J)[Lorg/rocksdb/ThreadStatus;
*/ */
jobjectArray Java_org_rocksdb_Env_getThreadList( jobjectArray Java_org_rocksdb_Env_getThreadList(JNIEnv* env, jobject,
JNIEnv* env, jobject, jlong jhandle) { jlong jhandle) {
auto* rocks_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle); auto* rocks_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle);
std::vector<ROCKSDB_NAMESPACE::ThreadStatus> thread_status; std::vector<ROCKSDB_NAMESPACE::ThreadStatus> thread_status;
ROCKSDB_NAMESPACE::Status s = rocks_env->GetThreadList(&thread_status); ROCKSDB_NAMESPACE::Status s = rocks_env->GetThreadList(&thread_status);
@ -160,8 +163,8 @@ jobjectArray Java_org_rocksdb_Env_getThreadList(
* Method: createMemEnv * Method: createMemEnv
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_RocksMemEnv_createMemEnv( jlong Java_org_rocksdb_RocksMemEnv_createMemEnv(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jbase_env_handle) { jlong jbase_env_handle) {
auto* base_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jbase_env_handle); auto* base_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jbase_env_handle);
return GET_CPLUSPLUS_POINTER(ROCKSDB_NAMESPACE::NewMemEnv(base_env)); return GET_CPLUSPLUS_POINTER(ROCKSDB_NAMESPACE::NewMemEnv(base_env));
} }
@ -171,8 +174,8 @@ jlong Java_org_rocksdb_RocksMemEnv_createMemEnv(
* Method: disposeInternal * Method: disposeInternal
* Signature: (J)V * Signature: (J)V
*/ */
void Java_org_rocksdb_RocksMemEnv_disposeInternal( void Java_org_rocksdb_RocksMemEnv_disposeInternal(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
auto* e = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle); auto* e = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle);
assert(e != nullptr); assert(e != nullptr);
delete e; delete e;
@ -183,8 +186,8 @@ void Java_org_rocksdb_RocksMemEnv_disposeInternal(
* Method: createTimedEnv * Method: createTimedEnv
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_TimedEnv_createTimedEnv( jlong Java_org_rocksdb_TimedEnv_createTimedEnv(JNIEnv*, jclass,
JNIEnv*, jclass, jlong jbase_env_handle) { jlong jbase_env_handle) {
auto* base_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jbase_env_handle); auto* base_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jbase_env_handle);
return GET_CPLUSPLUS_POINTER(ROCKSDB_NAMESPACE::NewTimedEnv(base_env)); return GET_CPLUSPLUS_POINTER(ROCKSDB_NAMESPACE::NewTimedEnv(base_env));
} }
@ -194,10 +197,9 @@ jlong Java_org_rocksdb_TimedEnv_createTimedEnv(
* Method: disposeInternal * Method: disposeInternal
* Signature: (J)V * Signature: (J)V
*/ */
void Java_org_rocksdb_TimedEnv_disposeInternal( void Java_org_rocksdb_TimedEnv_disposeInternal(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
auto* e = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle); auto* e = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle);
assert(e != nullptr); assert(e != nullptr);
delete e; delete e;
} }

View file

@ -33,8 +33,7 @@
* Method: newEnvOptions * Method: newEnvOptions
* Signature: ()J * Signature: ()J
*/ */
jlong Java_org_rocksdb_EnvOptions_newEnvOptions__( jlong Java_org_rocksdb_EnvOptions_newEnvOptions__(JNIEnv *, jclass) {
JNIEnv*, jclass) {
auto *env_opt = new ROCKSDB_NAMESPACE::EnvOptions(); auto *env_opt = new ROCKSDB_NAMESPACE::EnvOptions();
return GET_CPLUSPLUS_POINTER(env_opt); return GET_CPLUSPLUS_POINTER(env_opt);
} }
@ -44,8 +43,8 @@ jlong Java_org_rocksdb_EnvOptions_newEnvOptions__(
* Method: newEnvOptions * Method: newEnvOptions
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_EnvOptions_newEnvOptions__J( jlong Java_org_rocksdb_EnvOptions_newEnvOptions__J(JNIEnv *, jclass,
JNIEnv*, jclass, jlong jdboptions_handle) { jlong jdboptions_handle) {
auto *db_options = auto *db_options =
reinterpret_cast<ROCKSDB_NAMESPACE::DBOptions *>(jdboptions_handle); reinterpret_cast<ROCKSDB_NAMESPACE::DBOptions *>(jdboptions_handle);
auto *env_opt = new ROCKSDB_NAMESPACE::EnvOptions(*db_options); auto *env_opt = new ROCKSDB_NAMESPACE::EnvOptions(*db_options);
@ -57,8 +56,8 @@ jlong Java_org_rocksdb_EnvOptions_newEnvOptions__J(
* Method: disposeInternal * Method: disposeInternal
* Signature: (J)V * Signature: (J)V
*/ */
void Java_org_rocksdb_EnvOptions_disposeInternal( void Java_org_rocksdb_EnvOptions_disposeInternal(JNIEnv *, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
auto *eo = reinterpret_cast<ROCKSDB_NAMESPACE::EnvOptions *>(jhandle); auto *eo = reinterpret_cast<ROCKSDB_NAMESPACE::EnvOptions *>(jhandle);
assert(eo != nullptr); assert(eo != nullptr);
delete eo; delete eo;
@ -69,8 +68,9 @@ void Java_org_rocksdb_EnvOptions_disposeInternal(
* Method: setUseMmapReads * Method: setUseMmapReads
* Signature: (JZ)V * Signature: (JZ)V
*/ */
void Java_org_rocksdb_EnvOptions_setUseMmapReads( void Java_org_rocksdb_EnvOptions_setUseMmapReads(JNIEnv *, jobject,
JNIEnv*, jobject, jlong jhandle, jboolean use_mmap_reads) { jlong jhandle,
jboolean use_mmap_reads) {
ENV_OPTIONS_SET_BOOL(jhandle, use_mmap_reads); ENV_OPTIONS_SET_BOOL(jhandle, use_mmap_reads);
} }
@ -79,8 +79,8 @@ void Java_org_rocksdb_EnvOptions_setUseMmapReads(
* Method: useMmapReads * Method: useMmapReads
* Signature: (J)Z * Signature: (J)Z
*/ */
jboolean Java_org_rocksdb_EnvOptions_useMmapReads( jboolean Java_org_rocksdb_EnvOptions_useMmapReads(JNIEnv *, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
return ENV_OPTIONS_GET(jhandle, use_mmap_reads); return ENV_OPTIONS_GET(jhandle, use_mmap_reads);
} }
@ -89,8 +89,9 @@ jboolean Java_org_rocksdb_EnvOptions_useMmapReads(
* Method: setUseMmapWrites * Method: setUseMmapWrites
* Signature: (JZ)V * Signature: (JZ)V
*/ */
void Java_org_rocksdb_EnvOptions_setUseMmapWrites( void Java_org_rocksdb_EnvOptions_setUseMmapWrites(JNIEnv *, jobject,
JNIEnv*, jobject, jlong jhandle, jboolean use_mmap_writes) { jlong jhandle,
jboolean use_mmap_writes) {
ENV_OPTIONS_SET_BOOL(jhandle, use_mmap_writes); ENV_OPTIONS_SET_BOOL(jhandle, use_mmap_writes);
} }
@ -99,8 +100,8 @@ void Java_org_rocksdb_EnvOptions_setUseMmapWrites(
* Method: useMmapWrites * Method: useMmapWrites
* Signature: (J)Z * Signature: (J)Z
*/ */
jboolean Java_org_rocksdb_EnvOptions_useMmapWrites( jboolean Java_org_rocksdb_EnvOptions_useMmapWrites(JNIEnv *, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
return ENV_OPTIONS_GET(jhandle, use_mmap_writes); return ENV_OPTIONS_GET(jhandle, use_mmap_writes);
} }
@ -109,8 +110,9 @@ jboolean Java_org_rocksdb_EnvOptions_useMmapWrites(
* Method: setUseDirectReads * Method: setUseDirectReads
* Signature: (JZ)V * Signature: (JZ)V
*/ */
void Java_org_rocksdb_EnvOptions_setUseDirectReads( void Java_org_rocksdb_EnvOptions_setUseDirectReads(JNIEnv *, jobject,
JNIEnv*, jobject, jlong jhandle, jboolean use_direct_reads) { jlong jhandle,
jboolean use_direct_reads) {
ENV_OPTIONS_SET_BOOL(jhandle, use_direct_reads); ENV_OPTIONS_SET_BOOL(jhandle, use_direct_reads);
} }
@ -119,8 +121,8 @@ void Java_org_rocksdb_EnvOptions_setUseDirectReads(
* Method: useDirectReads * Method: useDirectReads
* Signature: (J)Z * Signature: (J)Z
*/ */
jboolean Java_org_rocksdb_EnvOptions_useDirectReads( jboolean Java_org_rocksdb_EnvOptions_useDirectReads(JNIEnv *, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
return ENV_OPTIONS_GET(jhandle, use_direct_reads); return ENV_OPTIONS_GET(jhandle, use_direct_reads);
} }
@ -139,8 +141,8 @@ void Java_org_rocksdb_EnvOptions_setUseDirectWrites(
* Method: useDirectWrites * Method: useDirectWrites
* Signature: (J)Z * Signature: (J)Z
*/ */
jboolean Java_org_rocksdb_EnvOptions_useDirectWrites( jboolean Java_org_rocksdb_EnvOptions_useDirectWrites(JNIEnv *, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
return ENV_OPTIONS_GET(jhandle, use_direct_writes); return ENV_OPTIONS_GET(jhandle, use_direct_writes);
} }
@ -149,8 +151,9 @@ jboolean Java_org_rocksdb_EnvOptions_useDirectWrites(
* Method: setAllowFallocate * Method: setAllowFallocate
* Signature: (JZ)V * Signature: (JZ)V
*/ */
void Java_org_rocksdb_EnvOptions_setAllowFallocate( void Java_org_rocksdb_EnvOptions_setAllowFallocate(JNIEnv *, jobject,
JNIEnv*, jobject, jlong jhandle, jboolean allow_fallocate) { jlong jhandle,
jboolean allow_fallocate) {
ENV_OPTIONS_SET_BOOL(jhandle, allow_fallocate); ENV_OPTIONS_SET_BOOL(jhandle, allow_fallocate);
} }
@ -159,8 +162,8 @@ void Java_org_rocksdb_EnvOptions_setAllowFallocate(
* Method: allowFallocate * Method: allowFallocate
* Signature: (J)Z * Signature: (J)Z
*/ */
jboolean Java_org_rocksdb_EnvOptions_allowFallocate( jboolean Java_org_rocksdb_EnvOptions_allowFallocate(JNIEnv *, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
return ENV_OPTIONS_GET(jhandle, allow_fallocate); return ENV_OPTIONS_GET(jhandle, allow_fallocate);
} }
@ -169,8 +172,9 @@ jboolean Java_org_rocksdb_EnvOptions_allowFallocate(
* Method: setSetFdCloexec * Method: setSetFdCloexec
* Signature: (JZ)V * Signature: (JZ)V
*/ */
void Java_org_rocksdb_EnvOptions_setSetFdCloexec( void Java_org_rocksdb_EnvOptions_setSetFdCloexec(JNIEnv *, jobject,
JNIEnv*, jobject, jlong jhandle, jboolean set_fd_cloexec) { jlong jhandle,
jboolean set_fd_cloexec) {
ENV_OPTIONS_SET_BOOL(jhandle, set_fd_cloexec); ENV_OPTIONS_SET_BOOL(jhandle, set_fd_cloexec);
} }
@ -179,8 +183,8 @@ void Java_org_rocksdb_EnvOptions_setSetFdCloexec(
* Method: setFdCloexec * Method: setFdCloexec
* Signature: (J)Z * Signature: (J)Z
*/ */
jboolean Java_org_rocksdb_EnvOptions_setFdCloexec( jboolean Java_org_rocksdb_EnvOptions_setFdCloexec(JNIEnv *, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
return ENV_OPTIONS_GET(jhandle, set_fd_cloexec); return ENV_OPTIONS_GET(jhandle, set_fd_cloexec);
} }
@ -189,8 +193,9 @@ jboolean Java_org_rocksdb_EnvOptions_setFdCloexec(
* Method: setBytesPerSync * Method: setBytesPerSync
* Signature: (JJ)V * Signature: (JJ)V
*/ */
void Java_org_rocksdb_EnvOptions_setBytesPerSync( void Java_org_rocksdb_EnvOptions_setBytesPerSync(JNIEnv *, jobject,
JNIEnv*, jobject, jlong jhandle, jlong bytes_per_sync) { jlong jhandle,
jlong bytes_per_sync) {
ENV_OPTIONS_SET_UINT64_T(jhandle, bytes_per_sync); ENV_OPTIONS_SET_UINT64_T(jhandle, bytes_per_sync);
} }
@ -199,8 +204,8 @@ void Java_org_rocksdb_EnvOptions_setBytesPerSync(
* Method: bytesPerSync * Method: bytesPerSync
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_EnvOptions_bytesPerSync( jlong Java_org_rocksdb_EnvOptions_bytesPerSync(JNIEnv *, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
return ENV_OPTIONS_GET(jhandle, bytes_per_sync); return ENV_OPTIONS_GET(jhandle, bytes_per_sync);
} }
@ -219,8 +224,8 @@ void Java_org_rocksdb_EnvOptions_setFallocateWithKeepSize(
* Method: fallocateWithKeepSize * Method: fallocateWithKeepSize
* Signature: (J)Z * Signature: (J)Z
*/ */
jboolean Java_org_rocksdb_EnvOptions_fallocateWithKeepSize( jboolean Java_org_rocksdb_EnvOptions_fallocateWithKeepSize(JNIEnv *, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
return ENV_OPTIONS_GET(jhandle, fallocate_with_keep_size); return ENV_OPTIONS_GET(jhandle, fallocate_with_keep_size);
} }
@ -239,8 +244,8 @@ void Java_org_rocksdb_EnvOptions_setCompactionReadaheadSize(
* Method: compactionReadaheadSize * Method: compactionReadaheadSize
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_EnvOptions_compactionReadaheadSize( jlong Java_org_rocksdb_EnvOptions_compactionReadaheadSize(JNIEnv *, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
return ENV_OPTIONS_GET(jhandle, compaction_readahead_size); return ENV_OPTIONS_GET(jhandle, compaction_readahead_size);
} }
@ -259,8 +264,8 @@ void Java_org_rocksdb_EnvOptions_setRandomAccessMaxBufferSize(
* Method: randomAccessMaxBufferSize * Method: randomAccessMaxBufferSize
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_EnvOptions_randomAccessMaxBufferSize( jlong Java_org_rocksdb_EnvOptions_randomAccessMaxBufferSize(JNIEnv *, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
return ENV_OPTIONS_GET(jhandle, random_access_max_buffer_size); return ENV_OPTIONS_GET(jhandle, random_access_max_buffer_size);
} }
@ -279,8 +284,8 @@ void Java_org_rocksdb_EnvOptions_setWritableFileMaxBufferSize(
* Method: writableFileMaxBufferSize * Method: writableFileMaxBufferSize
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_EnvOptions_writableFileMaxBufferSize( jlong Java_org_rocksdb_EnvOptions_writableFileMaxBufferSize(JNIEnv *, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
return ENV_OPTIONS_GET(jhandle, writable_file_max_buffer_size); return ENV_OPTIONS_GET(jhandle, writable_file_max_buffer_size);
} }
@ -289,8 +294,9 @@ jlong Java_org_rocksdb_EnvOptions_writableFileMaxBufferSize(
* Method: setRateLimiter * Method: setRateLimiter
* Signature: (JJ)V * Signature: (JJ)V
*/ */
void Java_org_rocksdb_EnvOptions_setRateLimiter( void Java_org_rocksdb_EnvOptions_setRateLimiter(JNIEnv *, jobject,
JNIEnv*, jobject, jlong jhandle, jlong rl_handle) { jlong jhandle,
jlong rl_handle) {
auto *sptr_rate_limiter = auto *sptr_rate_limiter =
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::RateLimiter> *>( reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::RateLimiter> *>(
rl_handle); rl_handle);

View file

@ -29,9 +29,8 @@ jlong Java_org_rocksdb_IngestExternalFileOptions_newIngestExternalFileOptions__(
* Signature: (ZZZZ)J * Signature: (ZZZZ)J
*/ */
jlong Java_org_rocksdb_IngestExternalFileOptions_newIngestExternalFileOptions__ZZZZ( jlong Java_org_rocksdb_IngestExternalFileOptions_newIngestExternalFileOptions__ZZZZ(
JNIEnv*, jclass, jboolean jmove_files, JNIEnv*, jclass, jboolean jmove_files, jboolean jsnapshot_consistency,
jboolean jsnapshot_consistency, jboolean jallow_global_seqno, jboolean jallow_global_seqno, jboolean jallow_blocking_flush) {
jboolean jallow_blocking_flush) {
auto* options = new ROCKSDB_NAMESPACE::IngestExternalFileOptions(); auto* options = new ROCKSDB_NAMESPACE::IngestExternalFileOptions();
options->move_files = static_cast<bool>(jmove_files); options->move_files = static_cast<bool>(jmove_files);
options->snapshot_consistency = static_cast<bool>(jsnapshot_consistency); options->snapshot_consistency = static_cast<bool>(jsnapshot_consistency);
@ -45,8 +44,8 @@ jlong Java_org_rocksdb_IngestExternalFileOptions_newIngestExternalFileOptions__Z
* Method: moveFiles * Method: moveFiles
* Signature: (J)Z * Signature: (J)Z
*/ */
jboolean Java_org_rocksdb_IngestExternalFileOptions_moveFiles( jboolean Java_org_rocksdb_IngestExternalFileOptions_moveFiles(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
auto* options = auto* options =
reinterpret_cast<ROCKSDB_NAMESPACE::IngestExternalFileOptions*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::IngestExternalFileOptions*>(jhandle);
return static_cast<jboolean>(options->move_files); return static_cast<jboolean>(options->move_files);
@ -165,8 +164,9 @@ void Java_org_rocksdb_IngestExternalFileOptions_setIngestBehind(
* Method: writeGlobalSeqno * Method: writeGlobalSeqno
* Signature: (J)Z * Signature: (J)Z
*/ */
JNIEXPORT jboolean JNICALL Java_org_rocksdb_IngestExternalFileOptions_writeGlobalSeqno( JNIEXPORT jboolean JNICALL
JNIEnv*, jobject, jlong jhandle) { Java_org_rocksdb_IngestExternalFileOptions_writeGlobalSeqno(JNIEnv*, jobject,
jlong jhandle) {
auto* options = auto* options =
reinterpret_cast<ROCKSDB_NAMESPACE::IngestExternalFileOptions*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::IngestExternalFileOptions*>(jhandle);
return options->write_global_seqno == JNI_TRUE; return options->write_global_seqno == JNI_TRUE;
@ -177,7 +177,8 @@ JNIEXPORT jboolean JNICALL Java_org_rocksdb_IngestExternalFileOptions_writeGloba
* Method: setWriteGlobalSeqno * Method: setWriteGlobalSeqno
* Signature: (JZ)V * Signature: (JZ)V
*/ */
JNIEXPORT void JNICALL Java_org_rocksdb_IngestExternalFileOptions_setWriteGlobalSeqno( JNIEXPORT void JNICALL
Java_org_rocksdb_IngestExternalFileOptions_setWriteGlobalSeqno(
JNIEnv*, jobject, jlong jhandle, jboolean jwrite_global_seqno) { JNIEnv*, jobject, jlong jhandle, jboolean jwrite_global_seqno) {
auto* options = auto* options =
reinterpret_cast<ROCKSDB_NAMESPACE::IngestExternalFileOptions*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::IngestExternalFileOptions*>(jhandle);
@ -189,8 +190,9 @@ JNIEXPORT void JNICALL Java_org_rocksdb_IngestExternalFileOptions_setWriteGlobal
* Method: disposeInternal * Method: disposeInternal
* Signature: (J)V * Signature: (J)V
*/ */
void Java_org_rocksdb_IngestExternalFileOptions_disposeInternal( void Java_org_rocksdb_IngestExternalFileOptions_disposeInternal(JNIEnv*,
JNIEnv*, jobject, jlong jhandle) { jobject,
jlong jhandle) {
auto* options = auto* options =
reinterpret_cast<ROCKSDB_NAMESPACE::IngestExternalFileOptions*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::IngestExternalFileOptions*>(jhandle);
delete options; delete options;

View file

@ -6,8 +6,10 @@
// This file implements the callback "bridge" between Java and C++ for // This file implements the callback "bridge" between Java and C++ for
// JNI Callbacks from C++ to sub-classes or org.rocksdb.RocksCallbackObject // JNI Callbacks from C++ to sub-classes or org.rocksdb.RocksCallbackObject
#include <assert.h>
#include "rocksjni/jnicallback.h" #include "rocksjni/jnicallback.h"
#include <assert.h>
#include "rocksjni/portal.h" #include "rocksjni/portal.h"
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {

View file

@ -10,11 +10,13 @@
#define JAVA_ROCKSJNI_LOGGERJNICALLBACK_H_ #define JAVA_ROCKSJNI_LOGGERJNICALLBACK_H_
#include <jni.h> #include <jni.h>
#include <memory> #include <memory>
#include <string> #include <string>
#include "rocksjni/jnicallback.h"
#include "port/port.h" #include "port/port.h"
#include "rocksdb/env.h" #include "rocksdb/env.h"
#include "rocksjni/jnicallback.h"
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
@ -23,8 +25,8 @@ class LoggerJniCallback : public JniCallback, public Logger {
LoggerJniCallback(JNIEnv* env, jobject jLogger); LoggerJniCallback(JNIEnv* env, jobject jLogger);
~LoggerJniCallback(); ~LoggerJniCallback();
using Logger::SetInfoLogLevel;
using Logger::GetInfoLogLevel; using Logger::GetInfoLogLevel;
using Logger::SetInfoLogLevel;
// Write an entry to the log file with the specified format. // Write an entry to the log file with the specified format.
virtual void Logv(const char* format, va_list ap); virtual void Logv(const char* format, va_list ap);
// Write an entry to the log file with the specified log level // Write an entry to the log file with the specified log level

View file

@ -3,19 +3,18 @@
// COPYING file in the root directory) and Apache 2.0 License // COPYING file in the root directory) and Apache 2.0 License
// (found in the LICENSE.Apache file in the root directory). // (found in the LICENSE.Apache file in the root directory).
#include "rocksdb/utilities/memory_util.h"
#include <jni.h> #include <jni.h>
#include <map> #include <map>
#include <string> #include <string>
#include <unordered_set> #include <unordered_set>
#include <vector> #include <vector>
#include "include/org_rocksdb_MemoryUtil.h" #include "include/org_rocksdb_MemoryUtil.h"
#include "rocksjni/portal.h" #include "rocksjni/portal.h"
#include "rocksdb/utilities/memory_util.h"
/* /*
* Class: org_rocksdb_MemoryUtil * Class: org_rocksdb_MemoryUtil
* Method: getApproximateMemoryUsageByType * Method: getApproximateMemoryUsageByType
@ -35,7 +34,8 @@ jobject Java_org_rocksdb_MemoryUtil_getApproximateMemoryUsageByType(
std::unordered_set<const ROCKSDB_NAMESPACE::Cache *> cache_set; std::unordered_set<const ROCKSDB_NAMESPACE::Cache *> cache_set;
jsize cache_handle_count = env->GetArrayLength(jcache_handles); jsize cache_handle_count = env->GetArrayLength(jcache_handles);
if (cache_handle_count > 0) { if (cache_handle_count > 0) {
jlong *ptr_jcache_handles = env->GetLongArrayElements(jcache_handles, nullptr); jlong *ptr_jcache_handles =
env->GetLongArrayElements(jcache_handles, nullptr);
if (ptr_jcache_handles == nullptr) { if (ptr_jcache_handles == nullptr) {
// exception thrown: OutOfMemoryError // exception thrown: OutOfMemoryError
return nullptr; return nullptr;
@ -46,7 +46,8 @@ jobject Java_org_rocksdb_MemoryUtil_getApproximateMemoryUsageByType(
ptr_jcache_handles[i]); ptr_jcache_handles[i]);
cache_set.insert(cache_ptr->get()); cache_set.insert(cache_ptr->get());
} }
env->ReleaseLongArrayElements(jcache_handles, ptr_jcache_handles, JNI_ABORT); env->ReleaseLongArrayElements(jcache_handles, ptr_jcache_handles,
JNI_ABORT);
} }
std::map<ROCKSDB_NAMESPACE::MemoryUtil::UsageType, uint64_t> usage_by_type; std::map<ROCKSDB_NAMESPACE::MemoryUtil::UsageType, uint64_t> usage_by_type;
@ -85,8 +86,7 @@ jobject Java_org_rocksdb_MemoryUtil_getApproximateMemoryUsageByType(
} }
// Construct and return pointer to pair of jobjects // Construct and return pointer to pair of jobjects
return std::unique_ptr<std::pair<jobject, jobject>>( return std::unique_ptr<std::pair<jobject, jobject>>(
new std::pair<jobject, jobject>(jusage_type, new std::pair<jobject, jobject>(jusage_type, jusage_value));
jusage_value));
}; };
if (!ROCKSDB_NAMESPACE::HashMapJni::putAll(env, jusage_by_type, if (!ROCKSDB_NAMESPACE::HashMapJni::putAll(env, jusage_by_type,

View file

@ -159,8 +159,8 @@ Java_org_rocksdb_OptimisticTransactionDB_open__JLjava_lang_String_2_3_3B_3J(
* Method: disposeInternal * Method: disposeInternal
* Signature: (J)V * Signature: (J)V
*/ */
void Java_org_rocksdb_OptimisticTransactionDB_disposeInternal( void Java_org_rocksdb_OptimisticTransactionDB_disposeInternal(JNIEnv*, jobject,
JNIEnv *, jobject, jlong jhandle) { jlong jhandle) {
auto* optimistic_txn_db = auto* optimistic_txn_db =
reinterpret_cast<ROCKSDB_NAMESPACE::OptimisticTransactionDB*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::OptimisticTransactionDB*>(jhandle);
assert(optimistic_txn_db != nullptr); assert(optimistic_txn_db != nullptr);
@ -172,8 +172,8 @@ void Java_org_rocksdb_OptimisticTransactionDB_disposeInternal(
* Method: closeDatabase * Method: closeDatabase
* Signature: (J)V * Signature: (J)V
*/ */
void Java_org_rocksdb_OptimisticTransactionDB_closeDatabase( void Java_org_rocksdb_OptimisticTransactionDB_closeDatabase(JNIEnv* env, jclass,
JNIEnv* env, jclass, jlong jhandle) { jlong jhandle) {
auto* optimistic_txn_db = auto* optimistic_txn_db =
reinterpret_cast<ROCKSDB_NAMESPACE::OptimisticTransactionDB*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::OptimisticTransactionDB*>(jhandle);
assert(optimistic_txn_db != nullptr); assert(optimistic_txn_db != nullptr);
@ -276,8 +276,8 @@ jlong Java_org_rocksdb_OptimisticTransactionDB_beginTransaction_1withOld__JJJJ(
* Method: getBaseDB * Method: getBaseDB
* Signature: (J)J * Signature: (J)J
*/ */
jlong Java_org_rocksdb_OptimisticTransactionDB_getBaseDB( jlong Java_org_rocksdb_OptimisticTransactionDB_getBaseDB(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
auto* optimistic_txn_db = auto* optimistic_txn_db =
reinterpret_cast<ROCKSDB_NAMESPACE::OptimisticTransactionDB*>(jhandle); reinterpret_cast<ROCKSDB_NAMESPACE::OptimisticTransactionDB*>(jhandle);
return GET_CPLUSPLUS_POINTER(optimistic_txn_db->GetBaseDB()); return GET_CPLUSPLUS_POINTER(optimistic_txn_db->GetBaseDB());

File diff suppressed because it is too large Load diff

View file

@ -6,14 +6,15 @@
// This file implements the "bridge" between Java and C++ and enables // This file implements the "bridge" between Java and C++ and enables
// calling C++ ROCKSDB_NAMESPACE::OptionsUtil methods from Java side. // calling C++ ROCKSDB_NAMESPACE::OptionsUtil methods from Java side.
#include "rocksdb/utilities/options_util.h"
#include <jni.h> #include <jni.h>
#include <string> #include <string>
#include "include/org_rocksdb_OptionsUtil.h" #include "include/org_rocksdb_OptionsUtil.h"
#include "rocksdb/db.h" #include "rocksdb/db.h"
#include "rocksdb/env.h" #include "rocksdb/env.h"
#include "rocksdb/utilities/options_util.h"
#include "rocksjni/portal.h" #include "rocksjni/portal.h"
void build_column_family_descriptor_list( void build_column_family_descriptor_list(

View file

@ -23,8 +23,8 @@
* Signature: (JLjava/lang/String;JJZ)J * Signature: (JLjava/lang/String;JJZ)J
*/ */
jlong Java_org_rocksdb_PersistentCache_newPersistentCache( jlong Java_org_rocksdb_PersistentCache_newPersistentCache(
JNIEnv* env, jclass, jlong jenv_handle, jstring jpath, JNIEnv* env, jclass, jlong jenv_handle, jstring jpath, jlong jsz,
jlong jsz, jlong jlogger_handle, jboolean joptimized_for_nvm) { jlong jlogger_handle, jboolean joptimized_for_nvm) {
auto* rocks_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jenv_handle); auto* rocks_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jenv_handle);
jboolean has_exception = JNI_FALSE; jboolean has_exception = JNI_FALSE;
std::string path = std::string path =
@ -51,8 +51,8 @@ jlong Java_org_rocksdb_PersistentCache_newPersistentCache(
* Method: disposeInternal * Method: disposeInternal
* Signature: (J)V * Signature: (J)V
*/ */
void Java_org_rocksdb_PersistentCache_disposeInternal( void Java_org_rocksdb_PersistentCache_disposeInternal(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
auto* cache = auto* cache =
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::PersistentCache>*>( reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::PersistentCache>*>(
jhandle); jhandle);

File diff suppressed because it is too large Load diff

View file

@ -6,7 +6,6 @@
#include <jni.h> #include <jni.h>
#include "include/org_rocksdb_RocksDBExceptionTest.h" #include "include/org_rocksdb_RocksDBExceptionTest.h"
#include "rocksdb/slice.h" #include "rocksdb/slice.h"
#include "rocksdb/status.h" #include "rocksdb/status.h"
#include "rocksjni/portal.h" #include "rocksjni/portal.h"

File diff suppressed because it is too large Load diff

View file

@ -176,7 +176,8 @@ jbyteArray Java_org_rocksdb_SstFileReaderIterator_key0(JNIEnv* env,
* Method: value0 * Method: value0
* Signature: (J)[B * Signature: (J)[B
*/ */
jbyteArray Java_org_rocksdb_SstFileReaderIterator_value0(JNIEnv* env, jobject /*jobj*/, jbyteArray Java_org_rocksdb_SstFileReaderIterator_value0(JNIEnv* env,
jobject /*jobj*/,
jlong handle) { jlong handle) {
auto* it = reinterpret_cast<ROCKSDB_NAMESPACE::Iterator*>(handle); auto* it = reinterpret_cast<ROCKSDB_NAMESPACE::Iterator*>(handle);
ROCKSDB_NAMESPACE::Slice value_slice = it->value(); ROCKSDB_NAMESPACE::Slice value_slice = it->value();
@ -187,7 +188,8 @@ jbyteArray Java_org_rocksdb_SstFileReaderIterator_value0(JNIEnv* env, jobject /*
// exception thrown: OutOfMemoryError // exception thrown: OutOfMemoryError
return nullptr; return nullptr;
} }
env->SetByteArrayRegion(jkeyValue, 0, static_cast<jsize>(value_slice.size()), env->SetByteArrayRegion(
jkeyValue, 0, static_cast<jsize>(value_slice.size()),
const_cast<jbyte*>(reinterpret_cast<const jbyte*>(value_slice.data()))); const_cast<jbyte*>(reinterpret_cast<const jbyte*>(value_slice.data())));
return jkeyValue; return jkeyValue;
} }
@ -357,7 +359,8 @@ void Java_org_rocksdb_SstFileReaderIterator_seekForPrevByteArray0(
* Method: refresh0 * Method: refresh0
* Signature: (J)V * Signature: (J)V
*/ */
void Java_org_rocksdb_SstFileReaderIterator_refresh0(JNIEnv* env, jobject /*jobj*/, void Java_org_rocksdb_SstFileReaderIterator_refresh0(JNIEnv* env,
jobject /*jobj*/,
jlong handle) { jlong handle) {
auto* it = reinterpret_cast<ROCKSDB_NAMESPACE::Iterator*>(handle); auto* it = reinterpret_cast<ROCKSDB_NAMESPACE::Iterator*>(handle);
ROCKSDB_NAMESPACE::Status s = it->Refresh(); ROCKSDB_NAMESPACE::Status s = it->Refresh();

View file

@ -23,10 +23,8 @@
* Method: newStatistics * Method: newStatistics
* Signature: ()J * Signature: ()J
*/ */
jlong Java_org_rocksdb_Statistics_newStatistics__( jlong Java_org_rocksdb_Statistics_newStatistics__(JNIEnv* env, jclass jcls) {
JNIEnv* env, jclass jcls) { return Java_org_rocksdb_Statistics_newStatistics___3BJ(env, jcls, nullptr, 0);
return Java_org_rocksdb_Statistics_newStatistics___3BJ(
env, jcls, nullptr, 0);
} }
/* /*
@ -45,10 +43,10 @@ jlong Java_org_rocksdb_Statistics_newStatistics__J(
* Method: newStatistics * Method: newStatistics
* Signature: ([B)J * Signature: ([B)J
*/ */
jlong Java_org_rocksdb_Statistics_newStatistics___3B( jlong Java_org_rocksdb_Statistics_newStatistics___3B(JNIEnv* env, jclass jcls,
JNIEnv* env, jclass jcls, jbyteArray jhistograms) { jbyteArray jhistograms) {
return Java_org_rocksdb_Statistics_newStatistics___3BJ( return Java_org_rocksdb_Statistics_newStatistics___3BJ(env, jcls, jhistograms,
env, jcls, jhistograms, 0); 0);
} }
/* /*
@ -57,7 +55,8 @@ jlong Java_org_rocksdb_Statistics_newStatistics___3B(
* Signature: ([BJ)J * Signature: ([BJ)J
*/ */
jlong Java_org_rocksdb_Statistics_newStatistics___3BJ( jlong Java_org_rocksdb_Statistics_newStatistics___3BJ(
JNIEnv* env, jclass, jbyteArray jhistograms, jlong jother_statistics_handle) { JNIEnv* env, jclass, jbyteArray jhistograms,
jlong jother_statistics_handle) {
std::shared_ptr<ROCKSDB_NAMESPACE::Statistics>* pSptr_other_statistics = std::shared_ptr<ROCKSDB_NAMESPACE::Statistics>* pSptr_other_statistics =
nullptr; nullptr;
if (jother_statistics_handle > 0) { if (jother_statistics_handle > 0) {
@ -105,8 +104,8 @@ jlong Java_org_rocksdb_Statistics_newStatistics___3BJ(
* Method: disposeInternal * Method: disposeInternal
* Signature: (J)V * Signature: (J)V
*/ */
void Java_org_rocksdb_Statistics_disposeInternal( void Java_org_rocksdb_Statistics_disposeInternal(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
if (jhandle > 0) { if (jhandle > 0) {
auto* pSptr_statistics = auto* pSptr_statistics =
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Statistics>*>( reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Statistics>*>(
@ -120,8 +119,7 @@ void Java_org_rocksdb_Statistics_disposeInternal(
* Method: statsLevel * Method: statsLevel
* Signature: (J)B * Signature: (J)B
*/ */
jbyte Java_org_rocksdb_Statistics_statsLevel( jbyte Java_org_rocksdb_Statistics_statsLevel(JNIEnv*, jobject, jlong jhandle) {
JNIEnv*, jobject, jlong jhandle) {
auto* pSptr_statistics = auto* pSptr_statistics =
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Statistics>*>( reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Statistics>*>(
jhandle); jhandle);
@ -135,8 +133,8 @@ jbyte Java_org_rocksdb_Statistics_statsLevel(
* Method: setStatsLevel * Method: setStatsLevel
* Signature: (JB)V * Signature: (JB)V
*/ */
void Java_org_rocksdb_Statistics_setStatsLevel( void Java_org_rocksdb_Statistics_setStatsLevel(JNIEnv*, jobject, jlong jhandle,
JNIEnv*, jobject, jlong jhandle, jbyte jstats_level) { jbyte jstats_level) {
auto* pSptr_statistics = auto* pSptr_statistics =
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Statistics>*>( reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Statistics>*>(
jhandle); jhandle);
@ -151,8 +149,9 @@ void Java_org_rocksdb_Statistics_setStatsLevel(
* Method: getTickerCount * Method: getTickerCount
* Signature: (JB)J * Signature: (JB)J
*/ */
jlong Java_org_rocksdb_Statistics_getTickerCount( jlong Java_org_rocksdb_Statistics_getTickerCount(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle, jbyte jticker_type) { jlong jhandle,
jbyte jticker_type) {
auto* pSptr_statistics = auto* pSptr_statistics =
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Statistics>*>( reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Statistics>*>(
jhandle); jhandle);
@ -167,8 +166,9 @@ jlong Java_org_rocksdb_Statistics_getTickerCount(
* Method: getAndResetTickerCount * Method: getAndResetTickerCount
* Signature: (JB)J * Signature: (JB)J
*/ */
jlong Java_org_rocksdb_Statistics_getAndResetTickerCount( jlong Java_org_rocksdb_Statistics_getAndResetTickerCount(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle, jbyte jticker_type) { jlong jhandle,
jbyte jticker_type) {
auto* pSptr_statistics = auto* pSptr_statistics =
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Statistics>*>( reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Statistics>*>(
jhandle); jhandle);
@ -182,8 +182,9 @@ jlong Java_org_rocksdb_Statistics_getAndResetTickerCount(
* Method: getHistogramData * Method: getHistogramData
* Signature: (JB)Lorg/rocksdb/HistogramData; * Signature: (JB)Lorg/rocksdb/HistogramData;
*/ */
jobject Java_org_rocksdb_Statistics_getHistogramData( jobject Java_org_rocksdb_Statistics_getHistogramData(JNIEnv* env, jobject,
JNIEnv* env, jobject, jlong jhandle, jbyte jhistogram_type) { jlong jhandle,
jbyte jhistogram_type) {
auto* pSptr_statistics = auto* pSptr_statistics =
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Statistics>*>( reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Statistics>*>(
jhandle); jhandle);
@ -213,8 +214,8 @@ jobject Java_org_rocksdb_Statistics_getHistogramData(
return env->NewObject(jclazz, mid, data.median, data.percentile95, return env->NewObject(jclazz, mid, data.median, data.percentile95,
data.percentile99, data.average, data.percentile99, data.average,
data.standard_deviation, data.max, data.count, data.standard_deviation, data.max, data.count, data.sum,
data.sum, data.min); data.min);
} }
/* /*
@ -222,8 +223,9 @@ jobject Java_org_rocksdb_Statistics_getHistogramData(
* Method: getHistogramString * Method: getHistogramString
* Signature: (JB)Ljava/lang/String; * Signature: (JB)Ljava/lang/String;
*/ */
jstring Java_org_rocksdb_Statistics_getHistogramString( jstring Java_org_rocksdb_Statistics_getHistogramString(JNIEnv* env, jobject,
JNIEnv* env, jobject, jlong jhandle, jbyte jhistogram_type) { jlong jhandle,
jbyte jhistogram_type) {
auto* pSptr_statistics = auto* pSptr_statistics =
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Statistics>*>( reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Statistics>*>(
jhandle); jhandle);
@ -239,8 +241,7 @@ jstring Java_org_rocksdb_Statistics_getHistogramString(
* Method: reset * Method: reset
* Signature: (J)V * Signature: (J)V
*/ */
void Java_org_rocksdb_Statistics_reset( void Java_org_rocksdb_Statistics_reset(JNIEnv* env, jobject, jlong jhandle) {
JNIEnv* env, jobject, jlong jhandle) {
auto* pSptr_statistics = auto* pSptr_statistics =
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Statistics>*>( reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Statistics>*>(
jhandle); jhandle);
@ -256,8 +257,8 @@ void Java_org_rocksdb_Statistics_reset(
* Method: toString * Method: toString
* Signature: (J)Ljava/lang/String; * Signature: (J)Ljava/lang/String;
*/ */
jstring Java_org_rocksdb_Statistics_toString( jstring Java_org_rocksdb_Statistics_toString(JNIEnv* env, jobject,
JNIEnv* env, jobject, jlong jhandle) { jlong jhandle) {
auto* pSptr_statistics = auto* pSptr_statistics =
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Statistics>*>( reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Statistics>*>(
jhandle); jhandle);

View file

@ -12,8 +12,9 @@
#include <memory> #include <memory>
#include <set> #include <set>
#include <string> #include <string>
#include "rocksdb/statistics.h"
#include "monitoring/statistics.h" #include "monitoring/statistics.h"
#include "rocksdb/statistics.h"
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {

View file

@ -131,7 +131,8 @@ jlong Java_org_rocksdb_BlockBasedTableConfig_newTableFactoryHandle(
options.block_size = static_cast<size_t>(jblock_size); options.block_size = static_cast<size_t>(jblock_size);
options.block_size_deviation = static_cast<int>(jblock_size_deviation); options.block_size_deviation = static_cast<int>(jblock_size_deviation);
options.block_restart_interval = static_cast<int>(jblock_restart_interval); options.block_restart_interval = static_cast<int>(jblock_restart_interval);
options.index_block_restart_interval = static_cast<int>(jindex_block_restart_interval); options.index_block_restart_interval =
static_cast<int>(jindex_block_restart_interval);
options.metadata_block_size = static_cast<uint64_t>(jmetadata_block_size); options.metadata_block_size = static_cast<uint64_t>(jmetadata_block_size);
options.partition_filters = static_cast<bool>(jpartition_filters); options.partition_filters = static_cast<bool>(jpartition_filters);
options.optimize_filters_for_memory = options.optimize_filters_for_memory =
@ -145,9 +146,11 @@ jlong Java_org_rocksdb_BlockBasedTableConfig_newTableFactoryHandle(
} }
options.whole_key_filtering = static_cast<bool>(jwhole_key_filtering); options.whole_key_filtering = static_cast<bool>(jwhole_key_filtering);
options.verify_compression = static_cast<bool>(jverify_compression); options.verify_compression = static_cast<bool>(jverify_compression);
options.read_amp_bytes_per_bit = static_cast<uint32_t>(jread_amp_bytes_per_bit); options.read_amp_bytes_per_bit =
static_cast<uint32_t>(jread_amp_bytes_per_bit);
options.format_version = static_cast<uint32_t>(jformat_version); options.format_version = static_cast<uint32_t>(jformat_version);
options.enable_index_compression = static_cast<bool>(jenable_index_compression); options.enable_index_compression =
static_cast<bool>(jenable_index_compression);
options.block_align = static_cast<bool>(jblock_align); options.block_align = static_cast<bool>(jblock_align);
options.index_shortening = options.index_shortening =
ROCKSDB_NAMESPACE::IndexShorteningModeJni::toCppIndexShorteningMode( ROCKSDB_NAMESPACE::IndexShorteningModeJni::toCppIndexShorteningMode(

View file

@ -7,14 +7,14 @@
// ROCKSDB_NAMESPACE::TableFilter. // ROCKSDB_NAMESPACE::TableFilter.
#include "rocksjni/table_filter_jnicallback.h" #include "rocksjni/table_filter_jnicallback.h"
#include "rocksjni/portal.h" #include "rocksjni/portal.h"
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
TableFilterJniCallback::TableFilterJniCallback( TableFilterJniCallback::TableFilterJniCallback(JNIEnv* env,
JNIEnv* env, jobject jtable_filter) jobject jtable_filter)
: JniCallback(env, jtable_filter) { : JniCallback(env, jtable_filter) {
m_jfilter_methodid = m_jfilter_methodid = AbstractTableFilterJni::getFilterMethod(env);
AbstractTableFilterJni::getFilterMethod(env);
if (m_jfilter_methodid == nullptr) { if (m_jfilter_methodid == nullptr) {
// exception thrown: NoSuchMethodException or OutOfMemoryError // exception thrown: NoSuchMethodException or OutOfMemoryError
return; return;

View file

@ -10,6 +10,7 @@
#define JAVA_ROCKSJNI_TABLE_FILTER_JNICALLBACK_H_ #define JAVA_ROCKSJNI_TABLE_FILTER_JNICALLBACK_H_
#include <jni.h> #include <jni.h>
#include <functional> #include <functional>
#include <memory> #include <memory>
@ -20,8 +21,7 @@ namespace ROCKSDB_NAMESPACE {
class TableFilterJniCallback : public JniCallback { class TableFilterJniCallback : public JniCallback {
public: public:
TableFilterJniCallback( TableFilterJniCallback(JNIEnv* env, jobject jtable_filter);
JNIEnv* env, jobject jtable_filter);
std::function<bool(const ROCKSDB_NAMESPACE::TableProperties&)> std::function<bool(const ROCKSDB_NAMESPACE::TableProperties&)>
GetTableFilterFunction(); GetTableFilterFunction();

View file

@ -6,11 +6,12 @@
// This file implements the "bridge" between Java and C++ and enables // This file implements the "bridge" between Java and C++ and enables
// calling c++ ROCKSDB_NAMESPACE::ThreadStatus methods from Java side. // calling c++ ROCKSDB_NAMESPACE::ThreadStatus methods from Java side.
#include "rocksdb/thread_status.h"
#include <jni.h> #include <jni.h>
#include "portal.h"
#include "include/org_rocksdb_ThreadStatus.h" #include "include/org_rocksdb_ThreadStatus.h"
#include "rocksdb/thread_status.h" #include "portal.h"
/* /*
* Class: org_rocksdb_ThreadStatus * Class: org_rocksdb_ThreadStatus
@ -42,8 +43,8 @@ jstring Java_org_rocksdb_ThreadStatus_getOperationName(
* Method: microsToStringNative * Method: microsToStringNative
* Signature: (J)Ljava/lang/String; * Signature: (J)Ljava/lang/String;
*/ */
jstring Java_org_rocksdb_ThreadStatus_microsToStringNative( jstring Java_org_rocksdb_ThreadStatus_microsToStringNative(JNIEnv* env, jclass,
JNIEnv* env, jclass, jlong jmicros) { jlong jmicros) {
auto str = ROCKSDB_NAMESPACE::ThreadStatus::MicrosToString( auto str = ROCKSDB_NAMESPACE::ThreadStatus::MicrosToString(
static_cast<uint64_t>(jmicros)); static_cast<uint64_t>(jmicros));
return ROCKSDB_NAMESPACE::JniUtil::toJavaString(env, &str, true); return ROCKSDB_NAMESPACE::JniUtil::toJavaString(env, &str, true);
@ -84,7 +85,6 @@ jstring Java_org_rocksdb_ThreadStatus_getOperationPropertyName(
jobject Java_org_rocksdb_ThreadStatus_interpretOperationProperties( jobject Java_org_rocksdb_ThreadStatus_interpretOperationProperties(
JNIEnv* env, jclass, jbyte joperation_type_value, JNIEnv* env, jclass, jbyte joperation_type_value,
jlongArray joperation_properties) { jlongArray joperation_properties) {
// convert joperation_properties // convert joperation_properties
const jsize len = env->GetArrayLength(joperation_properties); const jsize len = env->GetArrayLength(joperation_properties);
const std::unique_ptr<uint64_t[]> op_properties(new uint64_t[len]); const std::unique_ptr<uint64_t[]> op_properties(new uint64_t[len]);
@ -117,8 +117,8 @@ jobject Java_org_rocksdb_ThreadStatus_interpretOperationProperties(
* Method: getStateName * Method: getStateName
* Signature: (B)Ljava/lang/String; * Signature: (B)Ljava/lang/String;
*/ */
jstring Java_org_rocksdb_ThreadStatus_getStateName( jstring Java_org_rocksdb_ThreadStatus_getStateName(JNIEnv* env, jclass,
JNIEnv* env, jclass, jbyte jstate_type_value) { jbyte jstate_type_value) {
auto name = ROCKSDB_NAMESPACE::ThreadStatus::GetStateName( auto name = ROCKSDB_NAMESPACE::ThreadStatus::GetStateName(
ROCKSDB_NAMESPACE::StateTypeJni::toCppStateType(jstate_type_value)); ROCKSDB_NAMESPACE::StateTypeJni::toCppStateType(jstate_type_value));
return ROCKSDB_NAMESPACE::JniUtil::toJavaString(env, &name, true); return ROCKSDB_NAMESPACE::JniUtil::toJavaString(env, &name, true);

View file

@ -17,8 +17,8 @@
* Method: createNewTraceWriter * Method: createNewTraceWriter
* Signature: ()J * Signature: ()J
*/ */
jlong Java_org_rocksdb_AbstractTraceWriter_createNewTraceWriter( jlong Java_org_rocksdb_AbstractTraceWriter_createNewTraceWriter(JNIEnv* env,
JNIEnv* env, jobject jobj) { jobject jobj) {
auto* trace_writer = new ROCKSDB_NAMESPACE::TraceWriterJniCallback(env, jobj); auto* trace_writer = new ROCKSDB_NAMESPACE::TraceWriterJniCallback(env, jobj);
return GET_CPLUSPLUS_POINTER(trace_writer); return GET_CPLUSPLUS_POINTER(trace_writer);
} }

View file

@ -7,14 +7,14 @@
// ROCKSDB_NAMESPACE::TraceWriter. // ROCKSDB_NAMESPACE::TraceWriter.
#include "rocksjni/trace_writer_jnicallback.h" #include "rocksjni/trace_writer_jnicallback.h"
#include "rocksjni/portal.h" #include "rocksjni/portal.h"
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
TraceWriterJniCallback::TraceWriterJniCallback( TraceWriterJniCallback::TraceWriterJniCallback(JNIEnv* env,
JNIEnv* env, jobject jtrace_writer) jobject jtrace_writer)
: JniCallback(env, jtrace_writer) { : JniCallback(env, jtrace_writer) {
m_jwrite_proxy_methodid = m_jwrite_proxy_methodid = AbstractTraceWriterJni::getWriteProxyMethodId(env);
AbstractTraceWriterJni::getWriteProxyMethodId(env);
if (m_jwrite_proxy_methodid == nullptr) { if (m_jwrite_proxy_methodid == nullptr) {
// exception thrown: NoSuchMethodException or OutOfMemoryError // exception thrown: NoSuchMethodException or OutOfMemoryError
return; return;
@ -42,21 +42,22 @@ Status TraceWriterJniCallback::Write(const Slice& data) {
return Status::IOError("Unable to attach JNI Environment"); return Status::IOError("Unable to attach JNI Environment");
} }
jshort jstatus = env->CallShortMethod(m_jcallback_obj, jshort jstatus =
m_jwrite_proxy_methodid, env->CallShortMethod(m_jcallback_obj, m_jwrite_proxy_methodid, &data);
&data);
if (env->ExceptionCheck()) { if (env->ExceptionCheck()) {
// exception thrown from CallShortMethod // exception thrown from CallShortMethod
env->ExceptionDescribe(); // print out exception to stderr env->ExceptionDescribe(); // print out exception to stderr
releaseJniEnv(attached_thread); releaseJniEnv(attached_thread);
return Status::IOError("Unable to call AbstractTraceWriter#writeProxy(long)"); return Status::IOError(
"Unable to call AbstractTraceWriter#writeProxy(long)");
} }
// unpack status code and status sub-code from jstatus // unpack status code and status sub-code from jstatus
jbyte jcode_value = (jstatus >> 8) & 0xFF; jbyte jcode_value = (jstatus >> 8) & 0xFF;
jbyte jsub_code_value = jstatus & 0xFF; jbyte jsub_code_value = jstatus & 0xFF;
std::unique_ptr<Status> s = StatusJni::toCppStatus(jcode_value, jsub_code_value); std::unique_ptr<Status> s =
StatusJni::toCppStatus(jcode_value, jsub_code_value);
releaseJniEnv(attached_thread); releaseJniEnv(attached_thread);
@ -70,20 +71,22 @@ Status TraceWriterJniCallback::Close() {
return Status::IOError("Unable to attach JNI Environment"); return Status::IOError("Unable to attach JNI Environment");
} }
jshort jstatus = env->CallShortMethod(m_jcallback_obj, jshort jstatus =
m_jclose_writer_proxy_methodid); env->CallShortMethod(m_jcallback_obj, m_jclose_writer_proxy_methodid);
if (env->ExceptionCheck()) { if (env->ExceptionCheck()) {
// exception thrown from CallShortMethod // exception thrown from CallShortMethod
env->ExceptionDescribe(); // print out exception to stderr env->ExceptionDescribe(); // print out exception to stderr
releaseJniEnv(attached_thread); releaseJniEnv(attached_thread);
return Status::IOError("Unable to call AbstractTraceWriter#closeWriterProxy()"); return Status::IOError(
"Unable to call AbstractTraceWriter#closeWriterProxy()");
} }
// unpack status code and status sub-code from jstatus // unpack status code and status sub-code from jstatus
jbyte code_value = (jstatus >> 8) & 0xFF; jbyte code_value = (jstatus >> 8) & 0xFF;
jbyte sub_code_value = jstatus & 0xFF; jbyte sub_code_value = jstatus & 0xFF;
std::unique_ptr<Status> s = StatusJni::toCppStatus(code_value, sub_code_value); std::unique_ptr<Status> s =
StatusJni::toCppStatus(code_value, sub_code_value);
releaseJniEnv(attached_thread); releaseJniEnv(attached_thread);
@ -97,8 +100,8 @@ uint64_t TraceWriterJniCallback::GetFileSize() {
return 0; return 0;
} }
jlong jfile_size = env->CallLongMethod(m_jcallback_obj, jlong jfile_size =
m_jget_file_size_methodid); env->CallLongMethod(m_jcallback_obj, m_jget_file_size_methodid);
if (env->ExceptionCheck()) { if (env->ExceptionCheck()) {
// exception thrown from CallLongMethod // exception thrown from CallLongMethod

View file

@ -10,6 +10,7 @@
#define JAVA_ROCKSJNI_TRACE_WRITER_JNICALLBACK_H_ #define JAVA_ROCKSJNI_TRACE_WRITER_JNICALLBACK_H_
#include <jni.h> #include <jni.h>
#include <memory> #include <memory>
#include "rocksdb/trace_reader_writer.h" #include "rocksdb/trace_reader_writer.h"
@ -19,8 +20,7 @@ namespace ROCKSDB_NAMESPACE {
class TraceWriterJniCallback : public JniCallback, public TraceWriter { class TraceWriterJniCallback : public JniCallback, public TraceWriter {
public: public:
TraceWriterJniCallback( TraceWriterJniCallback(JNIEnv* env, jobject jtrace_writer);
JNIEnv* env, jobject jtrace_writer);
virtual Status Write(const Slice& data); virtual Status Write(const Slice& data);
virtual Status Close(); virtual Status Close();
virtual uint64_t GetFileSize(); virtual uint64_t GetFileSize();

View file

@ -190,7 +190,8 @@ jbyteArray txn_get_helper(JNIEnv* env, const FnGet& fn_get,
// exception thrown: OutOfMemoryError // exception thrown: OutOfMemoryError
return nullptr; return nullptr;
} }
env->SetByteArrayRegion(jret_value, 0, static_cast<jsize>(value.size()), env->SetByteArrayRegion(
jret_value, 0, static_cast<jsize>(value.size()),
const_cast<jbyte*>(reinterpret_cast<const jbyte*>(value.c_str()))); const_cast<jbyte*>(reinterpret_cast<const jbyte*>(value.c_str())));
if (env->ExceptionCheck()) { if (env->ExceptionCheck()) {
// exception thrown: ArrayIndexOutOfBoundsException // exception thrown: ArrayIndexOutOfBoundsException
@ -366,7 +367,8 @@ jobjectArray txn_multi_get_helper(JNIEnv* env, const FnMultiGet& fn_multi_get,
env->SetByteArrayRegion( env->SetByteArrayRegion(
jentry_value, 0, static_cast<jsize>(value_parts[i].size()), jentry_value, 0, static_cast<jsize>(value_parts[i].size()),
const_cast<jbyte*>(reinterpret_cast<const jbyte*>(value_parts[i].c_str()))); const_cast<jbyte*>(
reinterpret_cast<const jbyte*>(value_parts[i].c_str())));
if (env->ExceptionCheck()) { if (env->ExceptionCheck()) {
// exception thrown: ArrayIndexOutOfBoundsException // exception thrown: ArrayIndexOutOfBoundsException
env->DeleteLocalRef(jentry_value); env->DeleteLocalRef(jentry_value);

View file

@ -26,8 +26,8 @@
* Signature: (JJLjava/lang/String;)J * Signature: (JJLjava/lang/String;)J
*/ */
jlong Java_org_rocksdb_TransactionDB_open__JJLjava_lang_String_2( jlong Java_org_rocksdb_TransactionDB_open__JJLjava_lang_String_2(
JNIEnv* env, jclass, jlong joptions_handle, JNIEnv* env, jclass, jlong joptions_handle, jlong jtxn_db_options_handle,
jlong jtxn_db_options_handle, jstring jdb_path) { jstring jdb_path) {
auto* options = auto* options =
reinterpret_cast<ROCKSDB_NAMESPACE::Options*>(joptions_handle); reinterpret_cast<ROCKSDB_NAMESPACE::Options*>(joptions_handle);
auto* txn_db_options = auto* txn_db_options =
@ -57,8 +57,8 @@ jlong Java_org_rocksdb_TransactionDB_open__JJLjava_lang_String_2(
* Signature: (JJLjava/lang/String;[[B[J)[J * Signature: (JJLjava/lang/String;[[B[J)[J
*/ */
jlongArray Java_org_rocksdb_TransactionDB_open__JJLjava_lang_String_2_3_3B_3J( jlongArray Java_org_rocksdb_TransactionDB_open__JJLjava_lang_String_2_3_3B_3J(
JNIEnv* env, jclass, jlong jdb_options_handle, JNIEnv* env, jclass, jlong jdb_options_handle, jlong jtxn_db_options_handle,
jlong jtxn_db_options_handle, jstring jdb_path, jobjectArray jcolumn_names, jstring jdb_path, jobjectArray jcolumn_names,
jlongArray jcolumn_options_handles) { jlongArray jcolumn_options_handles) {
const char* db_path = env->GetStringUTFChars(jdb_path, nullptr); const char* db_path = env->GetStringUTFChars(jdb_path, nullptr);
if (db_path == nullptr) { if (db_path == nullptr) {
@ -161,8 +161,8 @@ jlongArray Java_org_rocksdb_TransactionDB_open__JJLjava_lang_String_2_3_3B_3J(
* Method: disposeInternal * Method: disposeInternal
* Signature: (J)V * Signature: (J)V
*/ */
void Java_org_rocksdb_TransactionDB_disposeInternal( void Java_org_rocksdb_TransactionDB_disposeInternal(JNIEnv*, jobject,
JNIEnv*, jobject, jlong jhandle) { jlong jhandle) {
auto* txn_db = reinterpret_cast<ROCKSDB_NAMESPACE::TransactionDB*>(jhandle); auto* txn_db = reinterpret_cast<ROCKSDB_NAMESPACE::TransactionDB*>(jhandle);
assert(txn_db != nullptr); assert(txn_db != nullptr);
delete txn_db; delete txn_db;
@ -173,8 +173,8 @@ void Java_org_rocksdb_TransactionDB_disposeInternal(
* Method: closeDatabase * Method: closeDatabase
* Signature: (J)V * Signature: (J)V
*/ */
void Java_org_rocksdb_TransactionDB_closeDatabase( void Java_org_rocksdb_TransactionDB_closeDatabase(JNIEnv* env, jclass,
JNIEnv* env, jclass, jlong jhandle) { jlong jhandle) {
auto* txn_db = reinterpret_cast<ROCKSDB_NAMESPACE::TransactionDB*>(jhandle); auto* txn_db = reinterpret_cast<ROCKSDB_NAMESPACE::TransactionDB*>(jhandle);
assert(txn_db != nullptr); assert(txn_db != nullptr);
ROCKSDB_NAMESPACE::Status s = txn_db->Close(); ROCKSDB_NAMESPACE::Status s = txn_db->Close();
@ -270,8 +270,9 @@ jlong Java_org_rocksdb_TransactionDB_beginTransaction_1withOld__JJJJ(
* Method: getTransactionByName * Method: getTransactionByName
* Signature: (JLjava/lang/String;)J * Signature: (JLjava/lang/String;)J
*/ */
jlong Java_org_rocksdb_TransactionDB_getTransactionByName( jlong Java_org_rocksdb_TransactionDB_getTransactionByName(JNIEnv* env, jobject,
JNIEnv* env, jobject, jlong jhandle, jstring jname) { jlong jhandle,
jstring jname) {
auto* txn_db = reinterpret_cast<ROCKSDB_NAMESPACE::TransactionDB*>(jhandle); auto* txn_db = reinterpret_cast<ROCKSDB_NAMESPACE::TransactionDB*>(jhandle);
const char* name = env->GetStringUTFChars(jname, nullptr); const char* name = env->GetStringUTFChars(jname, nullptr);
if (name == nullptr) { if (name == nullptr) {
@ -323,8 +324,8 @@ jlongArray Java_org_rocksdb_TransactionDB_getAllPreparedTransactions(
* Method: getLockStatusData * Method: getLockStatusData
* Signature: (J)Ljava/util/Map; * Signature: (J)Ljava/util/Map;
*/ */
jobject Java_org_rocksdb_TransactionDB_getLockStatusData( jobject Java_org_rocksdb_TransactionDB_getLockStatusData(JNIEnv* env, jobject,
JNIEnv* env, jobject, jlong jhandle) { jlong jhandle) {
auto* txn_db = reinterpret_cast<ROCKSDB_NAMESPACE::TransactionDB*>(jhandle); auto* txn_db = reinterpret_cast<ROCKSDB_NAMESPACE::TransactionDB*>(jhandle);
const std::unordered_multimap<uint32_t, ROCKSDB_NAMESPACE::KeyLockInfo> const std::unordered_multimap<uint32_t, ROCKSDB_NAMESPACE::KeyLockInfo>
lock_status_data = txn_db->GetLockStatusData(); lock_status_data = txn_db->GetLockStatusData();

View file

@ -6,12 +6,13 @@
// This file implements the "bridge" between Java and C++ and enables // This file implements the "bridge" between Java and C++ and enables
// calling c++ ROCKSDB_NAMESPACE::Iterator methods from Java side. // calling c++ ROCKSDB_NAMESPACE::Iterator methods from Java side.
#include "rocksdb/transaction_log.h"
#include <jni.h> #include <jni.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "include/org_rocksdb_TransactionLogIterator.h" #include "include/org_rocksdb_TransactionLogIterator.h"
#include "rocksdb/transaction_log.h"
#include "rocksjni/portal.h" #include "rocksjni/portal.h"
/* /*

View file

@ -13,8 +13,9 @@
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
TransactionNotifierJniCallback::TransactionNotifierJniCallback(JNIEnv* env, TransactionNotifierJniCallback::TransactionNotifierJniCallback(
jobject jtransaction_notifier) : JniCallback(env, jtransaction_notifier) { JNIEnv* env, jobject jtransaction_notifier)
: JniCallback(env, jtransaction_notifier) {
// we cache the method id for the JNI callback // we cache the method id for the JNI callback
m_jsnapshot_created_methodID = m_jsnapshot_created_methodID =
AbstractTransactionNotifierJni::getSnapshotCreatedMethodId(env); AbstractTransactionNotifierJni::getSnapshotCreatedMethodId(env);

View file

@ -25,8 +25,8 @@
* Method: open * Method: open
* Signature: (JLjava/lang/String;IZ)J * Signature: (JLjava/lang/String;IZ)J
*/ */
jlong Java_org_rocksdb_TtlDB_open( jlong Java_org_rocksdb_TtlDB_open(JNIEnv* env, jclass, jlong joptions_handle,
JNIEnv* env, jclass, jlong joptions_handle, jstring jdb_path, jint jttl, jstring jdb_path, jint jttl,
jboolean jread_only) { jboolean jread_only) {
const char* db_path = env->GetStringUTFChars(jdb_path, nullptr); const char* db_path = env->GetStringUTFChars(jdb_path, nullptr);
if (db_path == nullptr) { if (db_path == nullptr) {
@ -55,9 +55,10 @@ jlong Java_org_rocksdb_TtlDB_open(
* Method: openCF * Method: openCF
* Signature: (JLjava/lang/String;[[B[J[IZ)[J * Signature: (JLjava/lang/String;[[B[J[IZ)[J
*/ */
jlongArray Java_org_rocksdb_TtlDB_openCF( jlongArray Java_org_rocksdb_TtlDB_openCF(JNIEnv* env, jclass, jlong jopt_handle,
JNIEnv* env, jclass, jlong jopt_handle, jstring jdb_path, jstring jdb_path,
jobjectArray jcolumn_names, jlongArray jcolumn_options, jobjectArray jcolumn_names,
jlongArray jcolumn_options,
jintArray jttls, jboolean jread_only) { jintArray jttls, jboolean jread_only) {
const char* db_path = env->GetStringUTFChars(jdb_path, nullptr); const char* db_path = env->GetStringUTFChars(jdb_path, nullptr);
if (db_path == nullptr) { if (db_path == nullptr) {
@ -153,8 +154,7 @@ jlongArray Java_org_rocksdb_TtlDB_openCF(
* Method: disposeInternal * Method: disposeInternal
* Signature: (J)V * Signature: (J)V
*/ */
void Java_org_rocksdb_TtlDB_disposeInternal( void Java_org_rocksdb_TtlDB_disposeInternal(JNIEnv*, jobject, jlong jhandle) {
JNIEnv*, jobject, jlong jhandle) {
auto* ttl_db = reinterpret_cast<ROCKSDB_NAMESPACE::DBWithTTL*>(jhandle); auto* ttl_db = reinterpret_cast<ROCKSDB_NAMESPACE::DBWithTTL*>(jhandle);
assert(ttl_db != nullptr); assert(ttl_db != nullptr);
delete ttl_db; delete ttl_db;
@ -165,14 +165,15 @@ void Java_org_rocksdb_TtlDB_disposeInternal(
* Method: closeDatabase * Method: closeDatabase
* Signature: (J)V * Signature: (J)V
*/ */
void Java_org_rocksdb_TtlDB_closeDatabase( void Java_org_rocksdb_TtlDB_closeDatabase(JNIEnv* /* env */, jclass,
JNIEnv* /* env */, jclass, jlong /* jhandle */) { jlong /* jhandle */) {
// auto* ttl_db = reinterpret_cast<ROCKSDB_NAMESPACE::DBWithTTL*>(jhandle); // auto* ttl_db = reinterpret_cast<ROCKSDB_NAMESPACE::DBWithTTL*>(jhandle);
// assert(ttl_db != nullptr); // assert(ttl_db != nullptr);
// ROCKSDB_NAMESPACE::Status s = ttl_db->Close(); // ROCKSDB_NAMESPACE::Status s = ttl_db->Close();
// ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s); // ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s);
//TODO(AR) this is disabled until https://github.com/facebook/rocksdb/issues/4818 is resolved! // TODO(AR) this is disabled until
// https://github.com/facebook/rocksdb/issues/4818 is resolved!
} }
/* /*
@ -180,9 +181,11 @@ void Java_org_rocksdb_TtlDB_closeDatabase(
* Method: createColumnFamilyWithTtl * Method: createColumnFamilyWithTtl
* Signature: (JLorg/rocksdb/ColumnFamilyDescriptor;[BJI)J; * Signature: (JLorg/rocksdb/ColumnFamilyDescriptor;[BJI)J;
*/ */
jlong Java_org_rocksdb_TtlDB_createColumnFamilyWithTtl( jlong Java_org_rocksdb_TtlDB_createColumnFamilyWithTtl(JNIEnv* env, jobject,
JNIEnv* env, jobject, jlong jdb_handle, jbyteArray jcolumn_name, jlong jdb_handle,
jlong jcolumn_options, jint jttl) { jbyteArray jcolumn_name,
jlong jcolumn_options,
jint jttl) {
jbyte* cfname = env->GetByteArrayElements(jcolumn_name, nullptr); jbyte* cfname = env->GetByteArrayElements(jcolumn_name, nullptr);
if (cfname == nullptr) { if (cfname == nullptr) {
// exception thrown: OutOfMemoryError // exception thrown: OutOfMemoryError

View file

@ -17,8 +17,8 @@
* Method: createNewWalFilter * Method: createNewWalFilter
* Signature: ()J * Signature: ()J
*/ */
jlong Java_org_rocksdb_AbstractWalFilter_createNewWalFilter( jlong Java_org_rocksdb_AbstractWalFilter_createNewWalFilter(JNIEnv* env,
JNIEnv* env, jobject jobj) { jobject jobj) {
auto* wal_filter = new ROCKSDB_NAMESPACE::WalFilterJniCallback(env, jobj); auto* wal_filter = new ROCKSDB_NAMESPACE::WalFilterJniCallback(env, jobj);
return GET_CPLUSPLUS_POINTER(wal_filter); return GET_CPLUSPLUS_POINTER(wal_filter);
} }

View file

@ -12,8 +12,7 @@
#include "rocksjni/portal.h" #include "rocksjni/portal.h"
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
WalFilterJniCallback::WalFilterJniCallback( WalFilterJniCallback::WalFilterJniCallback(JNIEnv* env, jobject jwal_filter)
JNIEnv* env, jobject jwal_filter)
: JniCallback(env, jwal_filter) { : JniCallback(env, jwal_filter) {
// Note: The name of a WalFilter will not change during it's lifetime, // Note: The name of a WalFilter will not change during it's lifetime,
// so we cache it in a global var // so we cache it in a global var
@ -78,10 +77,8 @@ void WalFilterJniCallback::ColumnFamilyLogNumberMap(
return; return;
} }
env->CallVoidMethod(m_jcallback_obj, env->CallVoidMethod(m_jcallback_obj, m_column_family_log_number_map_mid,
m_column_family_log_number_map_mid, jcf_lognumber_map, jcf_name_id_map);
jcf_lognumber_map,
jcf_name_id_map);
env->DeleteLocalRef(jcf_lognumber_map); env->DeleteLocalRef(jcf_lognumber_map);
env->DeleteLocalRef(jcf_name_id_map); env->DeleteLocalRef(jcf_name_id_map);
@ -137,8 +134,6 @@ void WalFilterJniCallback::ColumnFamilyLogNumberMap(
jwal_processing_option_value); jwal_processing_option_value);
} }
const char* WalFilterJniCallback::Name() const { const char* WalFilterJniCallback::Name() const { return m_name.get(); }
return m_name.get();
}
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

View file

@ -10,6 +10,7 @@
#define JAVA_ROCKSJNI_WAL_FILTER_JNICALLBACK_H_ #define JAVA_ROCKSJNI_WAL_FILTER_JNICALLBACK_H_
#include <jni.h> #include <jni.h>
#include <map> #include <map>
#include <memory> #include <memory>
#include <string> #include <string>
@ -21,8 +22,7 @@ namespace ROCKSDB_NAMESPACE {
class WalFilterJniCallback : public JniCallback, public WalFilter { class WalFilterJniCallback : public JniCallback, public WalFilter {
public: public:
WalFilterJniCallback( WalFilterJniCallback(JNIEnv* env, jobject jwal_filter);
JNIEnv* env, jobject jwal_filter);
virtual void ColumnFamilyLogNumberMap( virtual void ColumnFamilyLogNumberMap(
const std::map<uint32_t, uint64_t>& cf_lognumber_map, const std::map<uint32_t, uint64_t>& cf_lognumber_map,
const std::map<std::string, uint32_t>& cf_name_id_map); const std::map<std::string, uint32_t>& cf_name_id_map);

View file

@ -5,6 +5,8 @@
// //
// This file implements the "bridge" between Java and C++ and enables // This file implements the "bridge" between Java and C++ and enables
// calling c++ ROCKSDB_NAMESPACE::WriteBatch methods testing from Java side. // calling c++ ROCKSDB_NAMESPACE::WriteBatch methods testing from Java side.
#include "rocksdb/write_batch.h"
#include <memory> #include <memory>
#include "db/memtable.h" #include "db/memtable.h"
@ -18,7 +20,6 @@
#include "rocksdb/env.h" #include "rocksdb/env.h"
#include "rocksdb/memtablerep.h" #include "rocksdb/memtablerep.h"
#include "rocksdb/status.h" #include "rocksdb/status.h"
#include "rocksdb/write_batch.h"
#include "rocksdb/write_buffer_manager.h" #include "rocksdb/write_buffer_manager.h"
#include "rocksjni/portal.h" #include "rocksjni/portal.h"
#include "table/scoped_arena_iterator.h" #include "table/scoped_arena_iterator.h"

View file

@ -947,6 +947,7 @@ jlongArray Java_org_rocksdb_WBWIRocksIterator_entry1(JNIEnv* env,
* Signature: (J)V * Signature: (J)V
*/ */
void Java_org_rocksdb_WBWIRocksIterator_refresh0(JNIEnv* env) { void Java_org_rocksdb_WBWIRocksIterator_refresh0(JNIEnv* env) {
ROCKSDB_NAMESPACE::Status s = ROCKSDB_NAMESPACE::Status::NotSupported("Refresh() is not supported"); ROCKSDB_NAMESPACE::Status s =
ROCKSDB_NAMESPACE::Status::NotSupported("Refresh() is not supported");
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s); ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s);
} }

View file

@ -34,8 +34,9 @@ jlong Java_org_rocksdb_WriteBufferManager_newWriteBufferManager(
* Method: disposeInternal * Method: disposeInternal
* Signature: (J)V * Signature: (J)V
*/ */
void Java_org_rocksdb_WriteBufferManager_disposeInternal( void Java_org_rocksdb_WriteBufferManager_disposeInternal(JNIEnv* /*env*/,
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) { jobject /*jobj*/,
jlong jhandle) {
auto* write_buffer_manager = auto* write_buffer_manager =
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::WriteBufferManager>*>( reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::WriteBufferManager>*>(
jhandle); jhandle);

View file

@ -7,13 +7,13 @@
// ROCKSDB_NAMESPACE::Comparator. // ROCKSDB_NAMESPACE::Comparator.
#include "rocksjni/writebatchhandlerjnicallback.h" #include "rocksjni/writebatchhandlerjnicallback.h"
#include "rocksjni/portal.h" #include "rocksjni/portal.h"
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
WriteBatchHandlerJniCallback::WriteBatchHandlerJniCallback( WriteBatchHandlerJniCallback::WriteBatchHandlerJniCallback(
JNIEnv* env, jobject jWriteBatchHandler) JNIEnv* env, jobject jWriteBatchHandler)
: JniCallback(env, jWriteBatchHandler), m_env(env) { : JniCallback(env, jWriteBatchHandler), m_env(env) {
m_jPutCfMethodId = WriteBatchHandlerJni::getPutCfMethodId(env); m_jPutCfMethodId = WriteBatchHandlerJni::getPutCfMethodId(env);
if (m_jPutCfMethodId == nullptr) { if (m_jPutCfMethodId == nullptr) {
// exception thrown // exception thrown
@ -137,14 +137,9 @@ WriteBatchHandlerJniCallback::WriteBatchHandlerJniCallback(
ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::PutCF( ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::PutCF(
uint32_t column_family_id, const Slice& key, const Slice& value) { uint32_t column_family_id, const Slice& key, const Slice& value) {
auto put = [this, column_family_id] ( auto put = [this, column_family_id](jbyteArray j_key, jbyteArray j_value) {
jbyteArray j_key, jbyteArray j_value) { m_env->CallVoidMethod(m_jcallback_obj, m_jPutCfMethodId,
m_env->CallVoidMethod( static_cast<jint>(column_family_id), j_key, j_value);
m_jcallback_obj,
m_jPutCfMethodId,
static_cast<jint>(column_family_id),
j_key,
j_value);
}; };
auto status = WriteBatchHandlerJniCallback::kv_op(key, value, put); auto status = WriteBatchHandlerJniCallback::kv_op(key, value, put);
if (status == nullptr) { if (status == nullptr) {
@ -157,27 +152,17 @@ ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::PutCF(
} }
void WriteBatchHandlerJniCallback::Put(const Slice& key, const Slice& value) { void WriteBatchHandlerJniCallback::Put(const Slice& key, const Slice& value) {
auto put = [this] ( auto put = [this](jbyteArray j_key, jbyteArray j_value) {
jbyteArray j_key, jbyteArray j_value) { m_env->CallVoidMethod(m_jcallback_obj, m_jPutMethodId, j_key, j_value);
m_env->CallVoidMethod(
m_jcallback_obj,
m_jPutMethodId,
j_key,
j_value);
}; };
WriteBatchHandlerJniCallback::kv_op(key, value, put); WriteBatchHandlerJniCallback::kv_op(key, value, put);
} }
ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MergeCF( ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MergeCF(
uint32_t column_family_id, const Slice& key, const Slice& value) { uint32_t column_family_id, const Slice& key, const Slice& value) {
auto merge = [this, column_family_id] ( auto merge = [this, column_family_id](jbyteArray j_key, jbyteArray j_value) {
jbyteArray j_key, jbyteArray j_value) { m_env->CallVoidMethod(m_jcallback_obj, m_jMergeCfMethodId,
m_env->CallVoidMethod( static_cast<jint>(column_family_id), j_key, j_value);
m_jcallback_obj,
m_jMergeCfMethodId,
static_cast<jint>(column_family_id),
j_key,
j_value);
}; };
auto status = WriteBatchHandlerJniCallback::kv_op(key, value, merge); auto status = WriteBatchHandlerJniCallback::kv_op(key, value, merge);
if (status == nullptr) { if (status == nullptr) {
@ -190,13 +175,8 @@ ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MergeCF(
} }
void WriteBatchHandlerJniCallback::Merge(const Slice& key, const Slice& value) { void WriteBatchHandlerJniCallback::Merge(const Slice& key, const Slice& value) {
auto merge = [this] ( auto merge = [this](jbyteArray j_key, jbyteArray j_value) {
jbyteArray j_key, jbyteArray j_value) { m_env->CallVoidMethod(m_jcallback_obj, m_jMergeMethodId, j_key, j_value);
m_env->CallVoidMethod(
m_jcallback_obj,
m_jMergeMethodId,
j_key,
j_value);
}; };
WriteBatchHandlerJniCallback::kv_op(key, value, merge); WriteBatchHandlerJniCallback::kv_op(key, value, merge);
} }
@ -204,11 +184,8 @@ void WriteBatchHandlerJniCallback::Merge(const Slice& key, const Slice& value) {
ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::DeleteCF( ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::DeleteCF(
uint32_t column_family_id, const Slice& key) { uint32_t column_family_id, const Slice& key) {
auto remove = [this, column_family_id](jbyteArray j_key) { auto remove = [this, column_family_id](jbyteArray j_key) {
m_env->CallVoidMethod( m_env->CallVoidMethod(m_jcallback_obj, m_jDeleteCfMethodId,
m_jcallback_obj, static_cast<jint>(column_family_id), j_key);
m_jDeleteCfMethodId,
static_cast<jint>(column_family_id),
j_key);
}; };
auto status = WriteBatchHandlerJniCallback::k_op(key, remove); auto status = WriteBatchHandlerJniCallback::k_op(key, remove);
if (status == nullptr) { if (status == nullptr) {
@ -222,10 +199,7 @@ ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::DeleteCF(
void WriteBatchHandlerJniCallback::Delete(const Slice& key) { void WriteBatchHandlerJniCallback::Delete(const Slice& key) {
auto remove = [this](jbyteArray j_key) { auto remove = [this](jbyteArray j_key) {
m_env->CallVoidMethod( m_env->CallVoidMethod(m_jcallback_obj, m_jDeleteMethodId, j_key);
m_jcallback_obj,
m_jDeleteMethodId,
j_key);
}; };
WriteBatchHandlerJniCallback::k_op(key, remove); WriteBatchHandlerJniCallback::k_op(key, remove);
} }
@ -233,11 +207,8 @@ void WriteBatchHandlerJniCallback::Delete(const Slice& key) {
ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::SingleDeleteCF( ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::SingleDeleteCF(
uint32_t column_family_id, const Slice& key) { uint32_t column_family_id, const Slice& key) {
auto singleDelete = [this, column_family_id](jbyteArray j_key) { auto singleDelete = [this, column_family_id](jbyteArray j_key) {
m_env->CallVoidMethod( m_env->CallVoidMethod(m_jcallback_obj, m_jSingleDeleteCfMethodId,
m_jcallback_obj, static_cast<jint>(column_family_id), j_key);
m_jSingleDeleteCfMethodId,
static_cast<jint>(column_family_id),
j_key);
}; };
auto status = WriteBatchHandlerJniCallback::k_op(key, singleDelete); auto status = WriteBatchHandlerJniCallback::k_op(key, singleDelete);
if (status == nullptr) { if (status == nullptr) {
@ -251,26 +222,21 @@ ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::SingleDeleteCF(
void WriteBatchHandlerJniCallback::SingleDelete(const Slice& key) { void WriteBatchHandlerJniCallback::SingleDelete(const Slice& key) {
auto singleDelete = [this](jbyteArray j_key) { auto singleDelete = [this](jbyteArray j_key) {
m_env->CallVoidMethod( m_env->CallVoidMethod(m_jcallback_obj, m_jSingleDeleteMethodId, j_key);
m_jcallback_obj,
m_jSingleDeleteMethodId,
j_key);
}; };
WriteBatchHandlerJniCallback::k_op(key, singleDelete); WriteBatchHandlerJniCallback::k_op(key, singleDelete);
} }
ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::DeleteRangeCF( ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::DeleteRangeCF(
uint32_t column_family_id, const Slice& beginKey, const Slice& endKey) { uint32_t column_family_id, const Slice& beginKey, const Slice& endKey) {
auto deleteRange = [this, column_family_id] ( auto deleteRange = [this, column_family_id](jbyteArray j_beginKey,
jbyteArray j_beginKey, jbyteArray j_endKey) { jbyteArray j_endKey) {
m_env->CallVoidMethod( m_env->CallVoidMethod(m_jcallback_obj, m_jDeleteRangeCfMethodId,
m_jcallback_obj, static_cast<jint>(column_family_id), j_beginKey,
m_jDeleteRangeCfMethodId,
static_cast<jint>(column_family_id),
j_beginKey,
j_endKey); j_endKey);
}; };
auto status = WriteBatchHandlerJniCallback::kv_op(beginKey, endKey, deleteRange); auto status =
WriteBatchHandlerJniCallback::kv_op(beginKey, endKey, deleteRange);
if (status == nullptr) { if (status == nullptr) {
return ROCKSDB_NAMESPACE::Status::OK(); // TODO(AR) what to do if there is return ROCKSDB_NAMESPACE::Status::OK(); // TODO(AR) what to do if there is
// an Exception but we don't know // an Exception but we don't know
@ -282,12 +248,8 @@ ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::DeleteRangeCF(
void WriteBatchHandlerJniCallback::DeleteRange(const Slice& beginKey, void WriteBatchHandlerJniCallback::DeleteRange(const Slice& beginKey,
const Slice& endKey) { const Slice& endKey) {
auto deleteRange = [this] ( auto deleteRange = [this](jbyteArray j_beginKey, jbyteArray j_endKey) {
jbyteArray j_beginKey, jbyteArray j_endKey) { m_env->CallVoidMethod(m_jcallback_obj, m_jDeleteRangeMethodId, j_beginKey,
m_env->CallVoidMethod(
m_jcallback_obj,
m_jDeleteRangeMethodId,
j_beginKey,
j_endKey); j_endKey);
}; };
WriteBatchHandlerJniCallback::kv_op(beginKey, endKey, deleteRange); WriteBatchHandlerJniCallback::kv_op(beginKey, endKey, deleteRange);
@ -295,24 +257,17 @@ void WriteBatchHandlerJniCallback::DeleteRange(const Slice& beginKey,
void WriteBatchHandlerJniCallback::LogData(const Slice& blob) { void WriteBatchHandlerJniCallback::LogData(const Slice& blob) {
auto logData = [this](jbyteArray j_blob) { auto logData = [this](jbyteArray j_blob) {
m_env->CallVoidMethod( m_env->CallVoidMethod(m_jcallback_obj, m_jLogDataMethodId, j_blob);
m_jcallback_obj,
m_jLogDataMethodId,
j_blob);
}; };
WriteBatchHandlerJniCallback::k_op(blob, logData); WriteBatchHandlerJniCallback::k_op(blob, logData);
} }
ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::PutBlobIndexCF( ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::PutBlobIndexCF(
uint32_t column_family_id, const Slice& key, const Slice& value) { uint32_t column_family_id, const Slice& key, const Slice& value) {
auto putBlobIndex = [this, column_family_id] ( auto putBlobIndex = [this, column_family_id](jbyteArray j_key,
jbyteArray j_key, jbyteArray j_value) { jbyteArray j_value) {
m_env->CallVoidMethod( m_env->CallVoidMethod(m_jcallback_obj, m_jPutBlobIndexCfMethodId,
m_jcallback_obj, static_cast<jint>(column_family_id), j_key, j_value);
m_jPutBlobIndexCfMethodId,
static_cast<jint>(column_family_id),
j_key,
j_value);
}; };
auto status = WriteBatchHandlerJniCallback::kv_op(key, value, putBlobIndex); auto status = WriteBatchHandlerJniCallback::kv_op(key, value, putBlobIndex);
if (status == nullptr) { if (status == nullptr) {
@ -346,7 +301,8 @@ ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkBeginPrepare(
// better error code here // better error code here
} else { } else {
m_env->ExceptionClear(); // clear the exception, as we have extracted the status m_env->ExceptionClear(); // clear the exception, as we have extracted the
// status
return ROCKSDB_NAMESPACE::Status(*status); return ROCKSDB_NAMESPACE::Status(*status);
} }
} }
@ -356,12 +312,8 @@ ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkBeginPrepare(
ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkEndPrepare( ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkEndPrepare(
const Slice& xid) { const Slice& xid) {
auto markEndPrepare = [this] ( auto markEndPrepare = [this](jbyteArray j_xid) {
jbyteArray j_xid) { m_env->CallVoidMethod(m_jcallback_obj, m_jMarkEndPrepareMethodId, j_xid);
m_env->CallVoidMethod(
m_jcallback_obj,
m_jMarkEndPrepareMethodId,
j_xid);
}; };
auto status = WriteBatchHandlerJniCallback::k_op(xid, markEndPrepare); auto status = WriteBatchHandlerJniCallback::k_op(xid, markEndPrepare);
if (status == nullptr) { if (status == nullptr) {
@ -375,7 +327,8 @@ ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkEndPrepare(
ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkNoop( ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkNoop(
bool empty_batch) { bool empty_batch) {
m_env->CallVoidMethod(m_jcallback_obj, m_jMarkNoopMethodId, static_cast<jboolean>(empty_batch)); m_env->CallVoidMethod(m_jcallback_obj, m_jMarkNoopMethodId,
static_cast<jboolean>(empty_batch));
// check for Exception, in-particular RocksDBException // check for Exception, in-particular RocksDBException
if (m_env->ExceptionCheck()) { if (m_env->ExceptionCheck()) {
@ -390,7 +343,8 @@ ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkNoop(
// better error code here // better error code here
} else { } else {
m_env->ExceptionClear(); // clear the exception, as we have extracted the status m_env->ExceptionClear(); // clear the exception, as we have extracted the
// status
return ROCKSDB_NAMESPACE::Status(*status); return ROCKSDB_NAMESPACE::Status(*status);
} }
} }
@ -400,12 +354,8 @@ ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkNoop(
ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkRollback( ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkRollback(
const Slice& xid) { const Slice& xid) {
auto markRollback = [this] ( auto markRollback = [this](jbyteArray j_xid) {
jbyteArray j_xid) { m_env->CallVoidMethod(m_jcallback_obj, m_jMarkRollbackMethodId, j_xid);
m_env->CallVoidMethod(
m_jcallback_obj,
m_jMarkRollbackMethodId,
j_xid);
}; };
auto status = WriteBatchHandlerJniCallback::k_op(xid, markRollback); auto status = WriteBatchHandlerJniCallback::k_op(xid, markRollback);
if (status == nullptr) { if (status == nullptr) {
@ -419,12 +369,8 @@ ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkRollback(
ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkCommit( ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkCommit(
const Slice& xid) { const Slice& xid) {
auto markCommit = [this] ( auto markCommit = [this](jbyteArray j_xid) {
jbyteArray j_xid) { m_env->CallVoidMethod(m_jcallback_obj, m_jMarkCommitMethodId, j_xid);
m_env->CallVoidMethod(
m_jcallback_obj,
m_jMarkCommitMethodId,
j_xid);
}; };
auto status = WriteBatchHandlerJniCallback::k_op(xid, markCommit); auto status = WriteBatchHandlerJniCallback::k_op(xid, markCommit);
if (status == nullptr) { if (status == nullptr) {
@ -454,9 +400,8 @@ ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkCommitWithTimestamp(
} }
bool WriteBatchHandlerJniCallback::Continue() { bool WriteBatchHandlerJniCallback::Continue() {
jboolean jContinue = m_env->CallBooleanMethod( jboolean jContinue =
m_jcallback_obj, m_env->CallBooleanMethod(m_jcallback_obj, m_jContinueMethodId);
m_jContinueMethodId);
if (m_env->ExceptionCheck()) { if (m_env->ExceptionCheck()) {
// exception thrown // exception thrown
m_env->ExceptionDescribe(); m_env->ExceptionDescribe();
@ -510,7 +455,8 @@ std::unique_ptr<ROCKSDB_NAMESPACE::Status> WriteBatchHandlerJniCallback::kv_op(
return nullptr; return nullptr;
} else { } else {
m_env->ExceptionClear(); // clear the exception, as we have extracted the status m_env->ExceptionClear(); // clear the exception, as we have extracted the
// status
return status; return status;
} }
} }
@ -556,7 +502,8 @@ std::unique_ptr<ROCKSDB_NAMESPACE::Status> WriteBatchHandlerJniCallback::k_op(
return nullptr; return nullptr;
} else { } else {
m_env->ExceptionClear(); // clear the exception, as we have extracted the status m_env->ExceptionClear(); // clear the exception, as we have extracted the
// status
return status; return status;
} }
} }

View file

@ -9,11 +9,13 @@
#ifndef JAVA_ROCKSJNI_WRITEBATCHHANDLERJNICALLBACK_H_ #ifndef JAVA_ROCKSJNI_WRITEBATCHHANDLERJNICALLBACK_H_
#define JAVA_ROCKSJNI_WRITEBATCHHANDLERJNICALLBACK_H_ #define JAVA_ROCKSJNI_WRITEBATCHHANDLERJNICALLBACK_H_
#include <functional>
#include <jni.h> #include <jni.h>
#include <functional>
#include <memory> #include <memory>
#include "rocksjni/jnicallback.h"
#include "rocksdb/write_batch.h" #include "rocksdb/write_batch.h"
#include "rocksjni/jnicallback.h"
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
/** /**
@ -23,12 +25,11 @@ namespace ROCKSDB_NAMESPACE {
* which calls the appropriate Java method. * which calls the appropriate Java method.
* This enables Write Batch Handlers to be implemented in Java. * This enables Write Batch Handlers to be implemented in Java.
*/ */
class WriteBatchHandlerJniCallback : public JniCallback, public WriteBatch::Handler { class WriteBatchHandlerJniCallback : public JniCallback,
public WriteBatch::Handler {
public: public:
WriteBatchHandlerJniCallback( WriteBatchHandlerJniCallback(JNIEnv* env, jobject jWriteBackHandler);
JNIEnv* env, jobject jWriteBackHandler); Status PutCF(uint32_t column_family_id, const Slice& key, const Slice& value);
Status PutCF(uint32_t column_family_id, const Slice& key,
const Slice& value);
void Put(const Slice& key, const Slice& value); void Put(const Slice& key, const Slice& value);
Status MergeCF(uint32_t column_family_id, const Slice& key, Status MergeCF(uint32_t column_family_id, const Slice& key,
const Slice& value); const Slice& value);