Fix pointer to jlong conversion in 32 bit OS (#9396)

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

Reviewed By: jay-zhuang

Differential Revision: D34529654

Pulled By: pdillinger

fbshipit-source-id: cf62152ba86b02f9ffa7780f370ad49089e56a0b
main
Si Ke 3 years ago committed by Facebook GitHub Bot
parent 7d7e88c7d1
commit 06c8afeff5
  1. 3
      java/rocksjni/backupablejni.cc
  2. 3
      java/rocksjni/backupenginejni.cc
  3. 3
      java/rocksjni/cassandra_compactionfilterjni.cc
  4. 4
      java/rocksjni/cassandra_value_operator.cc
  5. 7
      java/rocksjni/checkpoint.cc
  6. 6
      java/rocksjni/clock_cache.cc
  7. 3
      java/rocksjni/compact_range_options.cc
  8. 4
      java/rocksjni/compaction_filter_factory.cc
  9. 5
      java/rocksjni/compaction_job_info.cc
  10. 6
      java/rocksjni/compaction_job_stats.cc
  11. 4
      java/rocksjni/compaction_options.cc
  12. 3
      java/rocksjni/compaction_options_fifo.cc
  13. 3
      java/rocksjni/compaction_options_universal.cc
  14. 4
      java/rocksjni/comparator.cc
  15. 3
      java/rocksjni/compression_options.cc
  16. 3
      java/rocksjni/concurrent_task_limiter.cc
  17. 3
      java/rocksjni/config_options.cc
  18. 37
      java/rocksjni/cplusplus_to_java_convert.h
  19. 7
      java/rocksjni/env.cc
  20. 5
      java/rocksjni/env_options.cc
  21. 3
      java/rocksjni/event_listener.cc
  22. 4
      java/rocksjni/filter.cc
  23. 5
      java/rocksjni/ingest_external_file_options.cc
  24. 10
      java/rocksjni/loggerjnicallback.cc
  25. 6
      java/rocksjni/lru_cache.cc
  26. 9
      java/rocksjni/memtablejni.cc
  27. 11
      java/rocksjni/merge_operator.cc
  28. 7
      java/rocksjni/native_comparator_wrapper_test.cc
  29. 18
      java/rocksjni/optimistic_transaction_db.cc
  30. 4
      java/rocksjni/optimistic_transaction_options.cc
  31. 51
      java/rocksjni/options.cc
  32. 7
      java/rocksjni/persistent_cache.cc
  33. 18
      java/rocksjni/portal.h
  34. 3
      java/rocksjni/ratelimiterjni.cc
  35. 3
      java/rocksjni/remove_emptyvalue_compactionfilterjni.cc
  36. 3
      java/rocksjni/restorejni.cc
  37. 23
      java/rocksjni/rocksjni.cc
  38. 15
      java/rocksjni/slice.cc
  39. 7
      java/rocksjni/sst_file_manager.cc
  40. 6
      java/rocksjni/sst_file_readerjni.cc
  41. 6
      java/rocksjni/sst_file_writerjni.cc
  42. 3
      java/rocksjni/sst_partitioner.cc
  43. 7
      java/rocksjni/statistics.cc
  44. 7
      java/rocksjni/table.cc
  45. 4
      java/rocksjni/table_filter.cc
  46. 3
      java/rocksjni/trace_writer.cc
  47. 18
      java/rocksjni/transaction.cc
  48. 25
      java/rocksjni/transaction_db.cc
  49. 5
      java/rocksjni/transaction_db_options.cc
  50. 3
      java/rocksjni/transaction_notifier.cc
  51. 6
      java/rocksjni/transaction_notifier_jnicallback.cc
  52. 4
      java/rocksjni/transaction_options.cc
  53. 10
      java/rocksjni/ttl.cc
  54. 3
      java/rocksjni/wal_filter.cc
  55. 12
      java/rocksjni/wal_filter_jnicallback.cc
  56. 10
      java/rocksjni/write_batch.cc
  57. 18
      java/rocksjni/write_batch_with_index.cc
  58. 7
      java/rocksjni/write_buffer_manager.cc

@ -16,6 +16,7 @@
#include "include/org_rocksdb_BackupEngineOptions.h"
#include "rocksdb/utilities/backup_engine.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
///////////////////////////////////////////////////////////////////////////
@ -35,7 +36,7 @@ jlong Java_org_rocksdb_BackupEngineOptions_newBackupEngineOptions(
}
auto* bopt = new ROCKSDB_NAMESPACE::BackupEngineOptions(cpath);
env->ReleaseStringUTFChars(jpath, cpath);
return reinterpret_cast<jlong>(bopt);
return GET_CPLUSPLUS_POINTER(bopt);
}
/*

@ -12,6 +12,7 @@
#include "include/org_rocksdb_BackupEngine.h"
#include "rocksdb/utilities/backup_engine.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
/*
@ -31,7 +32,7 @@ jlong Java_org_rocksdb_BackupEngine_open(JNIEnv* env, jclass /*jcls*/,
rocks_env, *backup_engine_options, &backup_engine);
if (status.ok()) {
return reinterpret_cast<jlong>(backup_engine);
return GET_CPLUSPLUS_POINTER(backup_engine);
} else {
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, status);
return 0;

@ -6,6 +6,7 @@
#include <jni.h>
#include "include/org_rocksdb_CassandraCompactionFilter.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "utilities/cassandra/cassandra_compaction_filter.h"
/*
@ -20,5 +21,5 @@ jlong Java_org_rocksdb_CassandraCompactionFilter_createNewCassandraCompactionFil
new ROCKSDB_NAMESPACE::cassandra::CassandraCompactionFilter(
purge_ttl_on_expiration, gc_grace_period_in_seconds);
// set the native handle to our native compaction filter
return reinterpret_cast<jlong>(compaction_filter);
return GET_CPLUSPLUS_POINTER(compaction_filter);
}

@ -6,6 +6,7 @@
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <memory>
#include <string>
@ -17,6 +18,7 @@
#include "rocksdb/slice_transform.h"
#include "rocksdb/statistics.h"
#include "rocksdb/table.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
#include "utilities/cassandra/merge_operator.h"
@ -31,7 +33,7 @@ jlong Java_org_rocksdb_CassandraValueMergeOperator_newSharedCassandraValueMergeO
auto* op = new std::shared_ptr<ROCKSDB_NAMESPACE::MergeOperator>(
new ROCKSDB_NAMESPACE::cassandra::CassandraValueMergeOperator(
gcGracePeriodInSeconds, operands_limit));
return reinterpret_cast<jlong>(op);
return GET_CPLUSPLUS_POINTER(op);
}
/*

@ -6,14 +6,17 @@
// This file implements the "bridge" between Java and C++ and enables
// calling c++ ROCKSDB_NAMESPACE::Checkpoint methods from Java side.
#include "rocksdb/utilities/checkpoint.h"
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include "include/org_rocksdb_Checkpoint.h"
#include "rocksdb/db.h"
#include "rocksdb/utilities/checkpoint.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
/*
* Class: org_rocksdb_Checkpoint
@ -26,7 +29,7 @@ jlong Java_org_rocksdb_Checkpoint_newCheckpoint(JNIEnv* /*env*/,
auto* db = reinterpret_cast<ROCKSDB_NAMESPACE::DB*>(jdb_handle);
ROCKSDB_NAMESPACE::Checkpoint* checkpoint;
ROCKSDB_NAMESPACE::Checkpoint::Create(db, &checkpoint);
return reinterpret_cast<jlong>(checkpoint);
return GET_CPLUSPLUS_POINTER(checkpoint);
}
/*

@ -6,10 +6,12 @@
// This file implements the "bridge" between Java and C++ for
// ROCKSDB_NAMESPACE::ClockCache.
#include "cache/clock_cache.h"
#include <jni.h>
#include "cache/clock_cache.h"
#include "include/org_rocksdb_ClockCache.h"
#include "rocksjni/cplusplus_to_java_convert.h"
/*
* Class: org_rocksdb_ClockCache
@ -23,7 +25,7 @@ jlong Java_org_rocksdb_ClockCache_newClockCache(
ROCKSDB_NAMESPACE::NewClockCache(
static_cast<size_t>(jcapacity), static_cast<int>(jnum_shard_bits),
static_cast<bool>(jstrict_capacity_limit)));
return reinterpret_cast<jlong>(sptr_clock_cache);
return GET_CPLUSPLUS_POINTER(sptr_clock_cache);
}
/*

@ -10,6 +10,7 @@
#include "include/org_rocksdb_CompactRangeOptions.h"
#include "rocksdb/options.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
/*
@ -20,7 +21,7 @@
jlong Java_org_rocksdb_CompactRangeOptions_newCompactRangeOptions(
JNIEnv* /*env*/, jclass /*jclazz*/) {
auto* options = new ROCKSDB_NAMESPACE::CompactRangeOptions();
return reinterpret_cast<jlong>(options);
return GET_CPLUSPLUS_POINTER(options);
}

@ -7,10 +7,12 @@
// ROCKSDB_NAMESPACE::CompactionFilterFactory.
#include <jni.h>
#include <memory>
#include "include/org_rocksdb_AbstractCompactionFilterFactory.h"
#include "rocksjni/compaction_filter_factory_jnicallback.h"
#include "rocksjni/cplusplus_to_java_convert.h"
/*
* Class: org_rocksdb_AbstractCompactionFilterFactory
@ -23,7 +25,7 @@ jlong Java_org_rocksdb_AbstractCompactionFilterFactory_createNewCompactionFilter
new ROCKSDB_NAMESPACE::CompactionFilterFactoryJniCallback(env, jobj);
auto* ptr_sptr_cff = new std::shared_ptr<
ROCKSDB_NAMESPACE::CompactionFilterFactoryJniCallback>(cff);
return reinterpret_cast<jlong>(ptr_sptr_cff);
return GET_CPLUSPLUS_POINTER(ptr_sptr_cff);
}
/*

@ -10,6 +10,7 @@
#include "include/org_rocksdb_CompactionJobInfo.h"
#include "rocksdb/listener.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
/*
@ -20,7 +21,7 @@
jlong Java_org_rocksdb_CompactionJobInfo_newCompactionJobInfo(
JNIEnv*, jclass) {
auto* compact_job_info = new ROCKSDB_NAMESPACE::CompactionJobInfo();
return reinterpret_cast<jlong>(compact_job_info);
return GET_CPLUSPLUS_POINTER(compact_job_info);
}
/*
@ -227,5 +228,5 @@ jlong Java_org_rocksdb_CompactionJobInfo_stats(
reinterpret_cast<ROCKSDB_NAMESPACE::CompactionJobInfo*>(jhandle);
auto* stats = new ROCKSDB_NAMESPACE::CompactionJobStats();
stats->Add(compact_job_info->stats);
return reinterpret_cast<jlong>(stats);
return GET_CPLUSPLUS_POINTER(stats);
}

@ -6,10 +6,12 @@
// This file implements the "bridge" between Java and C++ for
// ROCKSDB_NAMESPACE::CompactionJobStats.
#include "rocksdb/compaction_job_stats.h"
#include <jni.h>
#include "include/org_rocksdb_CompactionJobStats.h"
#include "rocksdb/compaction_job_stats.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
/*
@ -20,7 +22,7 @@
jlong Java_org_rocksdb_CompactionJobStats_newCompactionJobStats(
JNIEnv*, jclass) {
auto* compact_job_stats = new ROCKSDB_NAMESPACE::CompactionJobStats();
return reinterpret_cast<jlong>(compact_job_stats);
return GET_CPLUSPLUS_POINTER(compact_job_stats);
}
/*

@ -10,9 +10,9 @@
#include "include/org_rocksdb_CompactionOptions.h"
#include "rocksdb/options.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
/*
* Class: org_rocksdb_CompactionOptions
* Method: newCompactionOptions
@ -21,7 +21,7 @@
jlong Java_org_rocksdb_CompactionOptions_newCompactionOptions(
JNIEnv*, jclass) {
auto* compact_opts = new ROCKSDB_NAMESPACE::CompactionOptions();
return reinterpret_cast<jlong>(compact_opts);
return GET_CPLUSPLUS_POINTER(compact_opts);
}
/*

@ -10,6 +10,7 @@
#include "include/org_rocksdb_CompactionOptionsFIFO.h"
#include "rocksdb/advanced_options.h"
#include "rocksjni/cplusplus_to_java_convert.h"
/*
* Class: org_rocksdb_CompactionOptionsFIFO
@ -19,7 +20,7 @@
jlong Java_org_rocksdb_CompactionOptionsFIFO_newCompactionOptionsFIFO(
JNIEnv*, jclass) {
const auto* opt = new ROCKSDB_NAMESPACE::CompactionOptionsFIFO();
return reinterpret_cast<jlong>(opt);
return GET_CPLUSPLUS_POINTER(opt);
}
/*

@ -10,6 +10,7 @@
#include "include/org_rocksdb_CompactionOptionsUniversal.h"
#include "rocksdb/advanced_options.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
/*
@ -20,7 +21,7 @@
jlong Java_org_rocksdb_CompactionOptionsUniversal_newCompactionOptionsUniversal(
JNIEnv*, jclass) {
const auto* opt = new ROCKSDB_NAMESPACE::CompactionOptionsUniversal();
return reinterpret_cast<jlong>(opt);
return GET_CPLUSPLUS_POINTER(opt);
}
/*

@ -9,12 +9,14 @@
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <functional>
#include <string>
#include "include/org_rocksdb_AbstractComparator.h"
#include "include/org_rocksdb_NativeComparatorWrapper.h"
#include "rocksjni/comparatorjnicallback.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
/*
@ -29,7 +31,7 @@ jlong Java_org_rocksdb_AbstractComparator_createNewComparator(
copt_handle);
auto* c =
new ROCKSDB_NAMESPACE::ComparatorJniCallback(env, jcomparator, copt);
return reinterpret_cast<jlong>(c);
return GET_CPLUSPLUS_POINTER(c);
}
/*

@ -10,6 +10,7 @@
#include "include/org_rocksdb_CompressionOptions.h"
#include "rocksdb/advanced_options.h"
#include "rocksjni/cplusplus_to_java_convert.h"
/*
* Class: org_rocksdb_CompressionOptions
@ -19,7 +20,7 @@
jlong Java_org_rocksdb_CompressionOptions_newCompressionOptions(
JNIEnv*, jclass) {
const auto* opt = new ROCKSDB_NAMESPACE::CompressionOptions();
return reinterpret_cast<jlong>(opt);
return GET_CPLUSPLUS_POINTER(opt);
}
/*

@ -6,6 +6,7 @@
#include <string>
#include "include/org_rocksdb_ConcurrentTaskLimiterImpl.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
/*
@ -25,7 +26,7 @@ jlong Java_org_rocksdb_ConcurrentTaskLimiterImpl_newConcurrentTaskLimiterImpl0(
auto* ptr = new std::shared_ptr<ROCKSDB_NAMESPACE::ConcurrentTaskLimiter>(
ROCKSDB_NAMESPACE::NewConcurrentTaskLimiter(name, limit));
return reinterpret_cast<jlong>(ptr);
return GET_CPLUSPLUS_POINTER(ptr);
}
/*

@ -11,6 +11,7 @@
#include "include/org_rocksdb_ConfigOptions.h"
#include "rocksdb/convenience.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
/*
@ -32,7 +33,7 @@ void Java_org_rocksdb_ConfigOptions_disposeInternal(JNIEnv *, jobject,
*/
jlong Java_org_rocksdb_ConfigOptions_newConfigOptions(JNIEnv *, jclass) {
auto *cfg_opt = new ROCKSDB_NAMESPACE::ConfigOptions();
return reinterpret_cast<jlong>(cfg_opt);
return GET_CPLUSPLUS_POINTER(cfg_opt);
}
/*

@ -0,0 +1,37 @@
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
// This source code is licensed under both the GPLv2 (found in the
// COPYING file in the root directory) and Apache 2.0 License
// (found in the LICENSE.Apache file in the root directory).
#pragma once
/*
* This macro is used for 32 bit OS. In 32 bit OS, the result number is a
negative number if we use reinterpret_cast<jlong>(pointer).
* For example, jlong ptr = reinterpret_cast<jlong>(pointer), ptr is a negative
number in 32 bit OS.
* If we check ptr using ptr > 0, it fails. For example, the following code is
not correct.
* if (jblock_cache_handle > 0) {
std::shared_ptr<ROCKSDB_NAMESPACE::Cache> *pCache =
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Cache> *>(
jblock_cache_handle);
options.block_cache = *pCache;
}
* But the result number is positive number if we do
reinterpret_cast<size_t>(pointer) first and then cast it to jlong. size_t is 4
bytes long in 32 bit OS and 8 bytes long in 64 bit OS.
static_cast<jlong>(reinterpret_cast<size_t>(_pointer)) is also working in 64
bit OS.
*
* We don't need an opposite cast because it works from jlong to c++ pointer in
both 32 bit and 64 bit OS.
* For example, the following code is working in both 32 bit and 64 bit OS.
jblock_cache_handle is jlong.
* std::shared_ptr<ROCKSDB_NAMESPACE::Cache> *pCache =
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Cache> *>(
jblock_cache_handle);
*/
#define GET_CPLUSPLUS_POINTER(_pointer) \
static_cast<jlong>(reinterpret_cast<size_t>(_pointer))

@ -17,6 +17,7 @@
#include "include/org_rocksdb_RocksMemEnv.h"
#include "include/org_rocksdb_TimedEnv.h"
#include "portal.h"
#include "rocksjni/cplusplus_to_java_convert.h"
/*
* Class: org_rocksdb_Env
@ -25,7 +26,7 @@
*/
jlong Java_org_rocksdb_Env_getDefaultEnvInternal(
JNIEnv*, jclass) {
return reinterpret_cast<jlong>(ROCKSDB_NAMESPACE::Env::Default());
return GET_CPLUSPLUS_POINTER(ROCKSDB_NAMESPACE::Env::Default());
}
/*
@ -162,7 +163,7 @@ jobjectArray Java_org_rocksdb_Env_getThreadList(
jlong Java_org_rocksdb_RocksMemEnv_createMemEnv(
JNIEnv*, jclass, jlong jbase_env_handle) {
auto* base_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jbase_env_handle);
return reinterpret_cast<jlong>(ROCKSDB_NAMESPACE::NewMemEnv(base_env));
return GET_CPLUSPLUS_POINTER(ROCKSDB_NAMESPACE::NewMemEnv(base_env));
}
/*
@ -185,7 +186,7 @@ void Java_org_rocksdb_RocksMemEnv_disposeInternal(
jlong Java_org_rocksdb_TimedEnv_createTimedEnv(
JNIEnv*, jclass, jlong jbase_env_handle) {
auto* base_env = reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jbase_env_handle);
return reinterpret_cast<jlong>(ROCKSDB_NAMESPACE::NewTimedEnv(base_env));
return GET_CPLUSPLUS_POINTER(ROCKSDB_NAMESPACE::NewTimedEnv(base_env));
}
/*

@ -11,6 +11,7 @@
#include "include/org_rocksdb_EnvOptions.h"
#include "rocksdb/env.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#define ENV_OPTIONS_SET_BOOL(_jhandle, _opt) \
reinterpret_cast<ROCKSDB_NAMESPACE::EnvOptions *>(_jhandle)->_opt = \
@ -35,7 +36,7 @@
jlong Java_org_rocksdb_EnvOptions_newEnvOptions__(
JNIEnv*, jclass) {
auto *env_opt = new ROCKSDB_NAMESPACE::EnvOptions();
return reinterpret_cast<jlong>(env_opt);
return GET_CPLUSPLUS_POINTER(env_opt);
}
/*
@ -48,7 +49,7 @@ jlong Java_org_rocksdb_EnvOptions_newEnvOptions__J(
auto *db_options =
reinterpret_cast<ROCKSDB_NAMESPACE::DBOptions *>(jdboptions_handle);
auto *env_opt = new ROCKSDB_NAMESPACE::EnvOptions(*db_options);
return reinterpret_cast<jlong>(env_opt);
return GET_CPLUSPLUS_POINTER(env_opt);
}
/*

@ -11,6 +11,7 @@
#include <memory>
#include "include/org_rocksdb_AbstractEventListener.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/event_listener_jnicallback.h"
#include "rocksjni/portal.h"
@ -28,7 +29,7 @@ jlong Java_org_rocksdb_AbstractEventListener_createNewEventListener(
new std::shared_ptr<ROCKSDB_NAMESPACE::EventListener>(
new ROCKSDB_NAMESPACE::EventListenerJniCallback(
env, jobj, enabled_event_callbacks));
return reinterpret_cast<jlong>(sptr_event_listener);
return GET_CPLUSPLUS_POINTER(sptr_event_listener);
}
/*

@ -9,11 +9,13 @@
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include "include/org_rocksdb_BloomFilter.h"
#include "include/org_rocksdb_Filter.h"
#include "rocksdb/filter_policy.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
/*
@ -27,7 +29,7 @@ jlong Java_org_rocksdb_BloomFilter_createNewBloomFilter(JNIEnv* /*env*/,
auto* sptr_filter =
new std::shared_ptr<const ROCKSDB_NAMESPACE::FilterPolicy>(
ROCKSDB_NAMESPACE::NewBloomFilterPolicy(bits_per_key));
return reinterpret_cast<jlong>(sptr_filter);
return GET_CPLUSPLUS_POINTER(sptr_filter);
}
/*

@ -10,6 +10,7 @@
#include "include/org_rocksdb_IngestExternalFileOptions.h"
#include "rocksdb/options.h"
#include "rocksjni/cplusplus_to_java_convert.h"
/*
* Class: org_rocksdb_IngestExternalFileOptions
@ -19,7 +20,7 @@
jlong Java_org_rocksdb_IngestExternalFileOptions_newIngestExternalFileOptions__(
JNIEnv*, jclass) {
auto* options = new ROCKSDB_NAMESPACE::IngestExternalFileOptions();
return reinterpret_cast<jlong>(options);
return GET_CPLUSPLUS_POINTER(options);
}
/*
@ -36,7 +37,7 @@ jlong Java_org_rocksdb_IngestExternalFileOptions_newIngestExternalFileOptions__Z
options->snapshot_consistency = static_cast<bool>(jsnapshot_consistency);
options->allow_global_seqno = static_cast<bool>(jallow_global_seqno);
options->allow_blocking_flush = static_cast<bool>(jallow_blocking_flush);
return reinterpret_cast<jlong>(options);
return GET_CPLUSPLUS_POINTER(options);
}
/*

@ -6,11 +6,13 @@
// This file implements the callback "bridge" between Java and C++ for
// ROCKSDB_NAMESPACE::Logger.
#include "include/org_rocksdb_Logger.h"
#include "rocksjni/loggerjnicallback.h"
#include <cstdarg>
#include <cstdio>
#include "rocksjni/loggerjnicallback.h"
#include "include/org_rocksdb_Logger.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
namespace ROCKSDB_NAMESPACE {
@ -234,7 +236,7 @@ jlong Java_org_rocksdb_Logger_createNewLoggerOptions(JNIEnv* env, jobject jobj,
auto* options = reinterpret_cast<ROCKSDB_NAMESPACE::Options*>(joptions);
sptr_logger->get()->SetInfoLogLevel(options->info_log_level);
return reinterpret_cast<jlong>(sptr_logger);
return GET_CPLUSPLUS_POINTER(sptr_logger);
}
/*
@ -253,7 +255,7 @@ jlong Java_org_rocksdb_Logger_createNewLoggerDbOptions(JNIEnv* env,
reinterpret_cast<ROCKSDB_NAMESPACE::DBOptions*>(jdb_options);
sptr_logger->get()->SetInfoLogLevel(db_options->info_log_level);
return reinterpret_cast<jlong>(sptr_logger);
return GET_CPLUSPLUS_POINTER(sptr_logger);
}
/*

@ -6,10 +6,12 @@
// This file implements the "bridge" between Java and C++ for
// ROCKSDB_NAMESPACE::LRUCache.
#include "cache/lru_cache.h"
#include <jni.h>
#include "cache/lru_cache.h"
#include "include/org_rocksdb_LRUCache.h"
#include "rocksjni/cplusplus_to_java_convert.h"
/*
* Class: org_rocksdb_LRUCache
@ -26,7 +28,7 @@ jlong Java_org_rocksdb_LRUCache_newLRUCache(JNIEnv* /*env*/, jclass /*jcls*/,
static_cast<size_t>(jcapacity), static_cast<int>(jnum_shard_bits),
static_cast<bool>(jstrict_capacity_limit),
static_cast<double>(jhigh_pri_pool_ratio)));
return reinterpret_cast<size_t>(sptr_lru_cache);
return GET_CPLUSPLUS_POINTER(sptr_lru_cache);
}
/*

@ -10,6 +10,7 @@
#include "include/org_rocksdb_SkipListMemTableConfig.h"
#include "include/org_rocksdb_VectorMemTableConfig.h"
#include "rocksdb/memtablerep.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
/*
@ -23,7 +24,7 @@ jlong Java_org_rocksdb_HashSkipListMemTableConfig_newMemTableFactoryHandle(
ROCKSDB_NAMESPACE::Status s =
ROCKSDB_NAMESPACE::JniUtil::check_if_jlong_fits_size_t(jbucket_count);
if (s.ok()) {
return reinterpret_cast<jlong>(ROCKSDB_NAMESPACE::NewHashSkipListRepFactory(
return GET_CPLUSPLUS_POINTER(ROCKSDB_NAMESPACE::NewHashSkipListRepFactory(
static_cast<size_t>(jbucket_count), static_cast<int32_t>(jheight),
static_cast<int32_t>(jbranching_factor)));
}
@ -46,7 +47,7 @@ jlong Java_org_rocksdb_HashLinkedListMemTableConfig_newMemTableFactoryHandle(
ROCKSDB_NAMESPACE::JniUtil::check_if_jlong_fits_size_t(
jhuge_page_tlb_size);
if (statusBucketCount.ok() && statusHugePageTlb.ok()) {
return reinterpret_cast<jlong>(ROCKSDB_NAMESPACE::NewHashLinkListRepFactory(
return GET_CPLUSPLUS_POINTER(ROCKSDB_NAMESPACE::NewHashLinkListRepFactory(
static_cast<size_t>(jbucket_count),
static_cast<size_t>(jhuge_page_tlb_size),
static_cast<int32_t>(jbucket_entries_logging_threshold),
@ -68,7 +69,7 @@ jlong Java_org_rocksdb_VectorMemTableConfig_newMemTableFactoryHandle(
ROCKSDB_NAMESPACE::Status s =
ROCKSDB_NAMESPACE::JniUtil::check_if_jlong_fits_size_t(jreserved_size);
if (s.ok()) {
return reinterpret_cast<jlong>(new ROCKSDB_NAMESPACE::VectorRepFactory(
return GET_CPLUSPLUS_POINTER(new ROCKSDB_NAMESPACE::VectorRepFactory(
static_cast<size_t>(jreserved_size)));
}
ROCKSDB_NAMESPACE::IllegalArgumentExceptionJni::ThrowNew(env, s);
@ -85,7 +86,7 @@ jlong Java_org_rocksdb_SkipListMemTableConfig_newMemTableFactoryHandle0(
ROCKSDB_NAMESPACE::Status s =
ROCKSDB_NAMESPACE::JniUtil::check_if_jlong_fits_size_t(jlookahead);
if (s.ok()) {
return reinterpret_cast<jlong>(new ROCKSDB_NAMESPACE::SkipListFactory(
return GET_CPLUSPLUS_POINTER(new ROCKSDB_NAMESPACE::SkipListFactory(
static_cast<size_t>(jlookahead)));
}
ROCKSDB_NAMESPACE::IllegalArgumentExceptionJni::ThrowNew(env, s);

@ -7,9 +7,12 @@
// This file implements the "bridge" between Java and C++
// for ROCKSDB_NAMESPACE::MergeOperator.
#include "rocksdb/merge_operator.h"
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <memory>
#include <string>
@ -17,11 +20,11 @@
#include "include/org_rocksdb_UInt64AddOperator.h"
#include "rocksdb/db.h"
#include "rocksdb/memtablerep.h"
#include "rocksdb/merge_operator.h"
#include "rocksdb/options.h"
#include "rocksdb/slice_transform.h"
#include "rocksdb/statistics.h"
#include "rocksdb/table.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
#include "utilities/merge_operators.h"
@ -36,7 +39,7 @@ jlong Java_org_rocksdb_StringAppendOperator_newSharedStringAppendOperator__C(
new std::shared_ptr<ROCKSDB_NAMESPACE::MergeOperator>(
ROCKSDB_NAMESPACE::MergeOperators::CreateStringAppendOperator(
(char)jdelim));
return reinterpret_cast<jlong>(sptr_string_append_op);
return GET_CPLUSPLUS_POINTER(sptr_string_append_op);
}
jlong Java_org_rocksdb_StringAppendOperator_newSharedStringAppendOperator__Ljava_lang_String_2(
@ -50,7 +53,7 @@ jlong Java_org_rocksdb_StringAppendOperator_newSharedStringAppendOperator__Ljava
auto* sptr_string_append_op =
new std::shared_ptr<ROCKSDB_NAMESPACE::MergeOperator>(
ROCKSDB_NAMESPACE::MergeOperators::CreateStringAppendOperator(delim));
return reinterpret_cast<jlong>(sptr_string_append_op);
return GET_CPLUSPLUS_POINTER(sptr_string_append_op);
}
/*
@ -77,7 +80,7 @@ jlong Java_org_rocksdb_UInt64AddOperator_newSharedUInt64AddOperator(
auto* sptr_uint64_add_op =
new std::shared_ptr<ROCKSDB_NAMESPACE::MergeOperator>(
ROCKSDB_NAMESPACE::MergeOperators::CreateUInt64AddOperator());
return reinterpret_cast<jlong>(sptr_uint64_add_op);
return GET_CPLUSPLUS_POINTER(sptr_uint64_add_op);
}
/*

@ -4,12 +4,13 @@
// (found in the LICENSE.Apache file in the root directory).
#include <jni.h>
#include <string>
#include "include/org_rocksdb_NativeComparatorWrapperTest_NativeStringComparatorWrapper.h"
#include "rocksdb/comparator.h"
#include "rocksdb/slice.h"
#include "include/org_rocksdb_NativeComparatorWrapperTest_NativeStringComparatorWrapper.h"
#include "rocksjni/cplusplus_to_java_convert.h"
namespace ROCKSDB_NAMESPACE {
@ -40,5 +41,5 @@ jlong Java_org_rocksdb_NativeComparatorWrapperTest_00024NativeStringComparatorWr
JNIEnv* /*env*/, jobject /*jobj*/) {
auto* comparator =
new ROCKSDB_NAMESPACE::NativeComparatorWrapperTestStringComparator();
return reinterpret_cast<jlong>(comparator);
return GET_CPLUSPLUS_POINTER(comparator);
}

@ -6,14 +6,14 @@
// This file implements the "bridge" between Java and C++
// for ROCKSDB_NAMESPACE::TransactionDB.
#include "rocksdb/utilities/optimistic_transaction_db.h"
#include <jni.h>
#include "include/org_rocksdb_OptimisticTransactionDB.h"
#include "rocksdb/options.h"
#include "rocksdb/utilities/optimistic_transaction_db.h"
#include "rocksdb/utilities/transaction.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
/*
@ -38,7 +38,7 @@ jlong Java_org_rocksdb_OptimisticTransactionDB_open__JLjava_lang_String_2(
env->ReleaseStringUTFChars(jdb_path, db_path);
if (s.ok()) {
return reinterpret_cast<jlong>(otdb);
return GET_CPLUSPLUS_POINTER(otdb);
} else {
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s);
return 0;
@ -194,7 +194,7 @@ jlong Java_org_rocksdb_OptimisticTransactionDB_beginTransaction__JJ(
reinterpret_cast<ROCKSDB_NAMESPACE::WriteOptions*>(jwrite_options_handle);
ROCKSDB_NAMESPACE::Transaction* txn =
optimistic_txn_db->BeginTransaction(*write_options);
return reinterpret_cast<jlong>(txn);
return GET_CPLUSPLUS_POINTER(txn);
}
/*
@ -214,7 +214,7 @@ jlong Java_org_rocksdb_OptimisticTransactionDB_beginTransaction__JJJ(
joptimistic_txn_options_handle);
ROCKSDB_NAMESPACE::Transaction* txn = optimistic_txn_db->BeginTransaction(
*write_options, *optimistic_txn_options);
return reinterpret_cast<jlong>(txn);
return GET_CPLUSPLUS_POINTER(txn);
}
/*
@ -240,7 +240,7 @@ jlong Java_org_rocksdb_OptimisticTransactionDB_beginTransaction_1withOld__JJJ(
// when providing an old_optimistic_txn
assert(txn == old_txn);
return reinterpret_cast<jlong>(txn);
return GET_CPLUSPLUS_POINTER(txn);
}
/*
@ -268,7 +268,7 @@ jlong Java_org_rocksdb_OptimisticTransactionDB_beginTransaction_1withOld__JJJJ(
// when providing an old_optimisic_txn
assert(txn == old_txn);
return reinterpret_cast<jlong>(txn);
return GET_CPLUSPLUS_POINTER(txn);
}
/*
@ -280,5 +280,5 @@ jlong Java_org_rocksdb_OptimisticTransactionDB_getBaseDB(
JNIEnv*, jobject, jlong jhandle) {
auto* optimistic_txn_db =
reinterpret_cast<ROCKSDB_NAMESPACE::OptimisticTransactionDB*>(jhandle);
return reinterpret_cast<jlong>(optimistic_txn_db->GetBaseDB());
return GET_CPLUSPLUS_POINTER(optimistic_txn_db->GetBaseDB());
}

@ -9,9 +9,9 @@
#include <jni.h>
#include "include/org_rocksdb_OptimisticTransactionOptions.h"
#include "rocksdb/comparator.h"
#include "rocksdb/utilities/optimistic_transaction_db.h"
#include "rocksjni/cplusplus_to_java_convert.h"
/*
* Class: org_rocksdb_OptimisticTransactionOptions
@ -22,7 +22,7 @@ jlong Java_org_rocksdb_OptimisticTransactionOptions_newOptimisticTransactionOpti
JNIEnv* /*env*/, jclass /*jcls*/) {
ROCKSDB_NAMESPACE::OptimisticTransactionOptions* opts =
new ROCKSDB_NAMESPACE::OptimisticTransactionOptions();
return reinterpret_cast<jlong>(opts);
return GET_CPLUSPLUS_POINTER(opts);
}
/*

@ -33,6 +33,7 @@
#include "rocksdb/statistics.h"
#include "rocksdb/table.h"
#include "rocksjni/comparatorjnicallback.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
#include "rocksjni/statisticsjni.h"
#include "rocksjni/table_filter_jnicallback.h"
@ -46,7 +47,7 @@
jlong Java_org_rocksdb_Options_newOptions__(
JNIEnv*, jclass) {
auto* op = new ROCKSDB_NAMESPACE::Options();
return reinterpret_cast<jlong>(op);
return GET_CPLUSPLUS_POINTER(op);
}
/*
@ -61,7 +62,7 @@ jlong Java_org_rocksdb_Options_newOptions__JJ(
auto* cfOpt = reinterpret_cast<const ROCKSDB_NAMESPACE::ColumnFamilyOptions*>(
jcfoptions);
auto* op = new ROCKSDB_NAMESPACE::Options(*dbOpt, *cfOpt);
return reinterpret_cast<jlong>(op);
return GET_CPLUSPLUS_POINTER(op);
}
/*
@ -73,7 +74,7 @@ jlong Java_org_rocksdb_Options_copyOptions(
JNIEnv*, jclass, jlong jhandle) {
auto new_opt = new ROCKSDB_NAMESPACE::Options(
*(reinterpret_cast<ROCKSDB_NAMESPACE::Options*>(jhandle)));
return reinterpret_cast<jlong>(new_opt);
return GET_CPLUSPLUS_POINTER(new_opt);
}
/*
@ -332,7 +333,7 @@ jlong Java_org_rocksdb_Options_statistics(
} else {
std::shared_ptr<ROCKSDB_NAMESPACE::Statistics>* pSptr =
new std::shared_ptr<ROCKSDB_NAMESPACE::Statistics>(sptr);
return reinterpret_cast<jlong>(pSptr);
return GET_CPLUSPLUS_POINTER(pSptr);
}
}
@ -3850,7 +3851,7 @@ jlong Java_org_rocksdb_Options_blobCompactionReadaheadSize(JNIEnv*, jobject,
jlong Java_org_rocksdb_ColumnFamilyOptions_newColumnFamilyOptions(
JNIEnv*, jclass) {
auto* op = new ROCKSDB_NAMESPACE::ColumnFamilyOptions();
return reinterpret_cast<jlong>(op);
return GET_CPLUSPLUS_POINTER(op);
}
/*
@ -3862,7 +3863,7 @@ jlong Java_org_rocksdb_ColumnFamilyOptions_copyColumnFamilyOptions(
JNIEnv*, jclass, jlong jhandle) {
auto new_opt = new ROCKSDB_NAMESPACE::ColumnFamilyOptions(
*(reinterpret_cast<ROCKSDB_NAMESPACE::ColumnFamilyOptions*>(jhandle)));
return reinterpret_cast<jlong>(new_opt);
return GET_CPLUSPLUS_POINTER(new_opt);
}
/*
@ -3874,7 +3875,7 @@ jlong Java_org_rocksdb_ColumnFamilyOptions_newColumnFamilyOptionsFromOptions(
JNIEnv*, jclass, jlong joptions_handle) {
auto new_opt = new ROCKSDB_NAMESPACE::ColumnFamilyOptions(
*reinterpret_cast<ROCKSDB_NAMESPACE::Options*>(joptions_handle));
return reinterpret_cast<jlong>(new_opt);
return GET_CPLUSPLUS_POINTER(new_opt);
}
/*
@ -3902,7 +3903,7 @@ jlong Java_org_rocksdb_ColumnFamilyOptions_getColumnFamilyOptionsFromProps__JLja
// Check if ColumnFamilyOptions creation was possible.
jlong ret_value = 0;
if (status.ok()) {
ret_value = reinterpret_cast<jlong>(cf_options);
ret_value = GET_CPLUSPLUS_POINTER(cf_options);
} else {
// if operation failed the ColumnFamilyOptions need to be deleted
// again to prevent a memory leak.
@ -3934,7 +3935,7 @@ jlong Java_org_rocksdb_ColumnFamilyOptions_getColumnFamilyOptionsFromProps__Ljav
// Check if ColumnFamilyOptions creation was possible.
jlong ret_value = 0;
if (status.ok()) {
ret_value = reinterpret_cast<jlong>(cf_options);
ret_value = GET_CPLUSPLUS_POINTER(cf_options);
} else {
// if operation failed the ColumnFamilyOptions need to be deleted
// again to prevent a memory leak.
@ -5633,7 +5634,7 @@ jlong Java_org_rocksdb_ColumnFamilyOptions_blobCompactionReadaheadSize(
jlong Java_org_rocksdb_DBOptions_newDBOptions(
JNIEnv*, jclass) {
auto* dbop = new ROCKSDB_NAMESPACE::DBOptions();
return reinterpret_cast<jlong>(dbop);
return GET_CPLUSPLUS_POINTER(dbop);
}
/*
@ -5645,7 +5646,7 @@ jlong Java_org_rocksdb_DBOptions_copyDBOptions(
JNIEnv*, jclass, jlong jhandle) {
auto new_opt = new ROCKSDB_NAMESPACE::DBOptions(
*(reinterpret_cast<ROCKSDB_NAMESPACE::DBOptions*>(jhandle)));
return reinterpret_cast<jlong>(new_opt);
return GET_CPLUSPLUS_POINTER(new_opt);
}
/*
@ -5657,7 +5658,7 @@ jlong Java_org_rocksdb_DBOptions_newDBOptionsFromOptions(
JNIEnv*, jclass, jlong joptions_handle) {
auto new_opt = new ROCKSDB_NAMESPACE::DBOptions(
*reinterpret_cast<ROCKSDB_NAMESPACE::Options*>(joptions_handle));
return reinterpret_cast<jlong>(new_opt);
return GET_CPLUSPLUS_POINTER(new_opt);
}
/*
@ -5684,7 +5685,7 @@ jlong Java_org_rocksdb_DBOptions_getDBOptionsFromProps__JLjava_lang_String_2(
// Check if DBOptions creation was possible.
jlong ret_value = 0;
if (status.ok()) {
ret_value = reinterpret_cast<jlong>(db_options);
ret_value = GET_CPLUSPLUS_POINTER(db_options);
} else {
// if operation failed the DBOptions need to be deleted
// again to prevent a memory leak.
@ -5715,7 +5716,7 @@ jlong Java_org_rocksdb_DBOptions_getDBOptionsFromProps__Ljava_lang_String_2(
// Check if DBOptions creation was possible.
jlong ret_value = 0;
if (status.ok()) {
ret_value = reinterpret_cast<jlong>(db_options);
ret_value = GET_CPLUSPLUS_POINTER(db_options);
} else {
// if operation failed the DBOptions need to be deleted
// again to prevent a memory leak.
@ -6014,7 +6015,7 @@ jlong Java_org_rocksdb_DBOptions_statistics(
} else {
std::shared_ptr<ROCKSDB_NAMESPACE::Statistics>* pSptr =
new std::shared_ptr<ROCKSDB_NAMESPACE::Statistics>(sptr);
return reinterpret_cast<jlong>(pSptr);
return GET_CPLUSPLUS_POINTER(pSptr);
}
}
@ -7664,7 +7665,7 @@ jlong Java_org_rocksdb_DBOptions_bgerrorResumeRetryInterval(JNIEnv*, jclass,
jlong Java_org_rocksdb_WriteOptions_newWriteOptions(
JNIEnv*, jclass) {
auto* op = new ROCKSDB_NAMESPACE::WriteOptions();
return reinterpret_cast<jlong>(op);
return GET_CPLUSPLUS_POINTER(op);
}
/*
@ -7676,7 +7677,7 @@ jlong Java_org_rocksdb_WriteOptions_copyWriteOptions(
JNIEnv*, jclass, jlong jhandle) {
auto new_opt = new ROCKSDB_NAMESPACE::WriteOptions(
*(reinterpret_cast<ROCKSDB_NAMESPACE::WriteOptions*>(jhandle)));
return reinterpret_cast<jlong>(new_opt);
return GET_CPLUSPLUS_POINTER(new_opt);
}
/*
@ -7835,7 +7836,7 @@ void Java_org_rocksdb_WriteOptions_setMemtableInsertHintPerBatch(
jlong Java_org_rocksdb_ReadOptions_newReadOptions__(
JNIEnv*, jclass) {
auto* read_options = new ROCKSDB_NAMESPACE::ReadOptions();
return reinterpret_cast<jlong>(read_options);
return GET_CPLUSPLUS_POINTER(read_options);
}
/*
@ -7847,7 +7848,7 @@ jlong Java_org_rocksdb_ReadOptions_newReadOptions__ZZ(
JNIEnv*, jclass, jboolean jverify_checksums, jboolean jfill_cache) {
auto* read_options = new ROCKSDB_NAMESPACE::ReadOptions(
static_cast<bool>(jverify_checksums), static_cast<bool>(jfill_cache));
return reinterpret_cast<jlong>(read_options);
return GET_CPLUSPLUS_POINTER(read_options);
}
/*
@ -7859,7 +7860,7 @@ jlong Java_org_rocksdb_ReadOptions_copyReadOptions(
JNIEnv*, jclass, jlong jhandle) {
auto new_opt = new ROCKSDB_NAMESPACE::ReadOptions(
*(reinterpret_cast<ROCKSDB_NAMESPACE::ReadOptions*>(jhandle)));
return reinterpret_cast<jlong>(new_opt);
return GET_CPLUSPLUS_POINTER(new_opt);
}
/*
@ -8136,7 +8137,7 @@ jlong Java_org_rocksdb_ReadOptions_snapshot(
JNIEnv*, jobject, jlong jhandle) {
auto& snapshot =
reinterpret_cast<ROCKSDB_NAMESPACE::ReadOptions*>(jhandle)->snapshot;
return reinterpret_cast<jlong>(snapshot);
return GET_CPLUSPLUS_POINTER(snapshot);
}
/*
@ -8183,7 +8184,7 @@ jlong Java_org_rocksdb_ReadOptions_iterateUpperBound(
auto& upper_bound_slice_handle =
reinterpret_cast<ROCKSDB_NAMESPACE::ReadOptions*>(jhandle)
->iterate_upper_bound;
return reinterpret_cast<jlong>(upper_bound_slice_handle);
return GET_CPLUSPLUS_POINTER(upper_bound_slice_handle);
}
/*
@ -8208,7 +8209,7 @@ jlong Java_org_rocksdb_ReadOptions_iterateLowerBound(
auto& lower_bound_slice_handle =
reinterpret_cast<ROCKSDB_NAMESPACE::ReadOptions*>(jhandle)
->iterate_lower_bound;
return reinterpret_cast<jlong>(lower_bound_slice_handle);
return GET_CPLUSPLUS_POINTER(lower_bound_slice_handle);
}
/*
@ -8371,7 +8372,7 @@ void Java_org_rocksdb_ReadOptions_setValueSizeSoftLimit(
jlong Java_org_rocksdb_ComparatorOptions_newComparatorOptions(
JNIEnv*, jclass) {
auto* comparator_opt = new ROCKSDB_NAMESPACE::ComparatorJniCallbackOptions();
return reinterpret_cast<jlong>(comparator_opt);
return GET_CPLUSPLUS_POINTER(comparator_opt);
}
/*
@ -8477,7 +8478,7 @@ void Java_org_rocksdb_ComparatorOptions_disposeInternal(
jlong Java_org_rocksdb_FlushOptions_newFlushOptions(
JNIEnv*, jclass) {
auto* flush_opt = new ROCKSDB_NAMESPACE::FlushOptions();
return reinterpret_cast<jlong>(flush_opt);
return GET_CPLUSPLUS_POINTER(flush_opt);
}
/*

@ -6,13 +6,16 @@
// This file implements the "bridge" between Java and C++ for
// ROCKSDB_NAMESPACE::PersistentCache.
#include "rocksdb/persistent_cache.h"
#include <jni.h>
#include <string>
#include "include/org_rocksdb_PersistentCache.h"
#include "rocksdb/persistent_cache.h"
#include "loggerjnicallback.h"
#include "portal.h"
#include "rocksjni/cplusplus_to_java_convert.h"
/*
* Class: org_rocksdb_PersistentCache
@ -40,7 +43,7 @@ jlong Java_org_rocksdb_PersistentCache_newPersistentCache(
if (!s.ok()) {
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s);
}
return reinterpret_cast<jlong>(cache);
return GET_CPLUSPLUS_POINTER(cache);
}
/*

@ -36,6 +36,7 @@
#include "rocksdb/utilities/write_batch_with_index.h"
#include "rocksjni/compaction_filter_factory_jnicallback.h"
#include "rocksjni/comparatorjnicallback.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/event_listener_jnicallback.h"
#include "rocksjni/loggerjnicallback.h"
#include "rocksjni/table_filter_jnicallback.h"
@ -120,7 +121,8 @@ template<class PTR, class DERIVED> class NativeRocksMutableObject
return true; // signal exception
}
env->CallVoidMethod(jobj, mid, reinterpret_cast<jlong>(ptr), java_owns_handle);
env->CallVoidMethod(jobj, mid, GET_CPLUSPLUS_POINTER(ptr),
java_owns_handle);
if(env->ExceptionCheck()) {
return true; // signal exception
}
@ -2243,9 +2245,9 @@ class JniUtil {
jboolean *has_exception) {
const jsize len = static_cast<jsize>(pointers.size());
std::unique_ptr<jlong[]> results(new jlong[len]);
std::transform(pointers.begin(), pointers.end(), results.get(), [](T* pointer) -> jlong {
return reinterpret_cast<jlong>(pointer);
});
std::transform(
pointers.begin(), pointers.end(), results.get(),
[](T* pointer) -> jlong { return GET_CPLUSPLUS_POINTER(pointer); });
jlongArray jpointers = env->NewLongArray(len);
if (jpointers == nullptr) {
@ -2785,7 +2787,7 @@ class ColumnFamilyOptionsJni
return nullptr;
}
jobject jcfd = env->NewObject(jclazz, mid, reinterpret_cast<jlong>(cfo));
jobject jcfd = env->NewObject(jclazz, mid, GET_CPLUSPLUS_POINTER(cfo));
if (env->ExceptionCheck()) {
return nullptr;
}
@ -2871,7 +2873,7 @@ class WriteBatchJni
return nullptr;
}
jobject jwb = env->NewObject(jclazz, mid, reinterpret_cast<jlong>(wb));
jobject jwb = env->NewObject(jclazz, mid, GET_CPLUSPLUS_POINTER(wb));
if (env->ExceptionCheck()) {
return nullptr;
}
@ -3496,7 +3498,7 @@ class ColumnFamilyHandleJni
assert(jclazz != nullptr);
static jmethodID ctor = getConstructorMethodId(env, jclazz);
assert(ctor != nullptr);
return env->NewObject(jclazz, ctor, reinterpret_cast<jlong>(info));
return env->NewObject(jclazz, ctor, GET_CPLUSPLUS_POINTER(info));
}
static jmethodID getConstructorMethodId(JNIEnv* env, jclass clazz) {
@ -8327,7 +8329,7 @@ class CompactionJobInfoJni : public JavaClass {
static jmethodID ctor = getConstructorMethodId(env, jclazz);
assert(ctor != nullptr);
return env->NewObject(jclazz, ctor,
reinterpret_cast<jlong>(compaction_job_info));
GET_CPLUSPLUS_POINTER(compaction_job_info));
}
static jclass getJClass(JNIEnv* env) {

@ -7,6 +7,7 @@
#include "include/org_rocksdb_RateLimiter.h"
#include "rocksdb/rate_limiter.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
/*
@ -27,7 +28,7 @@ jlong Java_org_rocksdb_RateLimiter_newRateLimiterHandle(
static_cast<int64_t>(jrefill_period_micros),
static_cast<int32_t>(jfairness), rate_limiter_mode, jauto_tune));
return reinterpret_cast<jlong>(sptr_rate_limiter);
return GET_CPLUSPLUS_POINTER(sptr_rate_limiter);
}
/*

@ -6,6 +6,7 @@
#include <jni.h>
#include "include/org_rocksdb_RemoveEmptyValueCompactionFilter.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "utilities/compaction_filters/remove_emptyvalue_compactionfilter.h"
/*
@ -19,5 +20,5 @@ jlong Java_org_rocksdb_RemoveEmptyValueCompactionFilter_createNewRemoveEmptyValu
new ROCKSDB_NAMESPACE::RemoveEmptyValueCompactionFilter();
// set the native handle to our native compaction filter
return reinterpret_cast<jlong>(compaction_filter);
return GET_CPLUSPLUS_POINTER(compaction_filter);
}

@ -15,6 +15,7 @@
#include "include/org_rocksdb_RestoreOptions.h"
#include "rocksdb/utilities/backup_engine.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
/*
* Class: org_rocksdb_RestoreOptions
@ -24,7 +25,7 @@
jlong Java_org_rocksdb_RestoreOptions_newRestoreOptions(
JNIEnv* /*env*/, jclass /*jcls*/, jboolean keep_log_files) {
auto* ropt = new ROCKSDB_NAMESPACE::RestoreOptions(keep_log_files);
return reinterpret_cast<jlong>(ropt);
return GET_CPLUSPLUS_POINTER(ropt);
}
/*

@ -24,6 +24,7 @@
#include "rocksdb/options.h"
#include "rocksdb/types.h"
#include "rocksdb/version.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
#ifdef min
@ -48,7 +49,7 @@ jlong rocksdb_open_helper(JNIEnv* env, jlong jopt_handle, jstring jdb_path,
env->ReleaseStringUTFChars(jdb_path, db_path);
if (s.ok()) {
return reinterpret_cast<jlong>(db);
return GET_CPLUSPLUS_POINTER(db);
} else {
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s);
return 0;
@ -152,9 +153,9 @@ jlongArray rocksdb_open_helper(
const jsize resultsLen = 1 + len_cols; // db handle + column family handles
std::unique_ptr<jlong[]> results =
std::unique_ptr<jlong[]>(new jlong[resultsLen]);
results[0] = reinterpret_cast<jlong>(db);
results[0] = GET_CPLUSPLUS_POINTER(db);
for (int i = 1; i <= len_cols; i++) {
results[i] = reinterpret_cast<jlong>(cf_handles[i - 1]);
results[i] = GET_CPLUSPLUS_POINTER(cf_handles[i - 1]);
}
jlongArray jresults = env->NewLongArray(resultsLen);
@ -364,7 +365,7 @@ jlong Java_org_rocksdb_RocksDB_createColumnFamily(
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s);
return 0;
}
return reinterpret_cast<jlong>(cf_handle);
return GET_CPLUSPLUS_POINTER(cf_handle);
}
/*
@ -1321,7 +1322,7 @@ jlong rocksdb_iterator_helper(
} else {
iterator = db->NewIterator(read_options);
}
return reinterpret_cast<jlong>(iterator);
return GET_CPLUSPLUS_POINTER(iterator);
}
/*
@ -2524,7 +2525,7 @@ jlong Java_org_rocksdb_RocksDB_getSnapshot(
JNIEnv*, jobject, jlong db_handle) {
auto* db = reinterpret_cast<ROCKSDB_NAMESPACE::DB*>(db_handle);
const ROCKSDB_NAMESPACE::Snapshot* snapshot = db->GetSnapshot();
return reinterpret_cast<jlong>(snapshot);
return GET_CPLUSPLUS_POINTER(snapshot);
}
/*
@ -3239,7 +3240,7 @@ jstring Java_org_rocksdb_RocksDB_getName(
jlong Java_org_rocksdb_RocksDB_getEnv(
JNIEnv*, jobject, jlong jdb_handle) {
auto* db = reinterpret_cast<ROCKSDB_NAMESPACE::DB*>(jdb_handle);
return reinterpret_cast<jlong>(db->GetEnv());
return GET_CPLUSPLUS_POINTER(db->GetEnv());
}
/*
@ -3424,7 +3425,7 @@ jlong Java_org_rocksdb_RocksDB_getUpdatesSince(
std::unique_ptr<ROCKSDB_NAMESPACE::TransactionLogIterator> iter;
ROCKSDB_NAMESPACE::Status s = db->GetUpdatesSince(sequence_number, &iter);
if (s.ok()) {
return reinterpret_cast<jlong>(iter.release());
return GET_CPLUSPLUS_POINTER(iter.release());
}
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s);
@ -3568,7 +3569,7 @@ jlong Java_org_rocksdb_RocksDB_getDefaultColumnFamily(
JNIEnv*, jobject, jlong jdb_handle) {
auto* db_handle = reinterpret_cast<ROCKSDB_NAMESPACE::DB*>(jdb_handle);
auto* cf_handle = db_handle->DefaultColumnFamily();
return reinterpret_cast<jlong>(cf_handle);
return GET_CPLUSPLUS_POINTER(cf_handle);
}
/*
@ -3728,8 +3729,8 @@ jlongArray Java_org_rocksdb_RocksDB_suggestCompactRange(
}
jlong slice_handles[2];
slice_handles[0] = reinterpret_cast<jlong>(begin);
slice_handles[1] = reinterpret_cast<jlong>(end);
slice_handles[0] = GET_CPLUSPLUS_POINTER(begin);
slice_handles[1] = GET_CPLUSPLUS_POINTER(end);
env->SetLongArrayRegion(jslice_handles, 0, 2, slice_handles);
if (env->ExceptionCheck()) {
// exception thrown: ArrayIndexOutOfBoundsException

@ -6,15 +6,18 @@
// This file implements the "bridge" between Java and C++ for
// ROCKSDB_NAMESPACE::Slice.
#include "rocksdb/slice.h"
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include "include/org_rocksdb_AbstractSlice.h"
#include "include/org_rocksdb_DirectSlice.h"
#include "include/org_rocksdb_Slice.h"
#include "rocksdb/slice.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
// <editor-fold desc="org.rocksdb.AbstractSlice>
@ -44,7 +47,7 @@ jlong Java_org_rocksdb_AbstractSlice_createNewSliceFromString(JNIEnv* env,
env->ReleaseStringUTFChars(jstr, str);
const auto* slice = new ROCKSDB_NAMESPACE::Slice(buf);
return reinterpret_cast<jlong>(slice);
return GET_CPLUSPLUS_POINTER(slice);
}
/*
@ -144,7 +147,7 @@ jlong Java_org_rocksdb_Slice_createNewSlice0(JNIEnv* env, jclass /*jcls*/,
}
const auto* slice = new ROCKSDB_NAMESPACE::Slice((const char*)buf, len);
return reinterpret_cast<jlong>(slice);
return GET_CPLUSPLUS_POINTER(slice);
}
/*
@ -171,7 +174,7 @@ jlong Java_org_rocksdb_Slice_createNewSlice1(JNIEnv* env, jclass /*jcls*/,
env->ReleaseByteArrayElements(data, ptrData, JNI_ABORT);
return reinterpret_cast<jlong>(slice);
return GET_CPLUSPLUS_POINTER(slice);
}
/*
@ -278,7 +281,7 @@ jlong Java_org_rocksdb_DirectSlice_createNewDirectSlice0(JNIEnv* env,
const auto* ptrData = reinterpret_cast<char*>(data_addr);
const auto* slice = new ROCKSDB_NAMESPACE::Slice(ptrData, length);
return reinterpret_cast<jlong>(slice);
return GET_CPLUSPLUS_POINTER(slice);
}
/*
@ -301,7 +304,7 @@ jlong Java_org_rocksdb_DirectSlice_createNewDirectSlice1(JNIEnv* env,
const auto* ptrData = reinterpret_cast<char*>(data_addr);
const auto* slice = new ROCKSDB_NAMESPACE::Slice(ptrData);
return reinterpret_cast<jlong>(slice);
return GET_CPLUSPLUS_POINTER(slice);
}
/*

@ -7,11 +7,14 @@
// calling C++ ROCKSDB_NAMESPACE::SstFileManager methods
// from Java side.
#include "rocksdb/sst_file_manager.h"
#include <jni.h>
#include <memory>
#include "include/org_rocksdb_SstFileManager.h"
#include "rocksdb/sst_file_manager.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
/*
@ -49,7 +52,7 @@ jlong Java_org_rocksdb_SstFileManager_newSstFileManager(
auto* sptr_sst_file_manager =
new std::shared_ptr<ROCKSDB_NAMESPACE::SstFileManager>(sst_file_manager);
return reinterpret_cast<jlong>(sptr_sst_file_manager);
return GET_CPLUSPLUS_POINTER(sptr_sst_file_manager);
}
/*

@ -8,6 +8,7 @@
// from Java side.
#include <jni.h>
#include <string>
#include "include/org_rocksdb_SstFileReader.h"
@ -15,6 +16,7 @@
#include "rocksdb/env.h"
#include "rocksdb/options.h"
#include "rocksdb/sst_file_reader.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
/*
@ -29,7 +31,7 @@ jlong Java_org_rocksdb_SstFileReader_newSstFileReader(JNIEnv * /*env*/,
reinterpret_cast<const ROCKSDB_NAMESPACE::Options *>(joptions);
ROCKSDB_NAMESPACE::SstFileReader *sst_file_reader =
new ROCKSDB_NAMESPACE::SstFileReader(*options);
return reinterpret_cast<jlong>(sst_file_reader);
return GET_CPLUSPLUS_POINTER(sst_file_reader);
}
/*
@ -67,7 +69,7 @@ jlong Java_org_rocksdb_SstFileReader_newIterator(JNIEnv * /*env*/,
reinterpret_cast<ROCKSDB_NAMESPACE::SstFileReader *>(jhandle);
auto *read_options =
reinterpret_cast<ROCKSDB_NAMESPACE::ReadOptions *>(jread_options_handle);
return reinterpret_cast<jlong>(sst_file_reader->NewIterator(*read_options));
return GET_CPLUSPLUS_POINTER(sst_file_reader->NewIterator(*read_options));
}
/*

@ -8,6 +8,7 @@
// from Java side.
#include <jni.h>
#include <string>
#include "include/org_rocksdb_SstFileWriter.h"
@ -15,6 +16,7 @@
#include "rocksdb/env.h"
#include "rocksdb/options.h"
#include "rocksdb/sst_file_writer.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
/*
@ -45,7 +47,7 @@ jlong Java_org_rocksdb_SstFileWriter_newSstFileWriter__JJJB(
reinterpret_cast<const ROCKSDB_NAMESPACE::Options *>(joptions);
ROCKSDB_NAMESPACE::SstFileWriter *sst_file_writer =
new ROCKSDB_NAMESPACE::SstFileWriter(*env_options, *options, comparator);
return reinterpret_cast<jlong>(sst_file_writer);
return GET_CPLUSPLUS_POINTER(sst_file_writer);
}
/*
@ -63,7 +65,7 @@ jlong Java_org_rocksdb_SstFileWriter_newSstFileWriter__JJ(JNIEnv * /*env*/,
reinterpret_cast<const ROCKSDB_NAMESPACE::Options *>(joptions);
ROCKSDB_NAMESPACE::SstFileWriter *sst_file_writer =
new ROCKSDB_NAMESPACE::SstFileWriter(*env_options, *options);
return reinterpret_cast<jlong>(sst_file_writer);
return GET_CPLUSPLUS_POINTER(sst_file_writer);
}
/*

@ -15,6 +15,7 @@
#include "include/org_rocksdb_SstPartitionerFixedPrefixFactory.h"
#include "rocksdb/sst_file_manager.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
/*
@ -26,7 +27,7 @@ jlong Java_org_rocksdb_SstPartitionerFixedPrefixFactory_newSstPartitionerFixedPr
JNIEnv*, jclass, jlong prefix_len) {
auto* ptr = new std::shared_ptr<ROCKSDB_NAMESPACE::SstPartitionerFactory>(
ROCKSDB_NAMESPACE::NewSstPartitionerFixedPrefixFactory(prefix_len));
return reinterpret_cast<jlong>(ptr);
return GET_CPLUSPLUS_POINTER(ptr);
}
/*

@ -6,12 +6,15 @@
// This file implements the "bridge" between Java and C++ and enables
// calling c++ ROCKSDB_NAMESPACE::Statistics methods from Java side.
#include "rocksdb/statistics.h"
#include <jni.h>
#include <memory>
#include <set>
#include "include/org_rocksdb_Statistics.h"
#include "rocksdb/statistics.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
#include "rocksjni/statisticsjni.h"
@ -94,7 +97,7 @@ jlong Java_org_rocksdb_Statistics_newStatistics___3BJ(
new ROCKSDB_NAMESPACE::StatisticsJni(sptr_other_statistics,
histograms));
return reinterpret_cast<jlong>(pSptr_statistics);
return GET_CPLUSPLUS_POINTER(pSptr_statistics);
}
/*

@ -7,12 +7,15 @@
// ROCKSDB_NAMESPACE::Options.
#include "rocksdb/table.h"
#include <jni.h>
#include "include/org_rocksdb_BlockBasedTableConfig.h"
#include "include/org_rocksdb_PlainTableConfig.h"
#include "portal.h"
#include "rocksdb/cache.h"
#include "rocksdb/filter_policy.h"
#include "rocksjni/cplusplus_to_java_convert.h"
/*
* Class: org_rocksdb_PlainTableConfig
@ -35,7 +38,7 @@ jlong Java_org_rocksdb_PlainTableConfig_newTableFactoryHandle(
static_cast<ROCKSDB_NAMESPACE::EncodingType>(jencoding_type);
options.full_scan_mode = jfull_scan_mode;
options.store_index_in_file = jstore_index_in_file;
return reinterpret_cast<jlong>(
return GET_CPLUSPLUS_POINTER(
ROCKSDB_NAMESPACE::NewPlainTableFactory(options));
}
@ -150,6 +153,6 @@ jlong Java_org_rocksdb_BlockBasedTableConfig_newTableFactoryHandle(
ROCKSDB_NAMESPACE::IndexShorteningModeJni::toCppIndexShorteningMode(
jindex_shortening);
return reinterpret_cast<jlong>(
return GET_CPLUSPLUS_POINTER(
ROCKSDB_NAMESPACE::NewBlockBasedTableFactory(options));
}

@ -7,9 +7,11 @@
// org.rocksdb.AbstractTableFilter.
#include <jni.h>
#include <memory>
#include "include/org_rocksdb_AbstractTableFilter.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/table_filter_jnicallback.h"
/*
@ -21,5 +23,5 @@ jlong Java_org_rocksdb_AbstractTableFilter_createNewTableFilter(
JNIEnv* env, jobject jtable_filter) {
auto* table_filter_jnicallback =
new ROCKSDB_NAMESPACE::TableFilterJniCallback(env, jtable_filter);
return reinterpret_cast<jlong>(table_filter_jnicallback);
return GET_CPLUSPLUS_POINTER(table_filter_jnicallback);
}

@ -9,6 +9,7 @@
#include <jni.h>
#include "include/org_rocksdb_AbstractTraceWriter.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/trace_writer_jnicallback.h"
/*
@ -19,5 +20,5 @@
jlong Java_org_rocksdb_AbstractTraceWriter_createNewTraceWriter(
JNIEnv* env, jobject jobj) {
auto* trace_writer = new ROCKSDB_NAMESPACE::TraceWriterJniCallback(env, jobj);
return reinterpret_cast<jlong>(trace_writer);
return GET_CPLUSPLUS_POINTER(trace_writer);
}

@ -6,12 +6,14 @@
// This file implements the "bridge" between Java and C++
// for ROCKSDB_NAMESPACE::Transaction.
#include "rocksdb/utilities/transaction.h"
#include <jni.h>
#include <functional>
#include "include/org_rocksdb_Transaction.h"
#include "rocksdb/utilities/transaction.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
#if defined(_MSC_VER)
@ -67,7 +69,7 @@ jlong Java_org_rocksdb_Transaction_getSnapshot(JNIEnv* /*env*/,
jlong jhandle) {
auto* txn = reinterpret_cast<ROCKSDB_NAMESPACE::Transaction*>(jhandle);
const ROCKSDB_NAMESPACE::Snapshot* snapshot = txn->GetSnapshot();
return reinterpret_cast<jlong>(snapshot);
return GET_CPLUSPLUS_POINTER(snapshot);
}
/*
@ -532,7 +534,7 @@ jlong Java_org_rocksdb_Transaction_getIterator__JJ(JNIEnv* /*env*/,
auto* txn = reinterpret_cast<ROCKSDB_NAMESPACE::Transaction*>(jhandle);
auto* read_options =
reinterpret_cast<ROCKSDB_NAMESPACE::ReadOptions*>(jread_options_handle);
return reinterpret_cast<jlong>(txn->GetIterator(*read_options));
return GET_CPLUSPLUS_POINTER(txn->GetIterator(*read_options));
}
/*
@ -549,7 +551,7 @@ jlong Java_org_rocksdb_Transaction_getIterator__JJJ(
auto* column_family_handle =
reinterpret_cast<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>(
jcolumn_family_handle);
return reinterpret_cast<jlong>(
return GET_CPLUSPLUS_POINTER(
txn->GetIterator(*read_options, column_family_handle));
}
@ -1379,7 +1381,7 @@ jlong Java_org_rocksdb_Transaction_getWriteBatch(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* txn = reinterpret_cast<ROCKSDB_NAMESPACE::Transaction*>(jhandle);
return reinterpret_cast<jlong>(txn->GetWriteBatch());
return GET_CPLUSPLUS_POINTER(txn->GetWriteBatch());
}
/*
@ -1404,7 +1406,7 @@ jlong Java_org_rocksdb_Transaction_getWriteOptions(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* txn = reinterpret_cast<ROCKSDB_NAMESPACE::Transaction*>(jhandle);
return reinterpret_cast<jlong>(txn->GetWriteOptions());
return GET_CPLUSPLUS_POINTER(txn->GetWriteOptions());
}
/*
@ -1496,7 +1498,7 @@ jlong Java_org_rocksdb_Transaction_getCommitTimeWriteBatch(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* txn = reinterpret_cast<ROCKSDB_NAMESPACE::Transaction*>(jhandle);
return reinterpret_cast<jlong>(txn->GetCommitTimeWriteBatch());
return GET_CPLUSPLUS_POINTER(txn->GetCommitTimeWriteBatch());
}
/*

@ -6,17 +6,18 @@
// This file implements the "bridge" between Java and C++
// for ROCKSDB_NAMESPACE::TransactionDB.
#include "rocksdb/utilities/transaction_db.h"
#include <jni.h>
#include <functional>
#include <memory>
#include <utility>
#include "include/org_rocksdb_TransactionDB.h"
#include "rocksdb/options.h"
#include "rocksdb/utilities/transaction.h"
#include "rocksdb/utilities/transaction_db.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
/*
@ -43,7 +44,7 @@ jlong Java_org_rocksdb_TransactionDB_open__JJLjava_lang_String_2(
env->ReleaseStringUTFChars(jdb_path, db_path);
if (s.ok()) {
return reinterpret_cast<jlong>(tdb);
return GET_CPLUSPLUS_POINTER(tdb);
} else {
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s);
return 0;
@ -132,9 +133,9 @@ jlongArray Java_org_rocksdb_TransactionDB_open__JJLjava_lang_String_2_3_3B_3J(
const jsize resultsLen = 1 + len_cols; // db handle + column family handles
std::unique_ptr<jlong[]> results =
std::unique_ptr<jlong[]>(new jlong[resultsLen]);
results[0] = reinterpret_cast<jlong>(tdb);
results[0] = GET_CPLUSPLUS_POINTER(tdb);
for (int i = 1; i <= len_cols; i++) {
results[i] = reinterpret_cast<jlong>(handles[i - 1]);
results[i] = GET_CPLUSPLUS_POINTER(handles[i - 1]);
}
jlongArray jresults = env->NewLongArray(resultsLen);
@ -192,7 +193,7 @@ jlong Java_org_rocksdb_TransactionDB_beginTransaction__JJ(
reinterpret_cast<ROCKSDB_NAMESPACE::WriteOptions*>(jwrite_options_handle);
ROCKSDB_NAMESPACE::Transaction* txn =
txn_db->BeginTransaction(*write_options);
return reinterpret_cast<jlong>(txn);
return GET_CPLUSPLUS_POINTER(txn);
}
/*
@ -210,7 +211,7 @@ jlong Java_org_rocksdb_TransactionDB_beginTransaction__JJJ(
jtxn_options_handle);
ROCKSDB_NAMESPACE::Transaction* txn =
txn_db->BeginTransaction(*write_options, *txn_options);
return reinterpret_cast<jlong>(txn);
return GET_CPLUSPLUS_POINTER(txn);
}
/*
@ -235,7 +236,7 @@ jlong Java_org_rocksdb_TransactionDB_beginTransaction_1withOld__JJJ(
// when providing an old_txn
assert(txn == old_txn);
return reinterpret_cast<jlong>(txn);
return GET_CPLUSPLUS_POINTER(txn);
}
/*
@ -261,7 +262,7 @@ jlong Java_org_rocksdb_TransactionDB_beginTransaction_1withOld__JJJJ(
// when providing an old_txn
assert(txn == old_txn);
return reinterpret_cast<jlong>(txn);
return GET_CPLUSPLUS_POINTER(txn);
}
/*
@ -279,7 +280,7 @@ jlong Java_org_rocksdb_TransactionDB_getTransactionByName(
}
ROCKSDB_NAMESPACE::Transaction* txn = txn_db->GetTransactionByName(name);
env->ReleaseStringUTFChars(jname, name);
return reinterpret_cast<jlong>(txn);
return GET_CPLUSPLUS_POINTER(txn);
}
/*
@ -299,7 +300,7 @@ jlongArray Java_org_rocksdb_TransactionDB_getAllPreparedTransactions(
const jsize len = static_cast<jsize>(size);
std::vector<jlong> tmp(len);
for (jsize i = 0; i < len; ++i) {
tmp[i] = reinterpret_cast<jlong>(txns[i]);
tmp[i] = GET_CPLUSPLUS_POINTER(txns[i]);
}
jlongArray jtxns = env->NewLongArray(len);

@ -9,9 +9,8 @@
#include <jni.h>
#include "include/org_rocksdb_TransactionDBOptions.h"
#include "rocksdb/utilities/transaction_db.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
/*
@ -23,7 +22,7 @@ jlong Java_org_rocksdb_TransactionDBOptions_newTransactionDBOptions(
JNIEnv* /*env*/, jclass /*jcls*/) {
ROCKSDB_NAMESPACE::TransactionDBOptions* opts =
new ROCKSDB_NAMESPACE::TransactionDBOptions();
return reinterpret_cast<jlong>(opts);
return GET_CPLUSPLUS_POINTER(opts);
}
/*

@ -9,6 +9,7 @@
#include <jni.h>
#include "include/org_rocksdb_AbstractTransactionNotifier.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/transaction_notifier_jnicallback.h"
/*
@ -23,7 +24,7 @@ jlong Java_org_rocksdb_AbstractTransactionNotifier_createNewTransactionNotifier(
auto* sptr_transaction_notifier =
new std::shared_ptr<ROCKSDB_NAMESPACE::TransactionNotifierJniCallback>(
transaction_notifier);
return reinterpret_cast<jlong>(sptr_transaction_notifier);
return GET_CPLUSPLUS_POINTER(sptr_transaction_notifier);
}
/*

@ -7,6 +7,8 @@
// ROCKSDB_NAMESPACE::TransactionNotifier.
#include "rocksjni/transaction_notifier_jnicallback.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
namespace ROCKSDB_NAMESPACE {
@ -24,8 +26,8 @@ void TransactionNotifierJniCallback::SnapshotCreated(
JNIEnv* env = getJniEnv(&attached_thread);
assert(env != nullptr);
env->CallVoidMethod(m_jcallback_obj,
m_jsnapshot_created_methodID, reinterpret_cast<jlong>(newSnapshot));
env->CallVoidMethod(m_jcallback_obj, m_jsnapshot_created_methodID,
GET_CPLUSPLUS_POINTER(newSnapshot));
if(env->ExceptionCheck()) {
// exception thrown from CallVoidMethod

@ -9,8 +9,8 @@
#include <jni.h>
#include "include/org_rocksdb_TransactionOptions.h"
#include "rocksdb/utilities/transaction_db.h"
#include "rocksjni/cplusplus_to_java_convert.h"
/*
* Class: org_rocksdb_TransactionOptions
@ -20,7 +20,7 @@
jlong Java_org_rocksdb_TransactionOptions_newTransactionOptions(
JNIEnv* /*env*/, jclass /*jcls*/) {
auto* opts = new ROCKSDB_NAMESPACE::TransactionOptions();
return reinterpret_cast<jlong>(opts);
return GET_CPLUSPLUS_POINTER(opts);
}
/*

@ -10,12 +10,14 @@
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <memory>
#include <string>
#include <vector>
#include "include/org_rocksdb_TtlDB.h"
#include "rocksdb/utilities/db_ttl.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
/*
@ -41,7 +43,7 @@ jlong Java_org_rocksdb_TtlDB_open(
// as TTLDB extends RocksDB on the java side, we can reuse
// the RocksDB portal here.
if (s.ok()) {
return reinterpret_cast<jlong>(db);
return GET_CPLUSPLUS_POINTER(db);
} else {
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s);
return 0;
@ -121,9 +123,9 @@ jlongArray Java_org_rocksdb_TtlDB_openCF(
const jsize resultsLen = 1 + len_cols; // db handle + column family handles
std::unique_ptr<jlong[]> results =
std::unique_ptr<jlong[]>(new jlong[resultsLen]);
results[0] = reinterpret_cast<jlong>(db);
results[0] = GET_CPLUSPLUS_POINTER(db);
for (int i = 1; i <= len_cols; i++) {
results[i] = reinterpret_cast<jlong>(handles[i - 1]);
results[i] = GET_CPLUSPLUS_POINTER(handles[i - 1]);
}
jlongArray jresults = env->NewLongArray(resultsLen);
@ -200,7 +202,7 @@ jlong Java_org_rocksdb_TtlDB_createColumnFamilyWithTtl(
env->ReleaseByteArrayElements(jcolumn_name, cfname, JNI_ABORT);
if (s.ok()) {
return reinterpret_cast<jlong>(handle);
return GET_CPLUSPLUS_POINTER(handle);
}
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s);
return 0;

@ -9,6 +9,7 @@
#include <jni.h>
#include "include/org_rocksdb_AbstractWalFilter.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/wal_filter_jnicallback.h"
/*
@ -19,5 +20,5 @@
jlong Java_org_rocksdb_AbstractWalFilter_createNewWalFilter(
JNIEnv* env, jobject jobj) {
auto* wal_filter = new ROCKSDB_NAMESPACE::WalFilterJniCallback(env, jobj);
return reinterpret_cast<jlong>(wal_filter);
return GET_CPLUSPLUS_POINTER(wal_filter);
}

@ -7,6 +7,8 @@
// ROCKSDB_NAMESPACE::WalFilter.
#include "rocksjni/wal_filter_jnicallback.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
namespace ROCKSDB_NAMESPACE {
@ -109,12 +111,10 @@ void WalFilterJniCallback::ColumnFamilyLogNumberMap(
return WalFilter::WalProcessingOption::kCorruptedRecord;
}
jshort jlog_record_found_result = env->CallShortMethod(m_jcallback_obj,
m_log_record_found_proxy_mid,
static_cast<jlong>(log_number),
jlog_file_name,
reinterpret_cast<jlong>(&batch),
reinterpret_cast<jlong>(new_batch));
jshort jlog_record_found_result = env->CallShortMethod(
m_jcallback_obj, m_log_record_found_proxy_mid,
static_cast<jlong>(log_number), jlog_file_name,
GET_CPLUSPLUS_POINTER(&batch), GET_CPLUSPLUS_POINTER(new_batch));
env->DeleteLocalRef(jlog_file_name);

@ -5,6 +5,8 @@
//
// This file implements the "bridge" between Java and C++ and enables
// calling c++ ROCKSDB_NAMESPACE::WriteBatch methods from Java side.
#include "rocksdb/write_batch.h"
#include <memory>
#include "db/memtable.h"
@ -16,8 +18,8 @@
#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/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
#include "rocksjni/writebatchhandlerjnicallback.h"
#include "table/scoped_arena_iterator.h"
@ -32,7 +34,7 @@ jlong Java_org_rocksdb_WriteBatch_newWriteBatch__I(JNIEnv* /*env*/,
jint jreserved_bytes) {
auto* wb =
new ROCKSDB_NAMESPACE::WriteBatch(static_cast<size_t>(jreserved_bytes));
return reinterpret_cast<jlong>(wb);
return GET_CPLUSPLUS_POINTER(wb);
}
/*
@ -55,7 +57,7 @@ jlong Java_org_rocksdb_WriteBatch_newWriteBatch___3BI(JNIEnv* env,
}
auto* wb = new ROCKSDB_NAMESPACE::WriteBatch(serialized);
return reinterpret_cast<jlong>(wb);
return GET_CPLUSPLUS_POINTER(wb);
}
/*
@ -670,5 +672,5 @@ void Java_org_rocksdb_WriteBatch_disposeInternal(JNIEnv* /*env*/,
jlong Java_org_rocksdb_WriteBatch_00024Handler_createNewHandler0(JNIEnv* env,
jobject jobj) {
auto* wbjnic = new ROCKSDB_NAMESPACE::WriteBatchHandlerJniCallback(env, jobj);
return reinterpret_cast<jlong>(wbjnic);
return GET_CPLUSPLUS_POINTER(wbjnic);
}

@ -7,9 +7,11 @@
// calling c++ ROCKSDB_NAMESPACE::WriteBatchWithIndex methods from Java side.
#include "rocksdb/utilities/write_batch_with_index.h"
#include "include/org_rocksdb_WBWIRocksIterator.h"
#include "include/org_rocksdb_WriteBatchWithIndex.h"
#include "rocksdb/comparator.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
/*
@ -20,7 +22,7 @@
jlong Java_org_rocksdb_WriteBatchWithIndex_newWriteBatchWithIndex__(
JNIEnv* /*env*/, jclass /*jcls*/) {
auto* wbwi = new ROCKSDB_NAMESPACE::WriteBatchWithIndex();
return reinterpret_cast<jlong>(wbwi);
return GET_CPLUSPLUS_POINTER(wbwi);
}
/*
@ -33,7 +35,7 @@ jlong Java_org_rocksdb_WriteBatchWithIndex_newWriteBatchWithIndex__Z(
auto* wbwi = new ROCKSDB_NAMESPACE::WriteBatchWithIndex(
ROCKSDB_NAMESPACE::BytewiseComparator(), 0,
static_cast<bool>(joverwrite_key));
return reinterpret_cast<jlong>(wbwi);
return GET_CPLUSPLUS_POINTER(wbwi);
}
/*
@ -62,7 +64,7 @@ jlong Java_org_rocksdb_WriteBatchWithIndex_newWriteBatchWithIndex__JBIZ(
auto* wbwi = new ROCKSDB_NAMESPACE::WriteBatchWithIndex(
fallback_comparator, static_cast<size_t>(jreserved_bytes),
static_cast<bool>(joverwrite_key));
return reinterpret_cast<jlong>(wbwi);
return GET_CPLUSPLUS_POINTER(wbwi);
}
/*
@ -510,7 +512,7 @@ jlong Java_org_rocksdb_WriteBatchWithIndex_iterator0(JNIEnv* /*env*/,
auto* wbwi =
reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(jwbwi_handle);
auto* wbwi_iterator = wbwi->NewIterator();
return reinterpret_cast<jlong>(wbwi_iterator);
return GET_CPLUSPLUS_POINTER(wbwi_iterator);
}
/*
@ -527,7 +529,7 @@ jlong Java_org_rocksdb_WriteBatchWithIndex_iterator1(JNIEnv* /*env*/,
auto* cf_handle =
reinterpret_cast<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>(jcf_handle);
auto* wbwi_iterator = wbwi->NewIterator(cf_handle);
return reinterpret_cast<jlong>(wbwi_iterator);
return GET_CPLUSPLUS_POINTER(wbwi_iterator);
}
/*
@ -551,7 +553,7 @@ jlong Java_org_rocksdb_WriteBatchWithIndex_iteratorWithBase(
jread_opts_handle);
auto* iterator =
wbwi->NewIteratorWithBase(cf_handle, base_iterator, read_opts);
return reinterpret_cast<size_t>(iterator);
return GET_CPLUSPLUS_POINTER(iterator);
}
/*
@ -825,7 +827,7 @@ jlongArray Java_org_rocksdb_WBWIRocksIterator_entry1(JNIEnv* env,
// org.rocksdb.DirectSlice#close
auto* key_slice = new ROCKSDB_NAMESPACE::Slice(we.key.data(), we.key.size());
results[1] = reinterpret_cast<jlong>(key_slice);
results[1] = GET_CPLUSPLUS_POINTER(key_slice);
if (we.type == ROCKSDB_NAMESPACE::kDeleteRecord ||
we.type == ROCKSDB_NAMESPACE::kSingleDeleteRecord ||
we.type == ROCKSDB_NAMESPACE::kLogDataRecord) {
@ -834,7 +836,7 @@ jlongArray Java_org_rocksdb_WBWIRocksIterator_entry1(JNIEnv* env,
} else {
auto* value_slice =
new ROCKSDB_NAMESPACE::Slice(we.value.data(), we.value.size());
results[2] = reinterpret_cast<jlong>(value_slice);
results[2] = GET_CPLUSPLUS_POINTER(value_slice);
}
jlongArray jresults = env->NewLongArray(3);

@ -3,12 +3,13 @@
// COPYING file in the root directory) and Apache 2.0 License
// (found in the LICENSE.Apache file in the root directory).
#include "rocksdb/write_buffer_manager.h"
#include <jni.h>
#include "include/org_rocksdb_WriteBufferManager.h"
#include "rocksdb/cache.h"
#include "rocksdb/write_buffer_manager.h"
#include "rocksjni/cplusplus_to_java_convert.h"
/*
* Class: org_rocksdb_WriteBufferManager
@ -25,7 +26,7 @@ jlong Java_org_rocksdb_WriteBufferManager_newWriteBufferManager(
new std::shared_ptr<ROCKSDB_NAMESPACE::WriteBufferManager>(
std::make_shared<ROCKSDB_NAMESPACE::WriteBufferManager>(
jbuffer_size, *cache_ptr, allow_stall));
return reinterpret_cast<jlong>(write_buffer_manager);
return GET_CPLUSPLUS_POINTER(write_buffer_manager);
}
/*

Loading…
Cancel
Save