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

View File

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

View File

@ -7,38 +7,40 @@
// ROCKSDB_NAMESPACE::CompactionFilterFactory.
#include "rocksjni/compaction_filter_factory_jnicallback.h"
#include "rocksjni/portal.h"
namespace ROCKSDB_NAMESPACE {
CompactionFilterFactoryJniCallback::CompactionFilterFactoryJniCallback(
JNIEnv* env, jobject jcompaction_filter_factory)
: JniCallback(env, jcompaction_filter_factory) {
// Note: The name of a CompactionFilterFactory will not change during
// it's lifetime, so we cache it in a global var
jmethodID jname_method_id =
AbstractCompactionFilterFactoryJni::getNameMethodId(env);
if(jname_method_id == nullptr) {
if (jname_method_id == nullptr) {
// exception thrown: NoSuchMethodException or OutOfMemoryError
return;
}
jstring jname =
(jstring)env->CallObjectMethod(m_jcallback_obj, jname_method_id);
if(env->ExceptionCheck()) {
if (env->ExceptionCheck()) {
// exception thrown
return;
}
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) {
// exception thrown
return;
}
m_jcreate_compaction_filter_methodid =
AbstractCompactionFilterFactoryJni::getCreateCompactionFilterMethodId(env);
if(m_jcreate_compaction_filter_methodid == nullptr) {
AbstractCompactionFilterFactoryJni::getCreateCompactionFilterMethodId(
env);
if (m_jcreate_compaction_filter_methodid == nullptr) {
// exception thrown: NoSuchMethodException or OutOfMemoryError
return;
}
@ -48,18 +50,19 @@ const char* CompactionFilterFactoryJniCallback::Name() const {
return m_name.get();
}
std::unique_ptr<CompactionFilter> CompactionFilterFactoryJniCallback::CreateCompactionFilter(
std::unique_ptr<CompactionFilter>
CompactionFilterFactoryJniCallback::CreateCompactionFilter(
const CompactionFilter::Context& context) {
jboolean attached_thread = JNI_FALSE;
JNIEnv* env = getJniEnv(&attached_thread);
assert(env != nullptr);
jlong addr_compaction_filter = env->CallLongMethod(m_jcallback_obj,
m_jcreate_compaction_filter_methodid,
static_cast<jboolean>(context.is_full_compaction),
static_cast<jboolean>(context.is_manual_compaction));
jlong addr_compaction_filter =
env->CallLongMethod(m_jcallback_obj, m_jcreate_compaction_filter_methodid,
static_cast<jboolean>(context.is_full_compaction),
static_cast<jboolean>(context.is_manual_compaction));
if(env->ExceptionCheck()) {
if (env->ExceptionCheck()) {
// exception thrown from CallLongMethod
env->ExceptionDescribe(); // print out exception to stderr
releaseJniEnv(attached_thread);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -7,18 +7,18 @@
// ROCKSDB_NAMESPACE::Comparator.
#include "rocksjni/comparatorjnicallback.h"
#include "rocksjni/portal.h"
namespace ROCKSDB_NAMESPACE {
ComparatorJniCallback::ComparatorJniCallback(
JNIEnv* env, jobject jcomparator,
const ComparatorJniCallbackOptions* options)
: JniCallback(env, jcomparator),
m_options(options) {
// cache the AbstractComparatorJniBridge class as we will reuse it many times for each callback
m_abstract_comparator_jni_bridge_clazz =
static_cast<jclass>(env->NewGlobalRef(AbstractComparatorJniBridge::getJClass(env)));
: JniCallback(env, jcomparator), m_options(options) {
// cache the AbstractComparatorJniBridge class as we will reuse it many times
// for each callback
m_abstract_comparator_jni_bridge_clazz = static_cast<jclass>(
env->NewGlobalRef(AbstractComparatorJniBridge::getJClass(env)));
// Note: The name of a Comparator will not change during it's lifetime,
// so we cache it in a global var
@ -34,7 +34,7 @@ ComparatorJniCallback::ComparatorJniCallback(
}
jboolean has_exception = JNI_FALSE;
m_name = JniUtil::copyString(env, js_name,
&has_exception); // also releases jsName
&has_exception); // also releases jsName
if (has_exception == JNI_TRUE) {
// exception thrown
return;
@ -52,16 +52,16 @@ ComparatorJniCallback::ComparatorJniCallback(
}
m_jshortest_mid =
AbstractComparatorJniBridge::getFindShortestSeparatorInternalMethodId(
env, m_abstract_comparator_jni_bridge_clazz);
AbstractComparatorJniBridge::getFindShortestSeparatorInternalMethodId(
env, m_abstract_comparator_jni_bridge_clazz);
if (m_jshortest_mid == nullptr) {
// exception thrown: NoSuchMethodException or OutOfMemoryError
return;
}
m_jshort_mid =
AbstractComparatorJniBridge::getFindShortSuccessorInternalMethodId(env,
m_abstract_comparator_jni_bridge_clazz);
AbstractComparatorJniBridge::getFindShortSuccessorInternalMethodId(
env, m_abstract_comparator_jni_bridge_clazz);
if (m_jshort_mid == nullptr) {
// exception thrown: NoSuchMethodException or OutOfMemoryError
return;
@ -69,9 +69,8 @@ ComparatorJniCallback::ComparatorJniCallback(
// do we need reusable buffers?
if (m_options->max_reused_buffer_size > -1) {
if (m_options->reused_synchronisation_type
== ReusedSynchronisationType::THREAD_LOCAL) {
if (m_options->reused_synchronisation_type ==
ReusedSynchronisationType::THREAD_LOCAL) {
// buffers reused per thread
UnrefHandler unref = [](void* ptr) {
ThreadLocalBuf* tlb = reinterpret_cast<ThreadLocalBuf*>(ptr);
@ -97,9 +96,9 @@ ComparatorJniCallback::ComparatorJniCallback(
m_jshort_buf_key = nullptr;
} else {
//buffers reused and shared across threads
const bool adaptive =
m_options->reused_synchronisation_type == ReusedSynchronisationType::ADAPTIVE_MUTEX;
// buffers reused and shared across threads
const bool adaptive = m_options->reused_synchronisation_type ==
ReusedSynchronisationType::ADAPTIVE_MUTEX;
mtx_compare = 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));
@ -220,9 +219,7 @@ ComparatorJniCallback::~ComparatorJniCallback() {
releaseJniEnv(attached_thread);
}
const char* ComparatorJniCallback::Name() const {
return m_name.get();
}
const char* ComparatorJniCallback::Name() const { return m_name.get(); }
int ComparatorJniCallback::Compare(const Slice& a, const Slice& b) const {
jboolean attached_thread = JNI_FALSE;
@ -236,38 +233,38 @@ int ComparatorJniCallback::Compare(const Slice& a, const Slice& b) const {
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) {
// exception occurred
MaybeUnlockForReuse(mtx_compare, reuse_jbuf_a || reuse_jbuf_b);
env->ExceptionDescribe(); // print out exception to stderr
env->ExceptionDescribe(); // print out exception to stderr
releaseJniEnv(attached_thread);
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) {
// exception occurred
if (!reuse_jbuf_a) {
DeleteBuffer(env, jcompare_buf_a);
}
MaybeUnlockForReuse(mtx_compare, reuse_jbuf_a || reuse_jbuf_b);
env->ExceptionDescribe(); // print out exception to stderr
env->ExceptionDescribe(); // print out exception to stderr
releaseJniEnv(attached_thread);
return 0;
}
jint result =
env->CallStaticIntMethod(
m_abstract_comparator_jni_bridge_clazz, m_jcompare_mid,
m_jcallback_obj,
jcompare_buf_a, reuse_jbuf_a ? a.size() : -1,
jcompare_buf_b, reuse_jbuf_b ? b.size() : -1);
jint result = env->CallStaticIntMethod(
m_abstract_comparator_jni_bridge_clazz, m_jcompare_mid, m_jcallback_obj,
jcompare_buf_a, reuse_jbuf_a ? a.size() : -1, jcompare_buf_b,
reuse_jbuf_b ? b.size() : -1);
if (env->ExceptionCheck()) {
// exception thrown from CallIntMethod
env->ExceptionDescribe(); // print out exception to stderr
result = 0; // we could not get a result from java callback so use 0
env->ExceptionDescribe(); // print out exception to stderr
result = 0; // we could not get a result from java callback so use 0
}
if (!reuse_jbuf_a) {
@ -284,8 +281,8 @@ int ComparatorJniCallback::Compare(const Slice& a, const Slice& b) const {
return result;
}
void ComparatorJniCallback::FindShortestSeparator(
std::string* start, const Slice& limit) const {
void ComparatorJniCallback::FindShortestSeparator(std::string* start,
const Slice& limit) const {
if (start == nullptr) {
return;
}
@ -294,88 +291,90 @@ void ComparatorJniCallback::FindShortestSeparator(
JNIEnv* env = getJniEnv(&attached_thread);
assert(env != nullptr);
const bool reuse_jbuf_start =
static_cast<int64_t>(start->length()) <= m_options->max_reused_buffer_size;
const bool reuse_jbuf_start = static_cast<int64_t>(start->length()) <=
m_options->max_reused_buffer_size;
const bool reuse_jbuf_limit =
static_cast<int64_t>(limit.size()) <= m_options->max_reused_buffer_size;
MaybeLockForReuse(mtx_shortest, reuse_jbuf_start || reuse_jbuf_limit);
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) {
// exception occurred
MaybeUnlockForReuse(mtx_shortest, reuse_jbuf_start || reuse_jbuf_limit);
env->ExceptionDescribe(); // print out exception to stderr
env->ExceptionDescribe(); // print out exception to stderr
releaseJniEnv(attached_thread);
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) {
// exception occurred
if (!reuse_jbuf_start) {
DeleteBuffer(env, j_start_buf);
}
MaybeUnlockForReuse(mtx_shortest, reuse_jbuf_start || reuse_jbuf_limit);
env->ExceptionDescribe(); // print out exception to stderr
env->ExceptionDescribe(); // print out exception to stderr
releaseJniEnv(attached_thread);
return;
}
jint jstart_len = env->CallStaticIntMethod(
m_abstract_comparator_jni_bridge_clazz, m_jshortest_mid,
m_jcallback_obj,
j_start_buf, reuse_jbuf_start ? start->length() : -1,
j_limit_buf, reuse_jbuf_limit ? limit.size() : -1);
m_abstract_comparator_jni_bridge_clazz, m_jshortest_mid, m_jcallback_obj,
j_start_buf, reuse_jbuf_start ? start->length() : -1, j_limit_buf,
reuse_jbuf_limit ? limit.size() : -1);
if (env->ExceptionCheck()) {
// exception thrown from CallIntMethod
env->ExceptionDescribe(); // print out exception to stderr
env->ExceptionDescribe(); // print out exception to stderr
} else if (static_cast<size_t>(jstart_len) != start->length()) {
// start buffer has changed in Java, so update `start` with the result
bool copy_from_non_direct = false;
if (reuse_jbuf_start) {
// reused a buffer
if (m_options->direct_buffer) {
// reused direct buffer
void* start_buf = env->GetDirectBufferAddress(j_start_buf);
if (start_buf == nullptr) {
if (!reuse_jbuf_start) {
DeleteBuffer(env, j_start_buf);
}
if (!reuse_jbuf_limit) {
DeleteBuffer(env, j_limit_buf);
}
MaybeUnlockForReuse(mtx_shortest, reuse_jbuf_start || reuse_jbuf_limit);
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(
env, "Unable to get Direct Buffer Address");
env->ExceptionDescribe(); // print out exception to stderr
releaseJniEnv(attached_thread);
return;
// reused a buffer
if (m_options->direct_buffer) {
// reused direct buffer
void* start_buf = env->GetDirectBufferAddress(j_start_buf);
if (start_buf == nullptr) {
if (!reuse_jbuf_start) {
DeleteBuffer(env, j_start_buf);
}
start->assign(static_cast<const char*>(start_buf), jstart_len);
} else {
// reused non-direct buffer
copy_from_non_direct = true;
if (!reuse_jbuf_limit) {
DeleteBuffer(env, j_limit_buf);
}
MaybeUnlockForReuse(mtx_shortest,
reuse_jbuf_start || reuse_jbuf_limit);
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(
env, "Unable to get Direct Buffer Address");
env->ExceptionDescribe(); // print out exception to stderr
releaseJniEnv(attached_thread);
return;
}
start->assign(static_cast<const char*>(start_buf), jstart_len);
} else {
// reused non-direct buffer
copy_from_non_direct = true;
}
} else {
// there was a new buffer
if (m_options->direct_buffer) {
// it was direct... don't forget to potentially truncate the `start` string
start->resize(jstart_len);
} else {
// it was non-direct
copy_from_non_direct = true;
}
// there was a new buffer
if (m_options->direct_buffer) {
// it was direct... don't forget to potentially truncate the `start`
// string
start->resize(jstart_len);
} else {
// it was non-direct
copy_from_non_direct = true;
}
}
if (copy_from_non_direct) {
jbyteArray jarray = ByteBufferJni::array(env, j_start_buf,
m_jbytebuffer_clazz);
jbyteArray jarray =
ByteBufferJni::array(env, j_start_buf, m_jbytebuffer_clazz);
if (jarray == nullptr) {
if (!reuse_jbuf_start) {
DeleteBuffer(env, j_start_buf);
@ -389,9 +388,12 @@ void ComparatorJniCallback::FindShortestSeparator(
return;
}
jboolean has_exception = JNI_FALSE;
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));
}, &has_exception);
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));
},
&has_exception);
env->DeleteLocalRef(jarray);
if (has_exception == JNI_TRUE) {
if (!reuse_jbuf_start) {
@ -420,8 +422,7 @@ void ComparatorJniCallback::FindShortestSeparator(
releaseJniEnv(attached_thread);
}
void ComparatorJniCallback::FindShortSuccessor(
std::string* key) const {
void ComparatorJniCallback::FindShortSuccessor(std::string* key) const {
if (key == nullptr) {
return;
}
@ -436,18 +437,18 @@ void ComparatorJniCallback::FindShortSuccessor(
MaybeLockForReuse(mtx_short, reuse_jbuf_key);
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) {
// exception occurred
MaybeUnlockForReuse(mtx_short, reuse_jbuf_key);
env->ExceptionDescribe(); // print out exception to stderr
env->ExceptionDescribe(); // print out exception to stderr
releaseJniEnv(attached_thread);
return;
}
jint jkey_len = env->CallStaticIntMethod(
m_abstract_comparator_jni_bridge_clazz, m_jshort_mid,
m_jcallback_obj,
m_abstract_comparator_jni_bridge_clazz, m_jshort_mid, m_jcallback_obj,
j_key_buf, reuse_jbuf_key ? key->length() : -1);
if (env->ExceptionCheck()) {
@ -459,49 +460,48 @@ void ComparatorJniCallback::FindShortSuccessor(
env->ExceptionDescribe(); // print out exception to stderr
releaseJniEnv(attached_thread);
return;
}
if (static_cast<size_t>(jkey_len) != key->length()) {
// key buffer has changed in Java, so update `key` with the result
bool copy_from_non_direct = false;
if (reuse_jbuf_key) {
// reused a buffer
if (m_options->direct_buffer) {
// reused direct buffer
void* key_buf = env->GetDirectBufferAddress(j_key_buf);
if (key_buf == nullptr) {
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(
env, "Unable to get Direct Buffer Address");
if (!reuse_jbuf_key) {
DeleteBuffer(env, j_key_buf);
}
MaybeUnlockForReuse(mtx_short, reuse_jbuf_key);
env->ExceptionDescribe(); // print out exception to stderr
releaseJniEnv(attached_thread);
return;
// reused a buffer
if (m_options->direct_buffer) {
// reused direct buffer
void* key_buf = env->GetDirectBufferAddress(j_key_buf);
if (key_buf == nullptr) {
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(
env, "Unable to get Direct Buffer Address");
if (!reuse_jbuf_key) {
DeleteBuffer(env, j_key_buf);
}
key->assign(static_cast<const char*>(key_buf), jkey_len);
} else {
// reused non-direct buffer
copy_from_non_direct = true;
MaybeUnlockForReuse(mtx_short, reuse_jbuf_key);
env->ExceptionDescribe(); // print out exception to stderr
releaseJniEnv(attached_thread);
return;
}
key->assign(static_cast<const char*>(key_buf), jkey_len);
} else {
// reused non-direct buffer
copy_from_non_direct = true;
}
} else {
// there was a new buffer
if (m_options->direct_buffer) {
// it was direct... don't forget to potentially truncate the `key` string
key->resize(jkey_len);
} else {
// it was non-direct
copy_from_non_direct = true;
}
// there was a new buffer
if (m_options->direct_buffer) {
// it was direct... don't forget to potentially truncate the `key`
// string
key->resize(jkey_len);
} else {
// it was non-direct
copy_from_non_direct = true;
}
}
if (copy_from_non_direct) {
jbyteArray jarray = ByteBufferJni::array(env, j_key_buf,
m_jbytebuffer_clazz);
jbyteArray jarray =
ByteBufferJni::array(env, j_key_buf, m_jbytebuffer_clazz);
if (jarray == nullptr) {
if (!reuse_jbuf_key) {
DeleteBuffer(env, j_key_buf);
}
@ -511,9 +511,12 @@ void ComparatorJniCallback::FindShortSuccessor(
return;
}
jboolean has_exception = JNI_FALSE;
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));
}, &has_exception);
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));
},
&has_exception);
env->DeleteLocalRef(jarray);
if (has_exception == JNI_TRUE) {
if (!reuse_jbuf_key) {
@ -539,8 +542,9 @@ void ComparatorJniCallback::FindShortSuccessor(
inline void ComparatorJniCallback::MaybeLockForReuse(
const std::unique_ptr<port::Mutex>& mutex, const bool cond) const {
// no need to lock if using thread_local
if (m_options->reused_synchronisation_type != ReusedSynchronisationType::THREAD_LOCAL
&& cond) {
if (m_options->reused_synchronisation_type !=
ReusedSynchronisationType::THREAD_LOCAL &&
cond) {
mutex.get()->Lock();
}
}
@ -548,18 +552,20 @@ inline void ComparatorJniCallback::MaybeLockForReuse(
inline void ComparatorJniCallback::MaybeUnlockForReuse(
const std::unique_ptr<port::Mutex>& mutex, const bool cond) const {
// no need to unlock if using thread_local
if (m_options->reused_synchronisation_type != ReusedSynchronisationType::THREAD_LOCAL
&& cond) {
if (m_options->reused_synchronisation_type !=
ReusedSynchronisationType::THREAD_LOCAL &&
cond) {
mutex.get()->Unlock();
}
}
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 (m_options->reused_synchronisation_type
== ReusedSynchronisationType::THREAD_LOCAL) {
if (m_options->reused_synchronisation_type ==
ReusedSynchronisationType::THREAD_LOCAL) {
// reuse thread-local bufffer
ThreadLocalBuf* tlb = reinterpret_cast<ThreadLocalBuf*>(tl_buf->Get());
if (tlb == nullptr) {
@ -576,25 +582,25 @@ jobject ComparatorJniCallback::GetBuffer(JNIEnv* env, const Slice& src,
}
return ReuseBuffer(env, src, tlb->jbuf);
} else {
// reuse class member buffer
return ReuseBuffer(env, src, jreuse_buffer);
}
} else {
// new buffer
return NewBuffer(env, src);
}
}
jobject ComparatorJniCallback::ReuseBuffer(
JNIEnv* env, const Slice& src, jobject jreuse_buffer) const {
jobject ComparatorJniCallback::ReuseBuffer(JNIEnv* env, const Slice& src,
jobject jreuse_buffer) const {
// we can reuse the buffer
if (m_options->direct_buffer) {
// copy into direct buffer
void* buf = env->GetDirectBufferAddress(jreuse_buffer);
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(
env, "Unable to get Direct Buffer Address");
return nullptr;
@ -602,13 +608,14 @@ jobject ComparatorJniCallback::ReuseBuffer(
memcpy(buf, src.data(), src.size());
} else {
// copy into non-direct buffer
const jbyteArray jarray = ByteBufferJni::array(env, jreuse_buffer,
m_jbytebuffer_clazz);
const jbyteArray jarray =
ByteBufferJni::array(env, jreuse_buffer, m_jbytebuffer_clazz);
if (jarray == nullptr) {
// exception occurred
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())));
if (env->ExceptionCheck()) {
// exception occurred
@ -622,8 +629,9 @@ jobject ComparatorJniCallback::ReuseBuffer(
jobject ComparatorJniCallback::NewBuffer(JNIEnv* env, const Slice& src) const {
// we need a new buffer
jobject jbuf = ByteBufferJni::constructWith(env, m_options->direct_buffer,
src.data(), src.size(), m_jbytebuffer_clazz);
jobject jbuf =
ByteBufferJni::constructWith(env, m_options->direct_buffer, src.data(),
src.size(), m_jbytebuffer_clazz);
if (jbuf == nullptr) {
// exception occurred
return nullptr;

View File

@ -10,12 +10,14 @@
#define JAVA_ROCKSJNI_COMPARATORJNICALLBACK_H_
#include <jni.h>
#include <memory>
#include <string>
#include "rocksjni/jnicallback.h"
#include "port/port.h"
#include "rocksdb/comparator.h"
#include "rocksdb/slice.h"
#include "port/port.h"
#include "rocksjni/jnicallback.h"
#include "util/thread_local.h"
namespace ROCKSDB_NAMESPACE {
@ -41,7 +43,6 @@ enum ReusedSynchronisationType {
};
struct ComparatorJniCallbackOptions {
// Set the synchronisation type used to guard the reused buffers.
// Only used if max_reused_buffer_size > 0.
// Default: ADAPTIVE_MUTEX
@ -83,54 +84,57 @@ struct ComparatorJniCallbackOptions {
*/
class ComparatorJniCallback : public JniCallback, public Comparator {
public:
ComparatorJniCallback(
JNIEnv* env, jobject jcomparator,
const ComparatorJniCallbackOptions* options);
~ComparatorJniCallback();
virtual const char* Name() const;
virtual int Compare(const Slice& a, const Slice& b) const;
virtual void FindShortestSeparator(
std::string* start, const Slice& limit) const;
virtual void FindShortSuccessor(std::string* key) const;
const ComparatorJniCallbackOptions* m_options;
ComparatorJniCallback(JNIEnv* env, jobject jcomparator,
const ComparatorJniCallbackOptions* options);
~ComparatorJniCallback();
virtual const char* Name() const;
virtual int Compare(const Slice& a, const Slice& b) const;
virtual void FindShortestSeparator(std::string* start,
const Slice& limit) const;
virtual void FindShortSuccessor(std::string* key) const;
const ComparatorJniCallbackOptions* m_options;
private:
struct ThreadLocalBuf {
ThreadLocalBuf(JavaVM* _jvm, bool _direct_buffer, jobject _jbuf) :
jvm(_jvm), direct_buffer(_direct_buffer), jbuf(_jbuf) {}
JavaVM* jvm;
bool direct_buffer;
jobject jbuf;
};
inline void MaybeLockForReuse(const std::unique_ptr<port::Mutex>& mutex,
const bool cond) const;
inline void MaybeUnlockForReuse(const std::unique_ptr<port::Mutex>& mutex,
const bool cond) const;
jobject GetBuffer(JNIEnv* env, const Slice& src, bool reuse_buffer,
ThreadLocalPtr* tl_buf, jobject jreuse_buffer) const;
jobject ReuseBuffer(JNIEnv* env, const Slice& src,
jobject jreuse_buffer) const;
jobject NewBuffer(JNIEnv* env, const Slice& src) const;
void DeleteBuffer(JNIEnv* env, jobject jbuffer) const;
// used for synchronisation in compare method
std::unique_ptr<port::Mutex> mtx_compare;
// used for synchronisation in findShortestSeparator method
std::unique_ptr<port::Mutex> mtx_shortest;
// used for synchronisation in findShortSuccessor method
std::unique_ptr<port::Mutex> mtx_short;
std::unique_ptr<const char[]> m_name;
jclass m_abstract_comparator_jni_bridge_clazz; // TODO(AR) could we make this 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_jshortest_mid; // TODO(AR) could we make this static somehow?
jmethodID m_jshort_mid; // TODO(AR) could we make this static somehow?
jobject m_jcompare_buf_a;
jobject m_jcompare_buf_b;
jobject m_jshortest_buf_start;
jobject m_jshortest_buf_limit;
jobject m_jshort_buf_key;
ThreadLocalPtr* m_tl_buf_a;
ThreadLocalPtr* m_tl_buf_b;
struct ThreadLocalBuf {
ThreadLocalBuf(JavaVM* _jvm, bool _direct_buffer, jobject _jbuf)
: jvm(_jvm), direct_buffer(_direct_buffer), jbuf(_jbuf) {}
JavaVM* jvm;
bool direct_buffer;
jobject jbuf;
};
inline void MaybeLockForReuse(const std::unique_ptr<port::Mutex>& mutex,
const bool cond) const;
inline void MaybeUnlockForReuse(const std::unique_ptr<port::Mutex>& mutex,
const bool cond) const;
jobject GetBuffer(JNIEnv* env, const Slice& src, bool reuse_buffer,
ThreadLocalPtr* tl_buf, jobject jreuse_buffer) const;
jobject ReuseBuffer(JNIEnv* env, const Slice& src,
jobject jreuse_buffer) const;
jobject NewBuffer(JNIEnv* env, const Slice& src) const;
void DeleteBuffer(JNIEnv* env, jobject jbuffer) const;
// used for synchronisation in compare method
std::unique_ptr<port::Mutex> mtx_compare;
// used for synchronisation in findShortestSeparator method
std::unique_ptr<port::Mutex> mtx_shortest;
// used for synchronisation in findShortSuccessor method
std::unique_ptr<port::Mutex> mtx_short;
std::unique_ptr<const char[]> m_name;
jclass m_abstract_comparator_jni_bridge_clazz; // TODO(AR) could we make this
// 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_jshortest_mid; // TODO(AR) could we make this static somehow?
jmethodID m_jshort_mid; // TODO(AR) could we make this static somehow?
jobject m_jcompare_buf_a;
jobject m_jcompare_buf_b;
jobject m_jshortest_buf_start;
jobject m_jshortest_buf_limit;
jobject m_jshort_buf_key;
ThreadLocalPtr* m_tl_buf_a;
ThreadLocalPtr* m_tl_buf_b;
};
} // namespace ROCKSDB_NAMESPACE

View File

@ -17,8 +17,8 @@
* Method: newCompressionOptions
* Signature: ()J
*/
jlong Java_org_rocksdb_CompressionOptions_newCompressionOptions(
JNIEnv*, jclass) {
jlong Java_org_rocksdb_CompressionOptions_newCompressionOptions(JNIEnv*,
jclass) {
const auto* opt = new ROCKSDB_NAMESPACE::CompressionOptions();
return GET_CPLUSPLUS_POINTER(opt);
}
@ -28,8 +28,9 @@ jlong Java_org_rocksdb_CompressionOptions_newCompressionOptions(
* Method: setWindowBits
* Signature: (JI)V
*/
void Java_org_rocksdb_CompressionOptions_setWindowBits(
JNIEnv*, jobject, jlong jhandle, jint jwindow_bits) {
void Java_org_rocksdb_CompressionOptions_setWindowBits(JNIEnv*, jobject,
jlong jhandle,
jint jwindow_bits) {
auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle);
opt->window_bits = static_cast<int>(jwindow_bits);
}
@ -39,8 +40,8 @@ void Java_org_rocksdb_CompressionOptions_setWindowBits(
* Method: windowBits
* Signature: (J)I
*/
jint Java_org_rocksdb_CompressionOptions_windowBits(
JNIEnv*, jobject, jlong jhandle) {
jint Java_org_rocksdb_CompressionOptions_windowBits(JNIEnv*, jobject,
jlong jhandle) {
auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle);
return static_cast<jint>(opt->window_bits);
}
@ -50,8 +51,8 @@ jint Java_org_rocksdb_CompressionOptions_windowBits(
* Method: setLevel
* Signature: (JI)V
*/
void Java_org_rocksdb_CompressionOptions_setLevel(
JNIEnv*, jobject, jlong jhandle, jint jlevel) {
void Java_org_rocksdb_CompressionOptions_setLevel(JNIEnv*, jobject,
jlong jhandle, jint jlevel) {
auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle);
opt->level = static_cast<int>(jlevel);
}
@ -61,8 +62,8 @@ void Java_org_rocksdb_CompressionOptions_setLevel(
* Method: level
* Signature: (J)I
*/
jint Java_org_rocksdb_CompressionOptions_level(
JNIEnv*, jobject, jlong jhandle) {
jint Java_org_rocksdb_CompressionOptions_level(JNIEnv*, jobject,
jlong jhandle) {
auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle);
return static_cast<jint>(opt->level);
}
@ -72,8 +73,9 @@ jint Java_org_rocksdb_CompressionOptions_level(
* Method: setStrategy
* Signature: (JI)V
*/
void Java_org_rocksdb_CompressionOptions_setStrategy(
JNIEnv*, jobject, jlong jhandle, jint jstrategy) {
void Java_org_rocksdb_CompressionOptions_setStrategy(JNIEnv*, jobject,
jlong jhandle,
jint jstrategy) {
auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle);
opt->strategy = static_cast<int>(jstrategy);
}
@ -83,8 +85,8 @@ void Java_org_rocksdb_CompressionOptions_setStrategy(
* Method: strategy
* Signature: (J)I
*/
jint Java_org_rocksdb_CompressionOptions_strategy(
JNIEnv*, jobject, jlong jhandle) {
jint Java_org_rocksdb_CompressionOptions_strategy(JNIEnv*, jobject,
jlong jhandle) {
auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle);
return static_cast<jint>(opt->strategy);
}
@ -94,8 +96,9 @@ jint Java_org_rocksdb_CompressionOptions_strategy(
* Method: setMaxDictBytes
* Signature: (JI)V
*/
void Java_org_rocksdb_CompressionOptions_setMaxDictBytes(
JNIEnv*, jobject, jlong jhandle, jint jmax_dict_bytes) {
void Java_org_rocksdb_CompressionOptions_setMaxDictBytes(JNIEnv*, jobject,
jlong jhandle,
jint jmax_dict_bytes) {
auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle);
opt->max_dict_bytes = static_cast<uint32_t>(jmax_dict_bytes);
}
@ -105,8 +108,8 @@ void Java_org_rocksdb_CompressionOptions_setMaxDictBytes(
* Method: maxDictBytes
* Signature: (J)I
*/
jint Java_org_rocksdb_CompressionOptions_maxDictBytes(
JNIEnv*, jobject, jlong jhandle) {
jint Java_org_rocksdb_CompressionOptions_maxDictBytes(JNIEnv*, jobject,
jlong jhandle) {
auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle);
return static_cast<jint>(opt->max_dict_bytes);
}
@ -127,8 +130,8 @@ void Java_org_rocksdb_CompressionOptions_setZstdMaxTrainBytes(
* Method: zstdMaxTrainBytes
* Signature: (J)I
*/
jint Java_org_rocksdb_CompressionOptions_zstdMaxTrainBytes(
JNIEnv *, jobject, jlong jhandle) {
jint Java_org_rocksdb_CompressionOptions_zstdMaxTrainBytes(JNIEnv*, jobject,
jlong jhandle) {
auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle);
return static_cast<jint>(opt->zstd_max_train_bytes);
}
@ -183,8 +186,9 @@ jboolean Java_org_rocksdb_CompressionOptions_useZstdDictTrainer(JNIEnv*,
* Method: setEnabled
* Signature: (JZ)V
*/
void Java_org_rocksdb_CompressionOptions_setEnabled(
JNIEnv*, jobject, jlong jhandle, jboolean jenabled) {
void Java_org_rocksdb_CompressionOptions_setEnabled(JNIEnv*, jobject,
jlong jhandle,
jboolean jenabled) {
auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle);
opt->enabled = jenabled == JNI_TRUE;
}
@ -194,8 +198,8 @@ void Java_org_rocksdb_CompressionOptions_setEnabled(
* Method: enabled
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_CompressionOptions_enabled(
JNIEnv*, jobject, jlong jhandle) {
jboolean Java_org_rocksdb_CompressionOptions_enabled(JNIEnv*, jobject,
jlong jhandle) {
auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::CompressionOptions*>(jhandle);
return static_cast<bool>(opt->enabled);
}
@ -204,7 +208,7 @@ jboolean Java_org_rocksdb_CompressionOptions_enabled(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_CompressionOptions_disposeInternal(
JNIEnv*, jobject, jlong jhandle) {
void Java_org_rocksdb_CompressionOptions_disposeInternal(JNIEnv*, jobject,
jlong 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,
jlong handle, jbyte level) {
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
* Signature: ()J
*/
jlong Java_org_rocksdb_Env_getDefaultEnvInternal(
JNIEnv*, jclass) {
jlong Java_org_rocksdb_Env_getDefaultEnvInternal(JNIEnv*, jclass) {
return GET_CPLUSPLUS_POINTER(ROCKSDB_NAMESPACE::Env::Default());
}
@ -34,8 +33,8 @@ jlong Java_org_rocksdb_Env_getDefaultEnvInternal(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_RocksEnv_disposeInternal(
JNIEnv*, jobject, jlong jhandle) {
void Java_org_rocksdb_RocksEnv_disposeInternal(JNIEnv*, jobject,
jlong jhandle) {
auto* e = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle);
assert(e != nullptr);
delete e;
@ -46,8 +45,9 @@ void Java_org_rocksdb_RocksEnv_disposeInternal(
* Method: setBackgroundThreads
* Signature: (JIB)V
*/
void Java_org_rocksdb_Env_setBackgroundThreads(
JNIEnv*, jobject, jlong jhandle, jint jnum, jbyte jpriority_value) {
void Java_org_rocksdb_Env_setBackgroundThreads(JNIEnv*, jobject, jlong jhandle,
jint jnum,
jbyte jpriority_value) {
auto* rocks_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle);
rocks_env->SetBackgroundThreads(
static_cast<int>(jnum),
@ -59,8 +59,8 @@ void Java_org_rocksdb_Env_setBackgroundThreads(
* Method: getBackgroundThreads
* Signature: (JB)I
*/
jint Java_org_rocksdb_Env_getBackgroundThreads(
JNIEnv*, jobject, jlong jhandle, jbyte jpriority_value) {
jint Java_org_rocksdb_Env_getBackgroundThreads(JNIEnv*, jobject, jlong jhandle,
jbyte jpriority_value) {
auto* rocks_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle);
const int num = rocks_env->GetBackgroundThreads(
ROCKSDB_NAMESPACE::PriorityJni::toCppPriority(jpriority_value));
@ -72,8 +72,8 @@ jint Java_org_rocksdb_Env_getBackgroundThreads(
* Method: getThreadPoolQueueLen
* Signature: (JB)I
*/
jint Java_org_rocksdb_Env_getThreadPoolQueueLen(
JNIEnv*, jobject, jlong jhandle, jbyte jpriority_value) {
jint Java_org_rocksdb_Env_getThreadPoolQueueLen(JNIEnv*, jobject, jlong jhandle,
jbyte jpriority_value) {
auto* rocks_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle);
const int queue_len = rocks_env->GetThreadPoolQueueLen(
ROCKSDB_NAMESPACE::PriorityJni::toCppPriority(jpriority_value));
@ -85,8 +85,9 @@ jint Java_org_rocksdb_Env_getThreadPoolQueueLen(
* Method: incBackgroundThreadsIfNeeded
* Signature: (JIB)V
*/
void Java_org_rocksdb_Env_incBackgroundThreadsIfNeeded(
JNIEnv*, jobject, jlong jhandle, jint jnum, jbyte jpriority_value) {
void Java_org_rocksdb_Env_incBackgroundThreadsIfNeeded(JNIEnv*, jobject,
jlong jhandle, jint jnum,
jbyte jpriority_value) {
auto* rocks_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle);
rocks_env->IncBackgroundThreadsIfNeeded(
static_cast<int>(jnum),
@ -98,8 +99,9 @@ void Java_org_rocksdb_Env_incBackgroundThreadsIfNeeded(
* Method: lowerThreadPoolIOPriority
* Signature: (JB)V
*/
void Java_org_rocksdb_Env_lowerThreadPoolIOPriority(
JNIEnv*, jobject, jlong jhandle, jbyte jpriority_value) {
void Java_org_rocksdb_Env_lowerThreadPoolIOPriority(JNIEnv*, jobject,
jlong jhandle,
jbyte jpriority_value) {
auto* rocks_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle);
rocks_env->LowerThreadPoolIOPriority(
ROCKSDB_NAMESPACE::PriorityJni::toCppPriority(jpriority_value));
@ -110,8 +112,9 @@ void Java_org_rocksdb_Env_lowerThreadPoolIOPriority(
* Method: lowerThreadPoolCPUPriority
* Signature: (JB)V
*/
void Java_org_rocksdb_Env_lowerThreadPoolCPUPriority(
JNIEnv*, jobject, jlong jhandle, jbyte jpriority_value) {
void Java_org_rocksdb_Env_lowerThreadPoolCPUPriority(JNIEnv*, jobject,
jlong jhandle,
jbyte jpriority_value) {
auto* rocks_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle);
rocks_env->LowerThreadPoolCPUPriority(
ROCKSDB_NAMESPACE::PriorityJni::toCppPriority(jpriority_value));
@ -122,8 +125,8 @@ void Java_org_rocksdb_Env_lowerThreadPoolCPUPriority(
* Method: getThreadList
* Signature: (J)[Lorg/rocksdb/ThreadStatus;
*/
jobjectArray Java_org_rocksdb_Env_getThreadList(
JNIEnv* env, jobject, jlong jhandle) {
jobjectArray Java_org_rocksdb_Env_getThreadList(JNIEnv* env, jobject,
jlong jhandle) {
auto* rocks_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle);
std::vector<ROCKSDB_NAMESPACE::ThreadStatus> thread_status;
ROCKSDB_NAMESPACE::Status s = rocks_env->GetThreadList(&thread_status);
@ -160,8 +163,8 @@ jobjectArray Java_org_rocksdb_Env_getThreadList(
* Method: createMemEnv
* Signature: (J)J
*/
jlong Java_org_rocksdb_RocksMemEnv_createMemEnv(
JNIEnv*, jclass, jlong jbase_env_handle) {
jlong Java_org_rocksdb_RocksMemEnv_createMemEnv(JNIEnv*, jclass,
jlong jbase_env_handle) {
auto* base_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jbase_env_handle);
return GET_CPLUSPLUS_POINTER(ROCKSDB_NAMESPACE::NewMemEnv(base_env));
}
@ -171,8 +174,8 @@ jlong Java_org_rocksdb_RocksMemEnv_createMemEnv(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_RocksMemEnv_disposeInternal(
JNIEnv*, jobject, jlong jhandle) {
void Java_org_rocksdb_RocksMemEnv_disposeInternal(JNIEnv*, jobject,
jlong jhandle) {
auto* e = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle);
assert(e != nullptr);
delete e;
@ -183,8 +186,8 @@ void Java_org_rocksdb_RocksMemEnv_disposeInternal(
* Method: createTimedEnv
* Signature: (J)J
*/
jlong Java_org_rocksdb_TimedEnv_createTimedEnv(
JNIEnv*, jclass, jlong jbase_env_handle) {
jlong Java_org_rocksdb_TimedEnv_createTimedEnv(JNIEnv*, jclass,
jlong jbase_env_handle) {
auto* base_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jbase_env_handle);
return GET_CPLUSPLUS_POINTER(ROCKSDB_NAMESPACE::NewTimedEnv(base_env));
}
@ -194,10 +197,9 @@ jlong Java_org_rocksdb_TimedEnv_createTimedEnv(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_TimedEnv_disposeInternal(
JNIEnv*, jobject, jlong jhandle) {
void Java_org_rocksdb_TimedEnv_disposeInternal(JNIEnv*, jobject,
jlong jhandle) {
auto* e = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jhandle);
assert(e != nullptr);
delete e;
}

View File

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

View File

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

View File

@ -6,8 +6,10 @@
// This file implements the callback "bridge" between Java and C++ for
// JNI Callbacks from C++ to sub-classes or org.rocksdb.RocksCallbackObject
#include <assert.h>
#include "rocksjni/jnicallback.h"
#include <assert.h>
#include "rocksjni/portal.h"
namespace ROCKSDB_NAMESPACE {
@ -15,7 +17,7 @@ JniCallback::JniCallback(JNIEnv* env, jobject jcallback_obj) {
// Note: jcallback_obj may be accessed by multiple threads,
// so we ref the jvm not the env
const jint rs = env->GetJavaVM(&m_jvm);
if(rs != JNI_OK) {
if (rs != JNI_OK) {
// exception thrown
return;
}
@ -24,7 +26,7 @@ JniCallback::JniCallback(JNIEnv* env, jobject jcallback_obj) {
// across multiple method calls, so we create a global ref
assert(jcallback_obj != nullptr);
m_jcallback_obj = env->NewGlobalRef(jcallback_obj);
if(jcallback_obj == nullptr) {
if (jcallback_obj == nullptr) {
// exception thrown: OutOfMemoryError
return;
}

View File

@ -26,7 +26,7 @@ class JniCallback {
jobject m_jcallback_obj;
JNIEnv* getJniEnv(jboolean* attached) const;
void releaseJniEnv(jboolean& attached) const;
};
} // namespace ROCKSDB_NAMESPACE
};
} // namespace ROCKSDB_NAMESPACE
#endif // JAVA_ROCKSJNI_JNICALLBACK_H_

View File

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

View File

@ -3,19 +3,18 @@
// COPYING file in the root directory) and Apache 2.0 License
// (found in the LICENSE.Apache file in the root directory).
#include "rocksdb/utilities/memory_util.h"
#include <jni.h>
#include <map>
#include <string>
#include <unordered_set>
#include <vector>
#include "include/org_rocksdb_MemoryUtil.h"
#include "rocksjni/portal.h"
#include "rocksdb/utilities/memory_util.h"
/*
* Class: org_rocksdb_MemoryUtil
* Method: getApproximateMemoryUsageByType
@ -34,8 +33,9 @@ jobject Java_org_rocksdb_MemoryUtil_getApproximateMemoryUsageByType(
std::unordered_set<const ROCKSDB_NAMESPACE::Cache *> cache_set;
jsize cache_handle_count = env->GetArrayLength(jcache_handles);
if(cache_handle_count > 0) {
jlong *ptr_jcache_handles = env->GetLongArrayElements(jcache_handles, nullptr);
if (cache_handle_count > 0) {
jlong *ptr_jcache_handles =
env->GetLongArrayElements(jcache_handles, nullptr);
if (ptr_jcache_handles == nullptr) {
// exception thrown: OutOfMemoryError
return nullptr;
@ -46,7 +46,8 @@ jobject Java_org_rocksdb_MemoryUtil_getApproximateMemoryUsageByType(
ptr_jcache_handles[i]);
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;
@ -85,8 +86,7 @@ jobject Java_org_rocksdb_MemoryUtil_getApproximateMemoryUsageByType(
}
// Construct and return pointer to pair of jobjects
return std::unique_ptr<std::pair<jobject, jobject>>(
new std::pair<jobject, jobject>(jusage_type,
jusage_value));
new std::pair<jobject, jobject>(jusage_type, jusage_value));
};
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
* Signature: (J)V
*/
void Java_org_rocksdb_OptimisticTransactionDB_disposeInternal(
JNIEnv *, jobject, jlong jhandle) {
void Java_org_rocksdb_OptimisticTransactionDB_disposeInternal(JNIEnv*, jobject,
jlong jhandle) {
auto* optimistic_txn_db =
reinterpret_cast<ROCKSDB_NAMESPACE::OptimisticTransactionDB*>(jhandle);
assert(optimistic_txn_db != nullptr);
@ -172,8 +172,8 @@ void Java_org_rocksdb_OptimisticTransactionDB_disposeInternal(
* Method: closeDatabase
* Signature: (J)V
*/
void Java_org_rocksdb_OptimisticTransactionDB_closeDatabase(
JNIEnv* env, jclass, jlong jhandle) {
void Java_org_rocksdb_OptimisticTransactionDB_closeDatabase(JNIEnv* env, jclass,
jlong jhandle) {
auto* optimistic_txn_db =
reinterpret_cast<ROCKSDB_NAMESPACE::OptimisticTransactionDB*>(jhandle);
assert(optimistic_txn_db != nullptr);
@ -276,8 +276,8 @@ jlong Java_org_rocksdb_OptimisticTransactionDB_beginTransaction_1withOld__JJJJ(
* Method: getBaseDB
* Signature: (J)J
*/
jlong Java_org_rocksdb_OptimisticTransactionDB_getBaseDB(
JNIEnv*, jobject, jlong jhandle) {
jlong Java_org_rocksdb_OptimisticTransactionDB_getBaseDB(JNIEnv*, jobject,
jlong jhandle) {
auto* optimistic_txn_db =
reinterpret_cast<ROCKSDB_NAMESPACE::OptimisticTransactionDB*>(jhandle);
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
// calling C++ ROCKSDB_NAMESPACE::OptionsUtil methods from Java side.
#include "rocksdb/utilities/options_util.h"
#include <jni.h>
#include <string>
#include "include/org_rocksdb_OptionsUtil.h"
#include "rocksdb/db.h"
#include "rocksdb/env.h"
#include "rocksdb/utilities/options_util.h"
#include "rocksjni/portal.h"
void build_column_family_descriptor_list(

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,6 @@
#include <jni.h>
#include "include/org_rocksdb_RocksDBExceptionTest.h"
#include "rocksdb/slice.h"
#include "rocksdb/status.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
* 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) {
auto* it = reinterpret_cast<ROCKSDB_NAMESPACE::Iterator*>(handle);
ROCKSDB_NAMESPACE::Slice value_slice = it->value();
@ -186,10 +187,11 @@ jbyteArray Java_org_rocksdb_SstFileReaderIterator_value0(JNIEnv* env, jobject /*
if (jkeyValue == nullptr) {
// exception thrown: OutOfMemoryError
return nullptr;
}
env->SetByteArrayRegion(jkeyValue, 0, static_cast<jsize>(value_slice.size()),
const_cast<jbyte*>(reinterpret_cast<const jbyte*>(value_slice.data())));
return jkeyValue;
}
env->SetByteArrayRegion(
jkeyValue, 0, static_cast<jsize>(value_slice.size()),
const_cast<jbyte*>(reinterpret_cast<const jbyte*>(value_slice.data())));
return jkeyValue;
}
/*
@ -357,8 +359,9 @@ void Java_org_rocksdb_SstFileReaderIterator_seekForPrevByteArray0(
* Method: refresh0
* Signature: (J)V
*/
void Java_org_rocksdb_SstFileReaderIterator_refresh0(JNIEnv* env, jobject /*jobj*/,
jlong handle) {
void Java_org_rocksdb_SstFileReaderIterator_refresh0(JNIEnv* env,
jobject /*jobj*/,
jlong handle) {
auto* it = reinterpret_cast<ROCKSDB_NAMESPACE::Iterator*>(handle);
ROCKSDB_NAMESPACE::Status s = it->Refresh();

View File

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

View File

@ -12,8 +12,9 @@
#include <memory>
#include <set>
#include <string>
#include "rocksdb/statistics.h"
#include "monitoring/statistics.h"
#include "rocksdb/statistics.h"
namespace ROCKSDB_NAMESPACE {
@ -26,8 +27,8 @@ class StatisticsJni : public StatisticsImpl {
private:
const std::set<uint32_t> m_ignore_histograms;
};
};
} // namespace ROCKSDB_NAMESPACE
} // namespace ROCKSDB_NAMESPACE
#endif // JAVA_ROCKSJNI_STATISTICSJNI_H_

View File

@ -72,9 +72,9 @@ jlong Java_org_rocksdb_BlockBasedTableConfig_newTableFactoryHandle(
options.cache_index_and_filter_blocks_with_high_priority =
static_cast<bool>(jcache_index_and_filter_blocks_with_high_priority);
options.pin_l0_filter_and_index_blocks_in_cache =
static_cast<bool>(jpin_l0_filter_and_index_blocks_in_cache);
static_cast<bool>(jpin_l0_filter_and_index_blocks_in_cache);
options.pin_top_level_index_and_filter =
static_cast<bool>(jpin_top_level_index_and_filter);
static_cast<bool>(jpin_top_level_index_and_filter);
options.index_type =
ROCKSDB_NAMESPACE::IndexTypeJni::toCppIndexType(jindex_type_value);
options.data_block_index_type =
@ -131,7 +131,8 @@ jlong Java_org_rocksdb_BlockBasedTableConfig_newTableFactoryHandle(
options.block_size = static_cast<size_t>(jblock_size);
options.block_size_deviation = static_cast<int>(jblock_size_deviation);
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.partition_filters = static_cast<bool>(jpartition_filters);
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.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.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.index_shortening =
ROCKSDB_NAMESPACE::IndexShorteningModeJni::toCppIndexShorteningMode(

View File

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

View File

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

View File

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

View File

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

View File

@ -7,29 +7,29 @@
// ROCKSDB_NAMESPACE::TraceWriter.
#include "rocksjni/trace_writer_jnicallback.h"
#include "rocksjni/portal.h"
namespace ROCKSDB_NAMESPACE {
TraceWriterJniCallback::TraceWriterJniCallback(
JNIEnv* env, jobject jtrace_writer)
TraceWriterJniCallback::TraceWriterJniCallback(JNIEnv* env,
jobject jtrace_writer)
: JniCallback(env, jtrace_writer) {
m_jwrite_proxy_methodid =
AbstractTraceWriterJni::getWriteProxyMethodId(env);
if(m_jwrite_proxy_methodid == nullptr) {
m_jwrite_proxy_methodid = AbstractTraceWriterJni::getWriteProxyMethodId(env);
if (m_jwrite_proxy_methodid == nullptr) {
// exception thrown: NoSuchMethodException or OutOfMemoryError
return;
}
m_jclose_writer_proxy_methodid =
AbstractTraceWriterJni::getCloseWriterProxyMethodId(env);
if(m_jclose_writer_proxy_methodid == nullptr) {
if (m_jclose_writer_proxy_methodid == nullptr) {
// exception thrown: NoSuchMethodException or OutOfMemoryError
return;
}
m_jget_file_size_methodid =
AbstractTraceWriterJni::getGetFileSizeMethodId(env);
if(m_jget_file_size_methodid == nullptr) {
if (m_jget_file_size_methodid == nullptr) {
// exception thrown: NoSuchMethodException or OutOfMemoryError
return;
}
@ -42,21 +42,22 @@ Status TraceWriterJniCallback::Write(const Slice& data) {
return Status::IOError("Unable to attach JNI Environment");
}
jshort jstatus = env->CallShortMethod(m_jcallback_obj,
m_jwrite_proxy_methodid,
&data);
jshort jstatus =
env->CallShortMethod(m_jcallback_obj, m_jwrite_proxy_methodid, &data);
if(env->ExceptionCheck()) {
if (env->ExceptionCheck()) {
// exception thrown from CallShortMethod
env->ExceptionDescribe(); // print out exception to stderr
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
jbyte jcode_value = (jstatus >> 8) & 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);
@ -70,20 +71,22 @@ Status TraceWriterJniCallback::Close() {
return Status::IOError("Unable to attach JNI Environment");
}
jshort jstatus = env->CallShortMethod(m_jcallback_obj,
m_jclose_writer_proxy_methodid);
jshort jstatus =
env->CallShortMethod(m_jcallback_obj, m_jclose_writer_proxy_methodid);
if(env->ExceptionCheck()) {
if (env->ExceptionCheck()) {
// exception thrown from CallShortMethod
env->ExceptionDescribe(); // print out exception to stderr
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
jbyte code_value = (jstatus >> 8) & 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);
@ -97,10 +100,10 @@ uint64_t TraceWriterJniCallback::GetFileSize() {
return 0;
}
jlong jfile_size = env->CallLongMethod(m_jcallback_obj,
m_jget_file_size_methodid);
jlong jfile_size =
env->CallLongMethod(m_jcallback_obj, m_jget_file_size_methodid);
if(env->ExceptionCheck()) {
if (env->ExceptionCheck()) {
// exception thrown from CallLongMethod
env->ExceptionDescribe(); // print out exception to stderr
releaseJniEnv(attached_thread);

View File

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

View File

@ -190,8 +190,9 @@ jbyteArray txn_get_helper(JNIEnv* env, const FnGet& fn_get,
// exception thrown: OutOfMemoryError
return nullptr;
}
env->SetByteArrayRegion(jret_value, 0, static_cast<jsize>(value.size()),
const_cast<jbyte*>(reinterpret_cast<const jbyte*>(value.c_str())));
env->SetByteArrayRegion(
jret_value, 0, static_cast<jsize>(value.size()),
const_cast<jbyte*>(reinterpret_cast<const jbyte*>(value.c_str())));
if (env->ExceptionCheck()) {
// exception thrown: ArrayIndexOutOfBoundsException
return nullptr;
@ -366,7 +367,8 @@ jobjectArray txn_multi_get_helper(JNIEnv* env, const FnMultiGet& fn_multi_get,
env->SetByteArrayRegion(
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()) {
// exception thrown: ArrayIndexOutOfBoundsException
env->DeleteLocalRef(jentry_value);
@ -647,7 +649,7 @@ void txn_write_kv_parts_helper(JNIEnv* env,
const jobjectArray& jvalue_parts,
const jint& jvalue_parts_len) {
#ifndef DEBUG
(void) jvalue_parts_len;
(void)jvalue_parts_len;
#else
assert(jkey_parts_len == jvalue_parts_len);
#endif

View File

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

View File

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

View File

@ -13,8 +13,9 @@
namespace ROCKSDB_NAMESPACE {
TransactionNotifierJniCallback::TransactionNotifierJniCallback(JNIEnv* env,
jobject jtransaction_notifier) : JniCallback(env, jtransaction_notifier) {
TransactionNotifierJniCallback::TransactionNotifierJniCallback(
JNIEnv* env, jobject jtransaction_notifier)
: JniCallback(env, jtransaction_notifier) {
// we cache the method id for the JNI callback
m_jsnapshot_created_methodID =
AbstractTransactionNotifierJni::getSnapshotCreatedMethodId(env);
@ -29,7 +30,7 @@ void TransactionNotifierJniCallback::SnapshotCreated(
env->CallVoidMethod(m_jcallback_obj, m_jsnapshot_created_methodID,
GET_CPLUSPLUS_POINTER(newSnapshot));
if(env->ExceptionCheck()) {
if (env->ExceptionCheck()) {
// exception thrown from CallVoidMethod
env->ExceptionDescribe(); // print out exception to stderr
releaseJniEnv(attached_thread);

View File

@ -28,8 +28,8 @@ namespace ROCKSDB_NAMESPACE {
* presented to the callback. This could be revisited in future
* if performance is lacking.
*/
class TransactionNotifierJniCallback: public JniCallback,
public TransactionNotifier {
class TransactionNotifierJniCallback : public JniCallback,
public TransactionNotifier {
public:
TransactionNotifierJniCallback(JNIEnv* env, jobject jtransaction_notifier);
virtual void SnapshotCreated(const Snapshot* newSnapshot);

View File

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

View File

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

View File

@ -12,24 +12,23 @@
#include "rocksjni/portal.h"
namespace ROCKSDB_NAMESPACE {
WalFilterJniCallback::WalFilterJniCallback(
JNIEnv* env, jobject jwal_filter)
WalFilterJniCallback::WalFilterJniCallback(JNIEnv* env, jobject jwal_filter)
: JniCallback(env, jwal_filter) {
// Note: The name of a WalFilter will not change during it's lifetime,
// so we cache it in a global var
jmethodID jname_mid = AbstractWalFilterJni::getNameMethodId(env);
if(jname_mid == nullptr) {
if (jname_mid == nullptr) {
// exception thrown: NoSuchMethodException or OutOfMemoryError
return;
}
jstring jname = (jstring)env->CallObjectMethod(m_jcallback_obj, jname_mid);
if(env->ExceptionCheck()) {
if (env->ExceptionCheck()) {
// exception thrown
return;
}
jboolean has_exception = JNI_FALSE;
m_name = JniUtil::copyString(env, jname,
&has_exception); // also releases jname
&has_exception); // also releases jname
if (has_exception == JNI_TRUE) {
// exception thrown
return;
@ -37,14 +36,14 @@ WalFilterJniCallback::WalFilterJniCallback(
m_column_family_log_number_map_mid =
AbstractWalFilterJni::getColumnFamilyLogNumberMapMethodId(env);
if(m_column_family_log_number_map_mid == nullptr) {
if (m_column_family_log_number_map_mid == nullptr) {
// exception thrown: NoSuchMethodException or OutOfMemoryError
return;
}
m_log_record_found_proxy_mid =
AbstractWalFilterJni::getLogRecordFoundProxyMethodId(env);
if(m_log_record_found_proxy_mid == nullptr) {
if (m_log_record_found_proxy_mid == nullptr) {
// exception thrown: NoSuchMethodException or OutOfMemoryError
return;
}
@ -63,7 +62,7 @@ void WalFilterJniCallback::ColumnFamilyLogNumberMap(
ROCKSDB_NAMESPACE::HashMapJni::fromCppMap(env, &cf_lognumber_map);
if (jcf_lognumber_map == nullptr) {
// exception occurred
env->ExceptionDescribe(); // print out exception to stderr
env->ExceptionDescribe(); // print out exception to stderr
releaseJniEnv(attached_thread);
return;
}
@ -72,21 +71,19 @@ void WalFilterJniCallback::ColumnFamilyLogNumberMap(
ROCKSDB_NAMESPACE::HashMapJni::fromCppMap(env, &cf_name_id_map);
if (jcf_name_id_map == nullptr) {
// exception occurred
env->ExceptionDescribe(); // print out exception to stderr
env->ExceptionDescribe(); // print out exception to stderr
env->DeleteLocalRef(jcf_lognumber_map);
releaseJniEnv(attached_thread);
return;
}
env->CallVoidMethod(m_jcallback_obj,
m_column_family_log_number_map_mid,
jcf_lognumber_map,
jcf_name_id_map);
env->CallVoidMethod(m_jcallback_obj, m_column_family_log_number_map_mid,
jcf_lognumber_map, jcf_name_id_map);
env->DeleteLocalRef(jcf_lognumber_map);
env->DeleteLocalRef(jcf_name_id_map);
if(env->ExceptionCheck()) {
if (env->ExceptionCheck()) {
// exception thrown from CallVoidMethod
env->ExceptionDescribe(); // print out exception to stderr
}
@ -94,21 +91,21 @@ void WalFilterJniCallback::ColumnFamilyLogNumberMap(
releaseJniEnv(attached_thread);
}
WalFilter::WalProcessingOption WalFilterJniCallback::LogRecordFound(
WalFilter::WalProcessingOption WalFilterJniCallback::LogRecordFound(
unsigned long long log_number, const std::string& log_file_name,
const WriteBatch& batch, WriteBatch* new_batch, bool* batch_changed) {
jboolean attached_thread = JNI_FALSE;
JNIEnv* env = getJniEnv(&attached_thread);
if (env == nullptr) {
return WalFilter::WalProcessingOption::kCorruptedRecord;
return WalFilter::WalProcessingOption::kCorruptedRecord;
}
jstring jlog_file_name = JniUtil::toJavaString(env, &log_file_name);
if (jlog_file_name == nullptr) {
// exception occcurred
env->ExceptionDescribe(); // print out exception to stderr
env->ExceptionDescribe(); // print out exception to stderr
releaseJniEnv(attached_thread);
return WalFilter::WalProcessingOption::kCorruptedRecord;
return WalFilter::WalProcessingOption::kCorruptedRecord;
}
jshort jlog_record_found_result = env->CallShortMethod(
@ -122,7 +119,7 @@ void WalFilterJniCallback::ColumnFamilyLogNumberMap(
// exception thrown from CallShortMethod
env->ExceptionDescribe(); // print out exception to stderr
releaseJniEnv(attached_thread);
return WalFilter::WalProcessingOption::kCorruptedRecord;
return WalFilter::WalProcessingOption::kCorruptedRecord;
}
// unpack WalProcessingOption and batch_changed from jlog_record_found_result
@ -137,8 +134,6 @@ void WalFilterJniCallback::ColumnFamilyLogNumberMap(
jwal_processing_option_value);
}
const char* WalFilterJniCallback::Name() const {
return m_name.get();
}
const char* WalFilterJniCallback::Name() const { return m_name.get(); }
} // namespace ROCKSDB_NAMESPACE

View File

@ -10,6 +10,7 @@
#define JAVA_ROCKSJNI_WAL_FILTER_JNICALLBACK_H_
#include <jni.h>
#include <map>
#include <memory>
#include <string>
@ -21,20 +22,19 @@ namespace ROCKSDB_NAMESPACE {
class WalFilterJniCallback : public JniCallback, public WalFilter {
public:
WalFilterJniCallback(
JNIEnv* env, jobject jwal_filter);
virtual void ColumnFamilyLogNumberMap(
const std::map<uint32_t, uint64_t>& cf_lognumber_map,
const std::map<std::string, uint32_t>& cf_name_id_map);
virtual WalFilter::WalProcessingOption LogRecordFound(
unsigned long long log_number, const std::string& log_file_name,
const WriteBatch& batch, WriteBatch* new_batch, bool* batch_changed);
virtual const char* Name() const;
WalFilterJniCallback(JNIEnv* env, jobject jwal_filter);
virtual void ColumnFamilyLogNumberMap(
const std::map<uint32_t, uint64_t>& cf_lognumber_map,
const std::map<std::string, uint32_t>& cf_name_id_map);
virtual WalFilter::WalProcessingOption LogRecordFound(
unsigned long long log_number, const std::string& log_file_name,
const WriteBatch& batch, WriteBatch* new_batch, bool* batch_changed);
virtual const char* Name() const;
private:
std::unique_ptr<const char[]> m_name;
jmethodID m_column_family_log_number_map_mid;
jmethodID m_log_record_found_proxy_mid;
std::unique_ptr<const char[]> m_name;
jmethodID m_column_family_log_number_map_mid;
jmethodID m_log_record_found_proxy_mid;
};
} // namespace ROCKSDB_NAMESPACE

View File

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

View File

@ -947,6 +947,7 @@ jlongArray Java_org_rocksdb_WBWIRocksIterator_entry1(JNIEnv* env,
* Signature: (J)V
*/
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);
}

View File

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

View File

@ -7,58 +7,58 @@
// ROCKSDB_NAMESPACE::Comparator.
#include "rocksjni/writebatchhandlerjnicallback.h"
#include "rocksjni/portal.h"
namespace ROCKSDB_NAMESPACE {
WriteBatchHandlerJniCallback::WriteBatchHandlerJniCallback(
JNIEnv* env, jobject jWriteBatchHandler)
: JniCallback(env, jWriteBatchHandler), m_env(env) {
m_jPutCfMethodId = WriteBatchHandlerJni::getPutCfMethodId(env);
if(m_jPutCfMethodId == nullptr) {
if (m_jPutCfMethodId == nullptr) {
// exception thrown
return;
}
m_jPutMethodId = WriteBatchHandlerJni::getPutMethodId(env);
if(m_jPutMethodId == nullptr) {
if (m_jPutMethodId == nullptr) {
// exception thrown
return;
}
m_jMergeCfMethodId = WriteBatchHandlerJni::getMergeCfMethodId(env);
if(m_jMergeCfMethodId == nullptr) {
if (m_jMergeCfMethodId == nullptr) {
// exception thrown
return;
}
m_jMergeMethodId = WriteBatchHandlerJni::getMergeMethodId(env);
if(m_jMergeMethodId == nullptr) {
if (m_jMergeMethodId == nullptr) {
// exception thrown
return;
}
m_jDeleteCfMethodId = WriteBatchHandlerJni::getDeleteCfMethodId(env);
if(m_jDeleteCfMethodId == nullptr) {
if (m_jDeleteCfMethodId == nullptr) {
// exception thrown
return;
}
m_jDeleteMethodId = WriteBatchHandlerJni::getDeleteMethodId(env);
if(m_jDeleteMethodId == nullptr) {
if (m_jDeleteMethodId == nullptr) {
// exception thrown
return;
}
m_jSingleDeleteCfMethodId =
WriteBatchHandlerJni::getSingleDeleteCfMethodId(env);
if(m_jSingleDeleteCfMethodId == nullptr) {
if (m_jSingleDeleteCfMethodId == nullptr) {
// exception thrown
return;
}
m_jSingleDeleteMethodId = WriteBatchHandlerJni::getSingleDeleteMethodId(env);
if(m_jSingleDeleteMethodId == nullptr) {
if (m_jSingleDeleteMethodId == nullptr) {
// exception thrown
return;
}
@ -77,46 +77,46 @@ WriteBatchHandlerJniCallback::WriteBatchHandlerJniCallback(
}
m_jLogDataMethodId = WriteBatchHandlerJni::getLogDataMethodId(env);
if(m_jLogDataMethodId == nullptr) {
if (m_jLogDataMethodId == nullptr) {
// exception thrown
return;
}
m_jPutBlobIndexCfMethodId =
WriteBatchHandlerJni::getPutBlobIndexCfMethodId(env);
if(m_jPutBlobIndexCfMethodId == nullptr) {
if (m_jPutBlobIndexCfMethodId == nullptr) {
// exception thrown
return;
}
m_jMarkBeginPrepareMethodId =
WriteBatchHandlerJni::getMarkBeginPrepareMethodId(env);
if(m_jMarkBeginPrepareMethodId == nullptr) {
if (m_jMarkBeginPrepareMethodId == nullptr) {
// exception thrown
return;
}
m_jMarkEndPrepareMethodId =
WriteBatchHandlerJni::getMarkEndPrepareMethodId(env);
if(m_jMarkEndPrepareMethodId == nullptr) {
if (m_jMarkEndPrepareMethodId == nullptr) {
// exception thrown
return;
}
m_jMarkNoopMethodId = WriteBatchHandlerJni::getMarkNoopMethodId(env);
if(m_jMarkNoopMethodId == nullptr) {
if (m_jMarkNoopMethodId == nullptr) {
// exception thrown
return;
}
m_jMarkRollbackMethodId = WriteBatchHandlerJni::getMarkRollbackMethodId(env);
if(m_jMarkRollbackMethodId == nullptr) {
if (m_jMarkRollbackMethodId == nullptr) {
// exception thrown
return;
}
m_jMarkCommitMethodId = WriteBatchHandlerJni::getMarkCommitMethodId(env);
if(m_jMarkCommitMethodId == nullptr) {
if (m_jMarkCommitMethodId == nullptr) {
// exception thrown
return;
}
@ -129,7 +129,7 @@ WriteBatchHandlerJniCallback::WriteBatchHandlerJniCallback(
}
m_jContinueMethodId = WriteBatchHandlerJni::getContinueMethodId(env);
if(m_jContinueMethodId == nullptr) {
if (m_jContinueMethodId == nullptr) {
// exception thrown
return;
}
@ -137,17 +137,12 @@ WriteBatchHandlerJniCallback::WriteBatchHandlerJniCallback(
ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::PutCF(
uint32_t column_family_id, const Slice& key, const Slice& value) {
auto put = [this, column_family_id] (
jbyteArray j_key, jbyteArray j_value) {
m_env->CallVoidMethod(
m_jcallback_obj,
m_jPutCfMethodId,
static_cast<jint>(column_family_id),
j_key,
j_value);
auto put = [this, column_family_id](jbyteArray j_key, jbyteArray j_value) {
m_env->CallVoidMethod(m_jcallback_obj, m_jPutCfMethodId,
static_cast<jint>(column_family_id), j_key, j_value);
};
auto status = WriteBatchHandlerJniCallback::kv_op(key, value, put);
if(status == nullptr) {
if (status == nullptr) {
return ROCKSDB_NAMESPACE::Status::OK(); // TODO(AR) what to do if there is
// an Exception but we don't know
// the ROCKSDB_NAMESPACE::Status?
@ -157,30 +152,20 @@ ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::PutCF(
}
void WriteBatchHandlerJniCallback::Put(const Slice& key, const Slice& value) {
auto put = [this] (
jbyteArray j_key, jbyteArray j_value) {
m_env->CallVoidMethod(
m_jcallback_obj,
m_jPutMethodId,
j_key,
j_value);
auto put = [this](jbyteArray j_key, jbyteArray j_value) {
m_env->CallVoidMethod(m_jcallback_obj, m_jPutMethodId, j_key, j_value);
};
WriteBatchHandlerJniCallback::kv_op(key, value, put);
}
ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MergeCF(
uint32_t column_family_id, const Slice& key, const Slice& value) {
auto merge = [this, column_family_id] (
jbyteArray j_key, jbyteArray j_value) {
m_env->CallVoidMethod(
m_jcallback_obj,
m_jMergeCfMethodId,
static_cast<jint>(column_family_id),
j_key,
j_value);
auto merge = [this, column_family_id](jbyteArray j_key, jbyteArray j_value) {
m_env->CallVoidMethod(m_jcallback_obj, m_jMergeCfMethodId,
static_cast<jint>(column_family_id), j_key, j_value);
};
auto status = WriteBatchHandlerJniCallback::kv_op(key, value, merge);
if(status == nullptr) {
if (status == nullptr) {
return ROCKSDB_NAMESPACE::Status::OK(); // TODO(AR) what to do if there is
// an Exception but we don't know
// the ROCKSDB_NAMESPACE::Status?
@ -190,28 +175,20 @@ ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MergeCF(
}
void WriteBatchHandlerJniCallback::Merge(const Slice& key, const Slice& value) {
auto merge = [this] (
jbyteArray j_key, jbyteArray j_value) {
m_env->CallVoidMethod(
m_jcallback_obj,
m_jMergeMethodId,
j_key,
j_value);
auto merge = [this](jbyteArray j_key, jbyteArray j_value) {
m_env->CallVoidMethod(m_jcallback_obj, m_jMergeMethodId, j_key, j_value);
};
WriteBatchHandlerJniCallback::kv_op(key, value, merge);
}
ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::DeleteCF(
uint32_t column_family_id, const Slice& key) {
auto remove = [this, column_family_id] (jbyteArray j_key) {
m_env->CallVoidMethod(
m_jcallback_obj,
m_jDeleteCfMethodId,
static_cast<jint>(column_family_id),
j_key);
auto remove = [this, column_family_id](jbyteArray j_key) {
m_env->CallVoidMethod(m_jcallback_obj, m_jDeleteCfMethodId,
static_cast<jint>(column_family_id), j_key);
};
auto status = WriteBatchHandlerJniCallback::k_op(key, remove);
if(status == nullptr) {
if (status == nullptr) {
return ROCKSDB_NAMESPACE::Status::OK(); // TODO(AR) what to do if there is
// an Exception but we don't know
// the ROCKSDB_NAMESPACE::Status?
@ -221,26 +198,20 @@ ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::DeleteCF(
}
void WriteBatchHandlerJniCallback::Delete(const Slice& key) {
auto remove = [this] (jbyteArray j_key) {
m_env->CallVoidMethod(
m_jcallback_obj,
m_jDeleteMethodId,
j_key);
auto remove = [this](jbyteArray j_key) {
m_env->CallVoidMethod(m_jcallback_obj, m_jDeleteMethodId, j_key);
};
WriteBatchHandlerJniCallback::k_op(key, remove);
}
ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::SingleDeleteCF(
uint32_t column_family_id, const Slice& key) {
auto singleDelete = [this, column_family_id] (jbyteArray j_key) {
m_env->CallVoidMethod(
m_jcallback_obj,
m_jSingleDeleteCfMethodId,
static_cast<jint>(column_family_id),
j_key);
auto singleDelete = [this, column_family_id](jbyteArray j_key) {
m_env->CallVoidMethod(m_jcallback_obj, m_jSingleDeleteCfMethodId,
static_cast<jint>(column_family_id), j_key);
};
auto status = WriteBatchHandlerJniCallback::k_op(key, singleDelete);
if(status == nullptr) {
if (status == nullptr) {
return ROCKSDB_NAMESPACE::Status::OK(); // TODO(AR) what to do if there is
// an Exception but we don't know
// the ROCKSDB_NAMESPACE::Status?
@ -250,28 +221,23 @@ ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::SingleDeleteCF(
}
void WriteBatchHandlerJniCallback::SingleDelete(const Slice& key) {
auto singleDelete = [this] (jbyteArray j_key) {
m_env->CallVoidMethod(
m_jcallback_obj,
m_jSingleDeleteMethodId,
j_key);
auto singleDelete = [this](jbyteArray j_key) {
m_env->CallVoidMethod(m_jcallback_obj, m_jSingleDeleteMethodId, j_key);
};
WriteBatchHandlerJniCallback::k_op(key, singleDelete);
}
ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::DeleteRangeCF(
uint32_t column_family_id, const Slice& beginKey, const Slice& endKey) {
auto deleteRange = [this, column_family_id] (
jbyteArray j_beginKey, jbyteArray j_endKey) {
m_env->CallVoidMethod(
m_jcallback_obj,
m_jDeleteRangeCfMethodId,
static_cast<jint>(column_family_id),
j_beginKey,
j_endKey);
auto deleteRange = [this, column_family_id](jbyteArray j_beginKey,
jbyteArray j_endKey) {
m_env->CallVoidMethod(m_jcallback_obj, m_jDeleteRangeCfMethodId,
static_cast<jint>(column_family_id), j_beginKey,
j_endKey);
};
auto status = WriteBatchHandlerJniCallback::kv_op(beginKey, endKey, deleteRange);
if(status == nullptr) {
auto status =
WriteBatchHandlerJniCallback::kv_op(beginKey, endKey, deleteRange);
if (status == nullptr) {
return ROCKSDB_NAMESPACE::Status::OK(); // TODO(AR) what to do if there is
// an Exception but we don't know
// the ROCKSDB_NAMESPACE::Status?
@ -281,41 +247,30 @@ ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::DeleteRangeCF(
}
void WriteBatchHandlerJniCallback::DeleteRange(const Slice& beginKey,
const Slice& endKey) {
auto deleteRange = [this] (
jbyteArray j_beginKey, jbyteArray j_endKey) {
m_env->CallVoidMethod(
m_jcallback_obj,
m_jDeleteRangeMethodId,
j_beginKey,
j_endKey);
const Slice& endKey) {
auto deleteRange = [this](jbyteArray j_beginKey, jbyteArray j_endKey) {
m_env->CallVoidMethod(m_jcallback_obj, m_jDeleteRangeMethodId, j_beginKey,
j_endKey);
};
WriteBatchHandlerJniCallback::kv_op(beginKey, endKey, deleteRange);
}
void WriteBatchHandlerJniCallback::LogData(const Slice& blob) {
auto logData = [this] (jbyteArray j_blob) {
m_env->CallVoidMethod(
m_jcallback_obj,
m_jLogDataMethodId,
j_blob);
auto logData = [this](jbyteArray j_blob) {
m_env->CallVoidMethod(m_jcallback_obj, m_jLogDataMethodId, j_blob);
};
WriteBatchHandlerJniCallback::k_op(blob, logData);
}
ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::PutBlobIndexCF(
uint32_t column_family_id, const Slice& key, const Slice& value) {
auto putBlobIndex = [this, column_family_id] (
jbyteArray j_key, jbyteArray j_value) {
m_env->CallVoidMethod(
m_jcallback_obj,
m_jPutBlobIndexCfMethodId,
static_cast<jint>(column_family_id),
j_key,
j_value);
auto putBlobIndex = [this, column_family_id](jbyteArray j_key,
jbyteArray j_value) {
m_env->CallVoidMethod(m_jcallback_obj, m_jPutBlobIndexCfMethodId,
static_cast<jint>(column_family_id), j_key, j_value);
};
auto status = WriteBatchHandlerJniCallback::kv_op(key, value, putBlobIndex);
if(status == nullptr) {
if (status == nullptr) {
return ROCKSDB_NAMESPACE::Status::OK(); // TODO(AR) what to do if there is
// an Exception but we don't know
// the ROCKSDB_NAMESPACE::Status?
@ -327,7 +282,7 @@ ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::PutBlobIndexCF(
ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkBeginPrepare(
bool unprepare) {
#ifndef DEBUG
(void) unprepare;
(void)unprepare;
#else
assert(!unprepare);
#endif
@ -346,7 +301,8 @@ ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkBeginPrepare(
// better error code here
} 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);
}
}
@ -356,15 +312,11 @@ ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkBeginPrepare(
ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkEndPrepare(
const Slice& xid) {
auto markEndPrepare = [this] (
jbyteArray j_xid) {
m_env->CallVoidMethod(
m_jcallback_obj,
m_jMarkEndPrepareMethodId,
j_xid);
auto markEndPrepare = [this](jbyteArray j_xid) {
m_env->CallVoidMethod(m_jcallback_obj, m_jMarkEndPrepareMethodId, j_xid);
};
auto status = WriteBatchHandlerJniCallback::k_op(xid, markEndPrepare);
if(status == nullptr) {
if (status == nullptr) {
return ROCKSDB_NAMESPACE::Status::OK(); // TODO(AR) what to do if there is
// an Exception but we don't know
// the ROCKSDB_NAMESPACE::Status?
@ -375,7 +327,8 @@ ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkEndPrepare(
ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkNoop(
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
if (m_env->ExceptionCheck()) {
@ -390,7 +343,8 @@ ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkNoop(
// better error code here
} 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);
}
}
@ -400,15 +354,11 @@ ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkNoop(
ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkRollback(
const Slice& xid) {
auto markRollback = [this] (
jbyteArray j_xid) {
m_env->CallVoidMethod(
m_jcallback_obj,
m_jMarkRollbackMethodId,
j_xid);
auto markRollback = [this](jbyteArray j_xid) {
m_env->CallVoidMethod(m_jcallback_obj, m_jMarkRollbackMethodId, j_xid);
};
auto status = WriteBatchHandlerJniCallback::k_op(xid, markRollback);
if(status == nullptr) {
if (status == nullptr) {
return ROCKSDB_NAMESPACE::Status::OK(); // TODO(AR) what to do if there is
// an Exception but we don't know
// the ROCKSDB_NAMESPACE::Status?
@ -419,15 +369,11 @@ ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkRollback(
ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkCommit(
const Slice& xid) {
auto markCommit = [this] (
jbyteArray j_xid) {
m_env->CallVoidMethod(
m_jcallback_obj,
m_jMarkCommitMethodId,
j_xid);
auto markCommit = [this](jbyteArray j_xid) {
m_env->CallVoidMethod(m_jcallback_obj, m_jMarkCommitMethodId, j_xid);
};
auto status = WriteBatchHandlerJniCallback::k_op(xid, markCommit);
if(status == nullptr) {
if (status == nullptr) {
return ROCKSDB_NAMESPACE::Status::OK(); // TODO(AR) what to do if there is
// an Exception but we don't know
// the ROCKSDB_NAMESPACE::Status?
@ -454,10 +400,9 @@ ROCKSDB_NAMESPACE::Status WriteBatchHandlerJniCallback::MarkCommitWithTimestamp(
}
bool WriteBatchHandlerJniCallback::Continue() {
jboolean jContinue = m_env->CallBooleanMethod(
m_jcallback_obj,
m_jContinueMethodId);
if(m_env->ExceptionCheck()) {
jboolean jContinue =
m_env->CallBooleanMethod(m_jcallback_obj, m_jContinueMethodId);
if (m_env->ExceptionCheck()) {
// exception thrown
m_env->ExceptionDescribe();
}
@ -510,7 +455,8 @@ std::unique_ptr<ROCKSDB_NAMESPACE::Status> WriteBatchHandlerJniCallback::kv_op(
return nullptr;
} 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;
}
}
@ -556,7 +502,8 @@ std::unique_ptr<ROCKSDB_NAMESPACE::Status> WriteBatchHandlerJniCallback::k_op(
return nullptr;
} 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;
}
}

View File

@ -9,11 +9,13 @@
#ifndef JAVA_ROCKSJNI_WRITEBATCHHANDLERJNICALLBACK_H_
#define JAVA_ROCKSJNI_WRITEBATCHHANDLERJNICALLBACK_H_
#include <functional>
#include <jni.h>
#include <functional>
#include <memory>
#include "rocksjni/jnicallback.h"
#include "rocksdb/write_batch.h"
#include "rocksjni/jnicallback.h"
namespace ROCKSDB_NAMESPACE {
/**
@ -23,68 +25,67 @@ namespace ROCKSDB_NAMESPACE {
* which calls the appropriate Java method.
* 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:
WriteBatchHandlerJniCallback(
JNIEnv* env, jobject jWriteBackHandler);
Status PutCF(uint32_t column_family_id, const Slice& key,
const Slice& value);
void Put(const Slice& key, const Slice& value);
Status MergeCF(uint32_t column_family_id, const Slice& key,
const Slice& value);
void Merge(const Slice& key, const Slice& value);
Status DeleteCF(uint32_t column_family_id, const Slice& key);
void Delete(const Slice& key);
Status SingleDeleteCF(uint32_t column_family_id, const Slice& key);
void SingleDelete(const Slice& key);
Status DeleteRangeCF(uint32_t column_family_id, const Slice& beginKey,
const Slice& endKey);
void DeleteRange(const Slice& beginKey, const Slice& endKey);
void LogData(const Slice& blob);
Status PutBlobIndexCF(uint32_t column_family_id, const Slice& key,
const Slice& value);
Status MarkBeginPrepare(bool);
Status MarkEndPrepare(const Slice& xid);
Status MarkNoop(bool empty_batch);
Status MarkRollback(const Slice& xid);
Status MarkCommit(const Slice& xid);
Status MarkCommitWithTimestamp(const Slice& xid, const Slice& commit_ts);
bool Continue();
WriteBatchHandlerJniCallback(JNIEnv* env, jobject jWriteBackHandler);
Status PutCF(uint32_t column_family_id, const Slice& key, const Slice& value);
void Put(const Slice& key, const Slice& value);
Status MergeCF(uint32_t column_family_id, const Slice& key,
const Slice& value);
void Merge(const Slice& key, const Slice& value);
Status DeleteCF(uint32_t column_family_id, const Slice& key);
void Delete(const Slice& key);
Status SingleDeleteCF(uint32_t column_family_id, const Slice& key);
void SingleDelete(const Slice& key);
Status DeleteRangeCF(uint32_t column_family_id, const Slice& beginKey,
const Slice& endKey);
void DeleteRange(const Slice& beginKey, const Slice& endKey);
void LogData(const Slice& blob);
Status PutBlobIndexCF(uint32_t column_family_id, const Slice& key,
const Slice& value);
Status MarkBeginPrepare(bool);
Status MarkEndPrepare(const Slice& xid);
Status MarkNoop(bool empty_batch);
Status MarkRollback(const Slice& xid);
Status MarkCommit(const Slice& xid);
Status MarkCommitWithTimestamp(const Slice& xid, const Slice& commit_ts);
bool Continue();
private:
JNIEnv* m_env;
jmethodID m_jPutCfMethodId;
jmethodID m_jPutMethodId;
jmethodID m_jMergeCfMethodId;
jmethodID m_jMergeMethodId;
jmethodID m_jDeleteCfMethodId;
jmethodID m_jDeleteMethodId;
jmethodID m_jSingleDeleteCfMethodId;
jmethodID m_jSingleDeleteMethodId;
jmethodID m_jDeleteRangeCfMethodId;
jmethodID m_jDeleteRangeMethodId;
jmethodID m_jLogDataMethodId;
jmethodID m_jPutBlobIndexCfMethodId;
jmethodID m_jMarkBeginPrepareMethodId;
jmethodID m_jMarkEndPrepareMethodId;
jmethodID m_jMarkNoopMethodId;
jmethodID m_jMarkRollbackMethodId;
jmethodID m_jMarkCommitMethodId;
jmethodID m_jMarkCommitWithTimestampMethodId;
jmethodID m_jContinueMethodId;
/**
* @return A pointer to a ROCKSDB_NAMESPACE::Status or nullptr if an
* unexpected exception occurred
*/
std::unique_ptr<ROCKSDB_NAMESPACE::Status> kv_op(
const Slice& key, const Slice& value,
std::function<void(jbyteArray, jbyteArray)> kvFn);
/**
* @return A pointer to a ROCKSDB_NAMESPACE::Status or nullptr if an
* unexpected exception occurred
*/
std::unique_ptr<ROCKSDB_NAMESPACE::Status> k_op(
const Slice& key, std::function<void(jbyteArray)> kFn);
JNIEnv* m_env;
jmethodID m_jPutCfMethodId;
jmethodID m_jPutMethodId;
jmethodID m_jMergeCfMethodId;
jmethodID m_jMergeMethodId;
jmethodID m_jDeleteCfMethodId;
jmethodID m_jDeleteMethodId;
jmethodID m_jSingleDeleteCfMethodId;
jmethodID m_jSingleDeleteMethodId;
jmethodID m_jDeleteRangeCfMethodId;
jmethodID m_jDeleteRangeMethodId;
jmethodID m_jLogDataMethodId;
jmethodID m_jPutBlobIndexCfMethodId;
jmethodID m_jMarkBeginPrepareMethodId;
jmethodID m_jMarkEndPrepareMethodId;
jmethodID m_jMarkNoopMethodId;
jmethodID m_jMarkRollbackMethodId;
jmethodID m_jMarkCommitMethodId;
jmethodID m_jMarkCommitWithTimestampMethodId;
jmethodID m_jContinueMethodId;
/**
* @return A pointer to a ROCKSDB_NAMESPACE::Status or nullptr if an
* unexpected exception occurred
*/
std::unique_ptr<ROCKSDB_NAMESPACE::Status> kv_op(
const Slice& key, const Slice& value,
std::function<void(jbyteArray, jbyteArray)> kvFn);
/**
* @return A pointer to a ROCKSDB_NAMESPACE::Status or nullptr if an
* unexpected exception occurred
*/
std::unique_ptr<ROCKSDB_NAMESPACE::Status> k_op(
const Slice& key, std::function<void(jbyteArray)> kFn);
};
} // namespace ROCKSDB_NAMESPACE