comment unused parameters to turn on -Wunused-parameter flag

Summary:
This PR comments out the rest of the unused arguments which allow us to turn on the -Wunused-parameter flag. This is the second part of a codemod relating to https://github.com/facebook/rocksdb/pull/3557.
Closes https://github.com/facebook/rocksdb/pull/3662

Differential Revision: D7426121

Pulled By: Dayvedde

fbshipit-source-id: 223994923b42bd4953eb016a0129e47560f7e352
main
David Lai 7 years ago committed by Facebook Github Bot
parent d15397ba10
commit 3be9b36453
  1. 2
      Makefile
  2. 2
      cache/cache_bench.cc
  3. 4
      cache/clock_cache.cc
  4. 53
      db/c_test.c
  5. 1
      db/column_family.cc
  6. 18
      db/column_family_test.cc
  7. 124
      db/compaction_job.cc
  8. 8
      db/compaction_job_stats_test.cc
  9. 4
      db/compaction_picker.cc
  10. 4
      db/db_bloom_filter_test.cc
  11. 42
      db/db_compaction_test.cc
  12. 4
      db/db_dynamic_level_test.cc
  13. 4
      db/db_flush_test.cc
  14. 103
      db/db_impl.cc
  15. 99
      db/db_impl_compaction_flush.cc
  16. 16
      db/db_impl_readonly.cc
  17. 6
      db/db_iter_test.cc
  18. 4
      db/db_options_test.cc
  19. 20
      db/db_sst_test.cc
  20. 6
      db/db_tailing_iter_test.cc
  21. 12
      db/db_test.cc
  22. 8
      db/db_test2.cc
  23. 14
      db/db_universal_compaction_test.cc
  24. 31
      db/event_helpers.cc
  25. 7
      db/experimental.cc
  26. 6
      db/external_sst_file_test.cc
  27. 4
      db/fault_injection_test.cc
  28. 44
      db/internal_stats.cc
  29. 40
      db/internal_stats.h
  30. 5
      db/job_context.h
  31. 10
      db/version_set.cc
  32. 3
      db/write_batch.cc
  33. 3
      env/env_posix.cc
  34. 4
      env/env_test.cc
  35. 21
      env/io_posix.cc
  36. 72
      env/mock_env.cc
  37. 2
      include/rocksdb/env.h
  38. 4
      include/rocksdb/utilities/lua/rocks_lua_compaction_filter.h
  39. 2
      include/rocksdb/utilities/lua/rocks_lua_custom_library.h
  40. 116
      java/rocksjni/backupablejni.cc
  41. 71
      java/rocksjni/backupenginejni.cc
  42. 2
      java/rocksjni/cassandra_compactionfilterjni.cc
  43. 16
      java/rocksjni/cassandra_value_operator.cc
  44. 27
      java/rocksjni/checkpoint.cc
  45. 12
      java/rocksjni/clock_cache.cc
  46. 30
      java/rocksjni/columnfamilyhandle.cc
  47. 5
      java/rocksjni/compaction_filter.cc
  48. 11
      java/rocksjni/compaction_filter_factory.cc
  49. 15
      java/rocksjni/compaction_options_fifo.cc
  50. 49
      java/rocksjni/compaction_options_universal.cc
  51. 20
      java/rocksjni/comparator.cc
  52. 50
      java/rocksjni/compression_options.cc
  53. 27
      java/rocksjni/env.cc
  54. 83
      java/rocksjni/env_options.cc
  55. 17
      java/rocksjni/filter.cc
  56. 29
      java/rocksjni/ingest_external_file_options.cc
  57. 77
      java/rocksjni/iterator.cc
  58. 99
      java/rocksjni/loggerjnicallback.cc
  59. 18
      java/rocksjni/lru_cache.cc
  60. 33
      java/rocksjni/memtablejni.cc
  61. 25
      java/rocksjni/merge_operator.cc
  62. 23
      java/rocksjni/native_comparator_wrapper_test.cc
  63. 68
      java/rocksjni/optimistic_transaction_db.cc
  64. 15
      java/rocksjni/optimistic_transaction_options.cc
  65. 2869
      java/rocksjni/options.cc
  66. 6
      java/rocksjni/options_util.cc
  67. 4
      java/rocksjni/portal.h
  68. 81
      java/rocksjni/ratelimiterjni.cc
  69. 6
      java/rocksjni/remove_emptyvalue_compactionfilterjni.cc
  70. 11
      java/rocksjni/restorejni.cc
  71. 19
      java/rocksjni/rocks_callback_object.cc
  72. 12
      java/rocksjni/rocksdb_exception_test.cc
  73. 815
      java/rocksjni/rocksjni.cc
  74. 153
      java/rocksjni/slice.cc
  75. 8
      java/rocksjni/snapshot.cc
  76. 108
      java/rocksjni/sst_file_manager.cc
  77. 104
      java/rocksjni/sst_file_writerjni.cc
  78. 85
      java/rocksjni/statistics.cc
  79. 30
      java/rocksjni/table.cc
  80. 582
      java/rocksjni/transaction.cc
  81. 128
      java/rocksjni/transaction_db.cc
  82. 59
      java/rocksjni/transaction_db_options.cc
  83. 29
      java/rocksjni/transaction_log.cc
  84. 8
      java/rocksjni/transaction_notifier.cc
  85. 93
      java/rocksjni/transaction_options.cc
  86. 56
      java/rocksjni/ttl.cc
  87. 208
      java/rocksjni/write_batch.cc
  88. 29
      java/rocksjni/write_batch_test.cc
  89. 261
      java/rocksjni/write_batch_with_index.cc
  90. 10
      memtable/memtablerep_bench.cc
  91. 6
      memtable/write_buffer_manager.cc
  92. 45
      monitoring/thread_status_impl.cc
  93. 122
      monitoring/thread_status_updater.cc
  94. 7
      monitoring/thread_status_updater_debug.cc
  95. 76
      monitoring/thread_status_util.cc
  96. 21
      table/block_based_table_factory.cc
  97. 2
      table/cuckoo_table_factory.h
  98. 31
      table/format.h
  99. 6
      table/full_filter_block.cc
  100. 8
      table/get_context.cc
  101. Some files were not shown because too many files have changed in this diff Show More

@ -278,7 +278,7 @@ endif
default: all
WARNING_FLAGS = -W -Wextra -Wall -Wsign-compare -Wshadow \
-Wno-unused-parameter
-Wunused-parameter
ifeq ($(PLATFORM), OS_OPENBSD)
WARNING_FLAGS += -Wno-unused-lambda-capture

@ -52,7 +52,7 @@ namespace rocksdb {
class CacheBench;
namespace {
void deleter(const Slice& key, void* value) {
void deleter(const Slice& /*key*/, void* value) {
delete reinterpret_cast<char *>(value);
}

@ -13,8 +13,8 @@
namespace rocksdb {
std::shared_ptr<Cache> NewClockCache(size_t capacity, int num_shard_bits,
bool strict_capacity_limit) {
std::shared_ptr<Cache> NewClockCache(size_t /*capacity*/, int /*num_shard_bits*/,
bool /*strict_capacity_limit*/) {
// Clock cache not supported.
return nullptr;
}

@ -192,10 +192,11 @@ static void CheckDel(void* ptr, const char* k, size_t klen) {
(*state)++;
}
static void CmpDestroy(void* arg) { }
static void CmpDestroy(void* arg) { (void)arg; }
static int CmpCompare(void* arg, const char* a, size_t alen,
const char* b, size_t blen) {
(void)arg;
size_t n = (alen < blen) ? alen : blen;
int r = memcmp(a, b, n);
if (r == 0) {
@ -206,13 +207,15 @@ static int CmpCompare(void* arg, const char* a, size_t alen,
}
static const char* CmpName(void* arg) {
(void)arg;
return "foo";
}
// Custom filter policy
static unsigned char fake_filter_result = 1;
static void FilterDestroy(void* arg) { }
static void FilterDestroy(void* arg) { (void)arg; }
static const char* FilterName(void* arg) {
(void)arg;
return "TestFilter";
}
static char* FilterCreate(
@ -220,6 +223,10 @@ static char* FilterCreate(
const char* const* key_array, const size_t* key_length_array,
int num_keys,
size_t* filter_length) {
(void)arg;
(void)key_array;
(void)key_length_array;
(void)num_keys;
*filter_length = 4;
char* result = malloc(4);
memcpy(result, "fake", 4);
@ -229,20 +236,30 @@ static unsigned char FilterKeyMatch(
void* arg,
const char* key, size_t length,
const char* filter, size_t filter_length) {
(void)arg;
(void)key;
(void)length;
CheckCondition(filter_length == 4);
CheckCondition(memcmp(filter, "fake", 4) == 0);
return fake_filter_result;
}
// Custom compaction filter
static void CFilterDestroy(void* arg) {}
static const char* CFilterName(void* arg) { return "foo"; }
static void CFilterDestroy(void* arg) { (void)arg; }
static const char* CFilterName(void* arg) {
(void)arg;
return "foo";
}
static unsigned char CFilterFilter(void* arg, int level, const char* key,
size_t key_length,
const char* existing_value,
size_t value_length, char** new_value,
size_t* new_value_length,
unsigned char* value_changed) {
(void)arg;
(void)level;
(void)existing_value;
(void)value_length;
if (key_length == 3) {
if (memcmp(key, "bar", key_length) == 0) {
return 1;
@ -256,10 +273,15 @@ static unsigned char CFilterFilter(void* arg, int level, const char* key,
return 0;
}
static void CFilterFactoryDestroy(void* arg) {}
static const char* CFilterFactoryName(void* arg) { return "foo"; }
static void CFilterFactoryDestroy(void* arg) { (void)arg; }
static const char* CFilterFactoryName(void* arg) {
(void)arg;
return "foo";
}
static rocksdb_compactionfilter_t* CFilterCreate(
void* arg, rocksdb_compactionfiltercontext_t* context) {
(void)arg;
(void)context;
return rocksdb_compactionfilter_create(NULL, CFilterDestroy, CFilterFilter,
CFilterName);
}
@ -290,8 +312,9 @@ static rocksdb_t* CheckCompaction(rocksdb_t* db, rocksdb_options_t* options,
}
// Custom merge operator
static void MergeOperatorDestroy(void* arg) { }
static void MergeOperatorDestroy(void* arg) { (void)arg; }
static const char* MergeOperatorName(void* arg) {
(void)arg;
return "TestMergeOperator";
}
static char* MergeOperatorFullMerge(
@ -301,6 +324,14 @@ static char* MergeOperatorFullMerge(
const char* const* operands_list, const size_t* operands_list_length,
int num_operands,
unsigned char* success, size_t* new_value_length) {
(void)arg;
(void)key;
(void)key_length;
(void)existing_value;
(void)existing_value_length;
(void)operands_list;
(void)operands_list_length;
(void)num_operands;
*new_value_length = 4;
*success = 1;
char* result = malloc(4);
@ -313,6 +344,12 @@ static char* MergeOperatorPartialMerge(
const char* const* operands_list, const size_t* operands_list_length,
int num_operands,
unsigned char* success, size_t* new_value_length) {
(void)arg;
(void)key;
(void)key_length;
(void)operands_list;
(void)operands_list_length;
(void)num_operands;
*new_value_length = 4;
*success = 1;
char* result = malloc(4);
@ -377,6 +414,8 @@ static void CheckTxnDBGetCF(rocksdb_transactiondb_t* txn_db,
}
int main(int argc, char** argv) {
(void)argc;
(void)argv;
rocksdb_t* db;
rocksdb_comparator_t* cmp;
rocksdb_cache_t* cache;

@ -85,6 +85,7 @@ Status ColumnFamilyHandleImpl::GetDescriptor(ColumnFamilyDescriptor* desc) {
*desc = ColumnFamilyDescriptor(cfd()->GetName(), cfd()->GetLatestCFOptions());
return Status::OK();
#else
(void)desc;
return Status::NotSupported();
#endif // !ROCKSDB_LITE
}

@ -1361,7 +1361,7 @@ TEST_F(ColumnFamilyTest, MultipleManualCompactions) {
{"ColumnFamilyTest::MultiManual:2", "ColumnFamilyTest::MultiManual:5"},
{"ColumnFamilyTest::MultiManual:2", "ColumnFamilyTest::MultiManual:3"}});
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* arg) {
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) {
if (cf_1_1) {
TEST_SYNC_POINT("ColumnFamilyTest::MultiManual:4");
cf_1_1 = false;
@ -1454,7 +1454,7 @@ TEST_F(ColumnFamilyTest, AutomaticAndManualCompactions) {
{"ColumnFamilyTest::AutoManual:2", "ColumnFamilyTest::AutoManual:5"},
{"ColumnFamilyTest::AutoManual:2", "ColumnFamilyTest::AutoManual:3"}});
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* arg) {
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) {
if (cf_1_1) {
cf_1_1 = false;
TEST_SYNC_POINT("ColumnFamilyTest::AutoManual:4");
@ -1555,7 +1555,7 @@ TEST_F(ColumnFamilyTest, ManualAndAutomaticCompactions) {
{"ColumnFamilyTest::ManualAuto:5", "ColumnFamilyTest::ManualAuto:2"},
{"ColumnFamilyTest::ManualAuto:2", "ColumnFamilyTest::ManualAuto:3"}});
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* arg) {
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) {
if (cf_1_1) {
TEST_SYNC_POINT("ColumnFamilyTest::ManualAuto:4");
cf_1_1 = false;
@ -1648,7 +1648,7 @@ TEST_F(ColumnFamilyTest, SameCFManualManualCompactions) {
{"ColumnFamilyTest::ManualManual:1",
"ColumnFamilyTest::ManualManual:3"}});
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* arg) {
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) {
if (cf_1_1) {
TEST_SYNC_POINT("ColumnFamilyTest::ManualManual:4");
cf_1_1 = false;
@ -1746,7 +1746,7 @@ TEST_F(ColumnFamilyTest, SameCFManualAutomaticCompactions) {
{"ColumnFamilyTest::ManualAuto:1", "ColumnFamilyTest::ManualAuto:2"},
{"ColumnFamilyTest::ManualAuto:1", "ColumnFamilyTest::ManualAuto:3"}});
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* arg) {
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) {
if (cf_1_1) {
TEST_SYNC_POINT("ColumnFamilyTest::ManualAuto:4");
cf_1_1 = false;
@ -1838,7 +1838,7 @@ TEST_F(ColumnFamilyTest, SameCFManualAutomaticCompactionsLevel) {
"ColumnFamilyTest::ManualAuto:3"},
{"ColumnFamilyTest::ManualAuto:1", "ColumnFamilyTest::ManualAuto:3"}});
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* arg) {
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) {
if (cf_1_1) {
TEST_SYNC_POINT("ColumnFamilyTest::ManualAuto:4");
cf_1_1 = false;
@ -1925,7 +1925,7 @@ TEST_F(ColumnFamilyTest, SameCFAutomaticManualCompactions) {
{"CompactionPicker::CompactRange:Conflict",
"ColumnFamilyTest::AutoManual:3"}});
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* arg) {
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) {
if (cf_1_1) {
TEST_SYNC_POINT("ColumnFamilyTest::AutoManual:4");
cf_1_1 = false;
@ -2372,7 +2372,7 @@ TEST_F(ColumnFamilyTest, CreateAndDropRace) {
auto main_thread_id = std::this_thread::get_id();
rocksdb::SyncPoint::GetInstance()->SetCallBack("PersistRocksDBOptions:start",
[&](void* arg) {
[&](void* /*arg*/) {
auto current_thread_id = std::this_thread::get_id();
// If it's the main thread hitting this sync-point, then it
// will be blocked until some other thread update the test_stage.
@ -2385,7 +2385,7 @@ TEST_F(ColumnFamilyTest, CreateAndDropRace) {
});
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"WriteThread::EnterUnbatched:Wait", [&](void* arg) {
"WriteThread::EnterUnbatched:Wait", [&](void* /*arg*/) {
// This means a thread doing DropColumnFamily() is waiting for
// other thread to finish persisting options.
// In such case, we update the test_stage to unblock the main thread.

@ -354,14 +354,12 @@ CompactionJob::~CompactionJob() {
ThreadStatusUtil::ResetThreadStatus();
}
void CompactionJob::ReportStartedCompaction(
Compaction* compaction) {
void CompactionJob::ReportStartedCompaction(Compaction* compaction) {
const auto* cfd = compact_->compaction->column_family_data();
ThreadStatusUtil::SetColumnFamily(cfd, cfd->ioptions()->env,
db_options_.enable_thread_tracking);
ThreadStatusUtil::SetThreadOperationProperty(
ThreadStatus::COMPACTION_JOB_ID,
ThreadStatusUtil::SetThreadOperationProperty(ThreadStatus::COMPACTION_JOB_ID,
job_id_);
ThreadStatusUtil::SetThreadOperationProperty(
@ -392,8 +390,7 @@ void CompactionJob::ReportStartedCompaction(
// Set the thread operation after operation properties
// to ensure GetThreadList() can always show them all together.
ThreadStatusUtil::SetThreadOperation(
ThreadStatus::OP_COMPACTION);
ThreadStatusUtil::SetThreadOperation(ThreadStatus::OP_COMPACTION);
if (compaction_job_stats_) {
compaction_job_stats_->is_manual_compaction =
@ -408,11 +405,11 @@ void CompactionJob::Prepare() {
// Generate file_levels_ for compaction berfore making Iterator
auto* c = compact_->compaction;
assert(c->column_family_data() != nullptr);
assert(c->column_family_data()->current()->storage_info()
->NumLevelFiles(compact_->compaction->level()) > 0);
assert(c->column_family_data()->current()->storage_info()->NumLevelFiles(
compact_->compaction->level()) > 0);
write_hint_ = c->column_family_data()->CalculateSSTWriteHint(
c->output_level());
write_hint_ =
c->column_family_data()->CalculateSSTWriteHint(c->output_level());
// Is this compaction producing files at the bottommost level?
bottommost_level_ = c->bottommost_level();
@ -495,14 +492,18 @@ void CompactionJob::GenSubcompactionBoundaries() {
}
std::sort(bounds.begin(), bounds.end(),
[cfd_comparator] (const Slice& a, const Slice& b) -> bool {
return cfd_comparator->Compare(ExtractUserKey(a), ExtractUserKey(b)) < 0;
[cfd_comparator](const Slice& a, const Slice& b) -> bool {
return cfd_comparator->Compare(ExtractUserKey(a),
ExtractUserKey(b)) < 0;
});
// Remove duplicated entries from bounds
bounds.erase(std::unique(bounds.begin(), bounds.end(),
[cfd_comparator] (const Slice& a, const Slice& b) -> bool {
return cfd_comparator->Compare(ExtractUserKey(a), ExtractUserKey(b)) == 0;
}), bounds.end());
bounds.erase(
std::unique(bounds.begin(), bounds.end(),
[cfd_comparator](const Slice& a, const Slice& b) -> bool {
return cfd_comparator->Compare(ExtractUserKey(a),
ExtractUserKey(b)) == 0;
}),
bounds.end());
// Combine consecutive pairs of boundaries into ranges with an approximate
// size of data covered by keys in that range
@ -606,10 +607,9 @@ Status CompactionJob::Run() {
TablePropertiesCollection tp;
for (const auto& state : compact_->sub_compact_states) {
for (const auto& output : state.outputs) {
auto fn = TableFileName(
state.compaction->immutable_cf_options()->cf_paths,
output.meta.fd.GetNumber(),
output.meta.fd.GetPathId());
auto fn =
TableFileName(state.compaction->immutable_cf_options()->cf_paths,
output.meta.fd.GetNumber(), output.meta.fd.GetPathId());
tp[fn] = output.table_properties;
}
}
@ -765,8 +765,8 @@ void CompactionJob::ProcessKeyValueCompaction(SubcompactionState* sub_compact) {
std::set<size_t> sample_begin_offsets;
if (bottommost_level_ && kSampleBytes > 0) {
const size_t kMaxSamples = kSampleBytes >> kSampleLenShift;
const size_t kOutFileLen = static_cast<size_t>(
mutable_cf_options->MaxFileSizeForLevel(
const size_t kOutFileLen =
static_cast<size_t>(mutable_cf_options->MaxFileSizeForLevel(
compact_->compaction->output_level()));
if (kOutFileLen != port::kMaxSizet) {
const size_t kOutFileNumSamples = kOutFileLen >> kSampleLenShift;
@ -815,13 +815,12 @@ void CompactionJob::ProcessKeyValueCompaction(SubcompactionState* sub_compact) {
preserve_deletes_seqnum_));
auto c_iter = sub_compact->c_iter.get();
c_iter->SeekToFirst();
if (c_iter->Valid() &&
sub_compact->compaction->output_level() != 0) {
if (c_iter->Valid() && sub_compact->compaction->output_level() != 0) {
// ShouldStopBefore() maintains state based on keys processed so far. The
// compaction loop always calls it on the "next" key, thus won't tell it the
// first key. So we do that here.
sub_compact->ShouldStopBefore(
c_iter->key(), sub_compact->current_output_file_size);
sub_compact->ShouldStopBefore(c_iter->key(),
sub_compact->current_output_file_size);
}
const auto& c_iter_stats = c_iter->iter_stats();
auto sample_begin_offset_iter = sample_begin_offsets.cbegin();
@ -935,8 +934,8 @@ void CompactionJob::ProcessKeyValueCompaction(SubcompactionState* sub_compact) {
c_iter->Next();
if (!output_file_ended && c_iter->Valid() &&
sub_compact->compaction->output_level() != 0 &&
sub_compact->ShouldStopBefore(
c_iter->key(), sub_compact->current_output_file_size) &&
sub_compact->ShouldStopBefore(c_iter->key(),
sub_compact->current_output_file_size) &&
sub_compact->builder != nullptr) {
// (2) this key belongs to the next file. For historical reasons, the
// iterator status after advancing will be given to
@ -988,8 +987,8 @@ void CompactionJob::ProcessKeyValueCompaction(SubcompactionState* sub_compact) {
RecordDroppedKeys(c_iter_stats, &sub_compact->compaction_job_stats);
RecordCompactionIOStats();
if (status.ok() && (shutting_down_->load(std::memory_order_relaxed) ||
cfd->IsDropped())) {
if (status.ok() &&
(shutting_down_->load(std::memory_order_relaxed) || cfd->IsDropped())) {
status = Status::ShutdownInProgress(
"Database shutdown or Column family drop during compaction");
}
@ -1153,10 +1152,9 @@ Status CompactionJob::FinishCompactionOutputFile(
// If there is nothing to output, no necessary to generate a sst file.
// This happens when the output level is bottom level, at the same time
// the sub_compact output nothing.
std::string fname = TableFileName(
sub_compact->compaction->immutable_cf_options()->cf_paths,
meta->fd.GetNumber(),
meta->fd.GetPathId());
std::string fname =
TableFileName(sub_compact->compaction->immutable_cf_options()->cf_paths,
meta->fd.GetNumber(), meta->fd.GetPathId());
env_->DeleteFile(fname);
// Also need to remove the file from outputs, or it will be added to the
@ -1187,7 +1185,8 @@ Status CompactionJob::FinishCompactionOutputFile(
s = iter->status();
if (s.ok() && paranoid_file_checks_) {
for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {}
for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
}
s = iter->status();
}
@ -1209,10 +1208,9 @@ Status CompactionJob::FinishCompactionOutputFile(
std::string fname;
FileDescriptor output_fd;
if (meta != nullptr) {
fname = TableFileName(
sub_compact->compaction->immutable_cf_options()->cf_paths,
meta->fd.GetNumber(),
meta->fd.GetPathId());
fname =
TableFileName(sub_compact->compaction->immutable_cf_options()->cf_paths,
meta->fd.GetNumber(), meta->fd.GetPathId());
output_fd = meta->fd;
} else {
fname = "(nil)";
@ -1226,10 +1224,9 @@ Status CompactionJob::FinishCompactionOutputFile(
auto sfm =
static_cast<SstFileManagerImpl*>(db_options_.sst_file_manager.get());
if (sfm && meta != nullptr && meta->fd.GetPathId() == 0) {
auto fn = TableFileName(
sub_compact->compaction->immutable_cf_options()->cf_paths,
meta->fd.GetNumber(),
meta->fd.GetPathId());
auto fn =
TableFileName(sub_compact->compaction->immutable_cf_options()->cf_paths,
meta->fd.GetNumber(), meta->fd.GetPathId());
sfm->OnAddFile(fn);
if (sfm->IsMaxAllowedSpaceReached()) {
// TODO(ajkr): should we return OK() if max space was reached by the final
@ -1314,10 +1311,9 @@ Status CompactionJob::OpenCompactionOutputFile(
assert(sub_compact->builder == nullptr);
// no need to lock because VersionSet::next_file_number_ is atomic
uint64_t file_number = versions_->NewFileNumber();
std::string fname = TableFileName(
sub_compact->compaction->immutable_cf_options()->cf_paths,
file_number,
sub_compact->compaction->output_path_id());
std::string fname =
TableFileName(sub_compact->compaction->immutable_cf_options()->cf_paths,
file_number, sub_compact->compaction->output_path_id());
// Fire events.
ColumnFamilyData* cfd = sub_compact->compaction->column_family_data();
#ifndef ROCKSDB_LITE
@ -1419,8 +1415,7 @@ void CompactionJob::CleanupCompaction() {
#ifndef ROCKSDB_LITE
namespace {
void CopyPrefix(
const Slice& src, size_t prefix_length, std::string* dst) {
void CopyPrefix(const Slice& src, size_t prefix_length, std::string* dst) {
assert(prefix_length > 0);
size_t length = src.size() > prefix_length ? prefix_length : src.size();
dst->assign(src.data(), length);
@ -1439,13 +1434,11 @@ void CompactionJob::UpdateCompactionStats() {
if (compaction->level(input_level) != compaction->output_level()) {
UpdateCompactionInputStatsHelper(
&compaction_stats_.num_input_files_in_non_output_levels,
&compaction_stats_.bytes_read_non_output_levels,
input_level);
&compaction_stats_.bytes_read_non_output_levels, input_level);
} else {
UpdateCompactionInputStatsHelper(
&compaction_stats_.num_input_files_in_output_level,
&compaction_stats_.bytes_read_output_level,
input_level);
&compaction_stats_.bytes_read_output_level, input_level);
}
}
@ -1468,8 +1461,9 @@ void CompactionJob::UpdateCompactionStats() {
}
}
void CompactionJob::UpdateCompactionInputStatsHelper(
int* num_files, uint64_t* bytes_read, int input_level) {
void CompactionJob::UpdateCompactionInputStatsHelper(int* num_files,
uint64_t* bytes_read,
int input_level) {
const Compaction* compaction = compact_->compaction;
auto num_input_files = compaction->num_input_files(input_level);
*num_files += static_cast<int>(num_input_files);
@ -1490,10 +1484,8 @@ void CompactionJob::UpdateCompactionJobStats(
// input information
compaction_job_stats_->total_input_bytes =
stats.bytes_read_non_output_levels +
stats.bytes_read_output_level;
compaction_job_stats_->num_input_records =
compact_->num_input_records;
stats.bytes_read_non_output_levels + stats.bytes_read_output_level;
compaction_job_stats_->num_input_records = compact_->num_input_records;
compaction_job_stats_->num_input_files =
stats.num_input_files_in_non_output_levels +
stats.num_input_files_in_output_level;
@ -1502,21 +1494,20 @@ void CompactionJob::UpdateCompactionJobStats(
// output information
compaction_job_stats_->total_output_bytes = stats.bytes_written;
compaction_job_stats_->num_output_records =
compact_->num_output_records;
compaction_job_stats_->num_output_records = compact_->num_output_records;
compaction_job_stats_->num_output_files = stats.num_output_files;
if (compact_->NumOutputFiles() > 0U) {
CopyPrefix(
compact_->SmallestUserKey(),
CopyPrefix(compact_->SmallestUserKey(),
CompactionJobStats::kMaxPrefixLength,
&compaction_job_stats_->smallest_output_key_prefix);
CopyPrefix(
compact_->LargestUserKey(),
CopyPrefix(compact_->LargestUserKey(),
CompactionJobStats::kMaxPrefixLength,
&compaction_job_stats_->largest_output_key_prefix);
}
}
#else
(void)stats;
#endif // !ROCKSDB_LITE
}
@ -1538,7 +1529,8 @@ void CompactionJob::LogCompaction() {
cfd->GetName().c_str(), scratch);
// build event logger report
auto stream = event_logger_->Log();
stream << "job" << job_id_ << "event" << "compaction_started"
stream << "job" << job_id_ << "event"
<< "compaction_started"
<< "compaction_reason"
<< GetCompactionReasonString(compaction->compaction_reason());
for (size_t i = 0; i < compaction->num_input_levels(); ++i) {

@ -806,7 +806,7 @@ TEST_P(CompactionJobStatsTest, CompactionJobStatsTest) {
stats_checker->set_verify_next_comp_io_stats(true);
std::atomic<bool> first_prepare_write(true);
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"WritableFileWriter::Append:BeforePrepareWrite", [&](void* arg) {
"WritableFileWriter::Append:BeforePrepareWrite", [&](void* /*arg*/) {
if (first_prepare_write.load()) {
options.env->SleepForMicroseconds(3);
first_prepare_write.store(false);
@ -815,7 +815,7 @@ TEST_P(CompactionJobStatsTest, CompactionJobStatsTest) {
std::atomic<bool> first_flush(true);
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"WritableFileWriter::Flush:BeforeAppend", [&](void* arg) {
"WritableFileWriter::Flush:BeforeAppend", [&](void* /*arg*/) {
if (first_flush.load()) {
options.env->SleepForMicroseconds(3);
first_flush.store(false);
@ -824,7 +824,7 @@ TEST_P(CompactionJobStatsTest, CompactionJobStatsTest) {
std::atomic<bool> first_sync(true);
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"WritableFileWriter::SyncInternal:0", [&](void* arg) {
"WritableFileWriter::SyncInternal:0", [&](void* /*arg*/) {
if (first_sync.load()) {
options.env->SleepForMicroseconds(3);
first_sync.store(false);
@ -833,7 +833,7 @@ TEST_P(CompactionJobStatsTest, CompactionJobStatsTest) {
std::atomic<bool> first_range_sync(true);
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"WritableFileWriter::RangeSync:0", [&](void* arg) {
"WritableFileWriter::RangeSync:0", [&](void* /*arg*/) {
if (first_range_sync.load()) {
options.env->SleepForMicroseconds(3);
first_range_sync.store(false);

@ -1674,6 +1674,10 @@ Compaction* FIFOCompactionPicker::CompactRange(
uint32_t /*output_path_id*/, const InternalKey* /*begin*/,
const InternalKey* /*end*/, InternalKey** compaction_end,
bool* /*manual_conflict*/) {
#ifdef NDEBUG
(void)input_level;
(void)output_level;
#endif
assert(input_level == 0);
assert(output_level == 0);
*compaction_end = nullptr;

@ -1057,10 +1057,10 @@ TEST_F(DBBloomFilterTest, OptimizeFiltersForHits) {
int32_t non_trivial_move = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:TrivialMove",
[&](void* arg) { trivial_move++; });
[&](void* /*arg*/) { trivial_move++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial",
[&](void* arg) { non_trivial_move++; });
[&](void* /*arg*/) { non_trivial_move++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
CompactRangeOptions compact_options;

@ -436,7 +436,7 @@ TEST_F(DBCompactionTest, TestTableReaderForCompaction) {
});
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"TableCache::GetTableReader:0",
[&](void* arg) { num_new_table_reader++; });
[&](void* /*arg*/) { num_new_table_reader++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
for (int k = 0; k < options.level0_file_num_compaction_trigger; ++k) {
@ -992,7 +992,7 @@ TEST_P(DBCompactionTestWithParam, TrivialMoveOneFile) {
int32_t trivial_move = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:TrivialMove",
[&](void* arg) { trivial_move++; });
[&](void* /*arg*/) { trivial_move++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
Options options = CurrentOptions();
@ -1049,10 +1049,10 @@ TEST_P(DBCompactionTestWithParam, TrivialMoveNonOverlappingFiles) {
int32_t non_trivial_move = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:TrivialMove",
[&](void* arg) { trivial_move++; });
[&](void* /*arg*/) { trivial_move++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial",
[&](void* arg) { non_trivial_move++; });
[&](void* /*arg*/) { non_trivial_move++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
Options options = CurrentOptions();
@ -1148,10 +1148,10 @@ TEST_P(DBCompactionTestWithParam, TrivialMoveTargetLevel) {
int32_t non_trivial_move = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:TrivialMove",
[&](void* arg) { trivial_move++; });
[&](void* /*arg*/) { trivial_move++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial",
[&](void* arg) { non_trivial_move++; });
[&](void* /*arg*/) { non_trivial_move++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
Options options = CurrentOptions();
@ -1207,10 +1207,10 @@ TEST_P(DBCompactionTestWithParam, ManualCompactionPartial) {
int32_t non_trivial_move = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:TrivialMove",
[&](void* arg) { trivial_move++; });
[&](void* /*arg*/) { trivial_move++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial",
[&](void* arg) { non_trivial_move++; });
[&](void* /*arg*/) { non_trivial_move++; });
bool first = true;
// Purpose of dependencies:
// 4 -> 1: ensure the order of two non-trivial compactions
@ -1221,7 +1221,7 @@ TEST_P(DBCompactionTestWithParam, ManualCompactionPartial) {
{"DBCompaction::ManualPartial:5", "DBCompaction::ManualPartial:2"},
{"DBCompaction::ManualPartial:5", "DBCompaction::ManualPartial:3"}});
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* arg) {
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) {
if (first) {
first = false;
TEST_SYNC_POINT("DBCompaction::ManualPartial:4");
@ -1352,17 +1352,17 @@ TEST_F(DBCompactionTest, DISABLED_ManualPartialFill) {
int32_t non_trivial_move = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:TrivialMove",
[&](void* arg) { trivial_move++; });
[&](void* /*arg*/) { trivial_move++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial",
[&](void* arg) { non_trivial_move++; });
[&](void* /*arg*/) { non_trivial_move++; });
bool first = true;
bool second = true;
rocksdb::SyncPoint::GetInstance()->LoadDependency(
{{"DBCompaction::PartialFill:4", "DBCompaction::PartialFill:1"},
{"DBCompaction::PartialFill:2", "DBCompaction::PartialFill:3"}});
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* arg) {
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun", [&](void* /*arg*/) {
if (first) {
TEST_SYNC_POINT("DBCompaction::PartialFill:4");
first = false;
@ -1768,10 +1768,10 @@ TEST_P(DBCompactionTestWithParam, TrivialMoveToLastLevelWithFiles) {
int32_t non_trivial_move = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:TrivialMove",
[&](void* arg) { trivial_move++; });
[&](void* /*arg*/) { trivial_move++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial",
[&](void* arg) { non_trivial_move++; });
[&](void* /*arg*/) { non_trivial_move++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
Options options = CurrentOptions();
@ -2768,16 +2768,16 @@ TEST_P(DBCompactionTestWithParam, CompressLevelCompaction) {
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"Compaction::InputCompressionMatchesOutput:Matches",
[&](void* arg) { matches++; });
[&](void* /*arg*/) { matches++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"Compaction::InputCompressionMatchesOutput:DidntMatch",
[&](void* arg) { didnt_match++; });
[&](void* /*arg*/) { didnt_match++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial",
[&](void* arg) { non_trivial++; });
[&](void* /*arg*/) { non_trivial++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:TrivialMove",
[&](void* arg) { trivial_move++; });
[&](void* /*arg*/) { trivial_move++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
Reopen(options);
@ -2939,10 +2939,10 @@ TEST_P(DBCompactionTestWithParam, ForceBottommostLevelCompaction) {
int32_t non_trivial_move = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:TrivialMove",
[&](void* arg) { trivial_move++; });
[&](void* /*arg*/) { trivial_move++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial",
[&](void* arg) { non_trivial_move++; });
[&](void* /*arg*/) { non_trivial_move++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
Options options = CurrentOptions();
@ -3689,7 +3689,7 @@ TEST_P(DBCompactionDirectIOTest, DirectIO) {
});
if (options.use_direct_io_for_flush_and_compaction) {
SyncPoint::GetInstance()->SetCallBack(
"SanitizeOptions:direct_io", [&](void* arg) {
"SanitizeOptions:direct_io", [&](void* /*arg*/) {
readahead = true;
});
}

@ -194,7 +194,7 @@ TEST_F(DBTestDynamicLevel, DynamicLevelMaxBytesBase2) {
// Hold compaction jobs to make sure
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"CompactionJob::Run():Start",
[&](void* arg) { env_->SleepForMicroseconds(100000); });
[&](void* /*arg*/) { env_->SleepForMicroseconds(100000); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
ASSERT_OK(dbfull()->SetOptions({
{"disable_auto_compactions", "true"},
@ -378,7 +378,7 @@ TEST_F(DBTestDynamicLevel, DynamicLevelMaxBytesBaseInc) {
int non_trivial = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial",
[&](void* arg) { non_trivial++; });
[&](void* /*arg*/) { non_trivial++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
Random rnd(301);

@ -105,7 +105,7 @@ TEST_F(DBFlushTest, FlushInLowPriThreadPool) {
std::thread::id tid;
int num_flushes = 0, num_compactions = 0;
SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BGWorkFlush", [&](void* arg) {
"DBImpl::BGWorkFlush", [&](void* /*arg*/) {
if (tid == std::thread::id()) {
tid = std::this_thread::get_id();
} else {
@ -114,7 +114,7 @@ TEST_F(DBFlushTest, FlushInLowPriThreadPool) {
++num_flushes;
});
SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BGWorkCompaction", [&](void* arg) {
"DBImpl::BGWorkCompaction", [&](void* /*arg*/) {
ASSERT_EQ(tid, std::this_thread::get_id());
++num_compactions;
});

@ -97,7 +97,7 @@
namespace rocksdb {
const std::string kDefaultColumnFamilyName("default");
void DumpRocksDBBuildVersion(Logger * log);
void DumpRocksDBBuildVersion(Logger* log);
CompressionType GetCompressionFlush(
const ImmutableCFOptions& ioptions,
@ -355,7 +355,8 @@ Status DBImpl::CloseHelper() {
uint64_t log_number = log.writer->get_log_number();
Status s = log.ClearWriter();
if (!s.ok()) {
ROCKS_LOG_WARN(immutable_db_options_.info_log,
ROCKS_LOG_WARN(
immutable_db_options_.info_log,
"Unable to Sync WAL file %s with error -- %s",
LogFileName(immutable_db_options_.wal_dir, log_number).c_str(),
s.ToString().c_str());
@ -533,9 +534,12 @@ Directory* DBImpl::Directories::GetDataDir(size_t path_id) const {
return ret_dir;
}
Status DBImpl::SetOptions(ColumnFamilyHandle* column_family,
Status DBImpl::SetOptions(
ColumnFamilyHandle* column_family,
const std::unordered_map<std::string, std::string>& options_map) {
#ifdef ROCKSDB_LITE
(void)column_family;
(void)options_map;
return Status::NotSupported("Not supported in ROCKSDB LITE");
#else
auto* cfd = reinterpret_cast<ColumnFamilyHandleImpl*>(column_family)->cfd();
@ -572,9 +576,9 @@ Status DBImpl::SetOptions(ColumnFamilyHandle* column_family,
}
sv_context.Clean();
ROCKS_LOG_INFO(immutable_db_options_.info_log,
"SetOptions() on column family [%s], inputs:",
cfd->GetName().c_str());
ROCKS_LOG_INFO(
immutable_db_options_.info_log,
"SetOptions() on column family [%s], inputs:", cfd->GetName().c_str());
for (const auto& o : options_map) {
ROCKS_LOG_INFO(immutable_db_options_.info_log, "%s: %s\n", o.first.c_str(),
o.second.c_str());
@ -598,6 +602,7 @@ Status DBImpl::SetOptions(ColumnFamilyHandle* column_family,
Status DBImpl::SetDBOptions(
const std::unordered_map<std::string, std::string>& options_map) {
#ifdef ROCKSDB_LITE
(void)options_map;
return Status::NotSupported("Not supported in ROCKSDB LITE");
#else
if (options_map.empty()) {
@ -624,7 +629,8 @@ Status DBImpl::SetDBOptions(
MaybeScheduleFlushOrCompaction();
}
write_controller_.set_max_delayed_write_rate(new_options.delayed_write_rate);
write_controller_.set_max_delayed_write_rate(
new_options.delayed_write_rate);
table_cache_.get()->SetCapacity(new_options.max_open_files == -1
? TableCache::kInfiniteCapacity
: new_options.max_open_files - 10);
@ -788,12 +794,10 @@ Status DBImpl::SyncWAL() {
return status;
}
void DBImpl::MarkLogsSynced(
uint64_t up_to, bool synced_dir, const Status& status) {
void DBImpl::MarkLogsSynced(uint64_t up_to, bool synced_dir,
const Status& status) {
mutex_.AssertHeld();
if (synced_dir &&
logfile_number_ == up_to &&
status.ok()) {
if (synced_dir && logfile_number_ == up_to && status.ok()) {
log_dir_synced_ = true;
}
for (auto it = logs_.begin(); it != logs_.end() && it->number <= up_to;) {
@ -1029,8 +1033,8 @@ Status DBImpl::GetImpl(const ReadOptions& read_options,
// Because prep_seq > snapshot => commit_seq > snapshot so if a snapshot is
// specified we should be fine with skipping seq numbers that are greater
// than that.
snapshot = reinterpret_cast<const SnapshotImpl*>(
read_options.snapshot)->number_;
snapshot =
reinterpret_cast<const SnapshotImpl*>(read_options.snapshot)->number_;
} else {
// Since we get and reference the super version before getting
// the snapshot number, without a mutex protection, it is possible
@ -1108,7 +1112,6 @@ std::vector<Status> DBImpl::MultiGet(
const ReadOptions& read_options,
const std::vector<ColumnFamilyHandle*>& column_family,
const std::vector<Slice>& keys, std::vector<std::string>* values) {
StopWatch sw(env_, stats_, DB_MULTIGET);
PERF_TIMER_GUARD(get_snapshot_time);
@ -1132,8 +1135,8 @@ std::vector<Status> DBImpl::MultiGet(
mutex_.Lock();
if (read_options.snapshot != nullptr) {
snapshot = reinterpret_cast<const SnapshotImpl*>(
read_options.snapshot)->number_;
snapshot =
reinterpret_cast<const SnapshotImpl*>(read_options.snapshot)->number_;
} else {
snapshot = last_seq_same_as_publish_seq_
? versions_->LastSequence()
@ -1367,8 +1370,8 @@ Status DBImpl::CreateColumnFamilyImpl(const ColumnFamilyOptions& cf_options,
auto* cfd =
versions_->GetColumnFamilySet()->GetColumnFamily(column_family_name);
assert(cfd != nullptr);
InstallSuperVersionAndScheduleWork(
cfd, &sv_context, *cfd->GetLatestMutableCFOptions());
InstallSuperVersionAndScheduleWork(cfd, &sv_context,
*cfd->GetLatestMutableCFOptions());
if (!cfd->mem()->IsSnapshotSupported()) {
is_snapshot_supported_ = false;
@ -1450,8 +1453,8 @@ Status DBImpl::DropColumnFamilyImpl(ColumnFamilyHandle* column_family) {
// we drop column family from a single write thread
WriteThread::Writer w;
write_thread_.EnterUnbatched(&w, &mutex_);
s = versions_->LogAndApply(cfd, *cfd->GetLatestMutableCFOptions(),
&edit, &mutex_);
s = versions_->LogAndApply(cfd, *cfd->GetLatestMutableCFOptions(), &edit,
&mutex_);
write_thread_.ExitUnbatched(&w);
}
if (s.ok()) {
@ -1554,9 +1557,9 @@ Iterator* DBImpl::NewIterator(const ReadOptions& read_options,
#else
SuperVersion* sv = cfd->GetReferencedSuperVersion(&mutex_);
auto iter = new ForwardIterator(this, read_options, cfd, sv);
result = NewDBIterator(
env_, read_options, *cfd->ioptions(), cfd->user_comparator(), iter,
kMaxSequenceNumber,
result =
NewDBIterator(env_, read_options, *cfd->ioptions(),
cfd->user_comparator(), iter, kMaxSequenceNumber,
sv->mutable_cf_options.max_sequential_skip_in_iterations,
read_callback);
#endif
@ -1688,8 +1691,8 @@ Status DBImpl::NewIterators(
? read_options.snapshot->GetSequenceNumber()
: versions_->LastSequence();
for (size_t i = 0; i < column_families.size(); ++i) {
auto* cfd = reinterpret_cast<ColumnFamilyHandleImpl*>(
column_families[i])->cfd();
auto* cfd =
reinterpret_cast<ColumnFamilyHandleImpl*>(column_families[i])->cfd();
iterators->push_back(
NewIteratorImpl(read_options, cfd, snapshot, read_callback));
}
@ -1796,13 +1799,9 @@ Status DBImpl::GetPropertiesOfTablesInRange(ColumnFamilyHandle* column_family,
#endif // ROCKSDB_LITE
const std::string& DBImpl::GetName() const {
return dbname_;
}
const std::string& DBImpl::GetName() const { return dbname_; }
Env* DBImpl::GetEnv() const {
return env_;
}
Env* DBImpl::GetEnv() const { return env_; }
Options DBImpl::GetOptions(ColumnFamilyHandle* column_family) const {
InstrumentedMutexLock l(&mutex_);
@ -2085,7 +2084,6 @@ void DBImpl::ReleaseFileNumberFromPendingOutputs(
Status DBImpl::GetUpdatesSince(
SequenceNumber seq, unique_ptr<TransactionLogIterator>* iter,
const TransactionLogIterator::ReadOptions& read_options) {
RecordTick(stats_, GET_UPDATES_SINCE_CALLS);
if (seq > versions_->LastSequence()) {
return Status::NotFound("Requested sequence not yet written in the db");
@ -2228,8 +2226,8 @@ Status DBImpl::DeleteFilesInRanges(ColumnFamilyHandle* column_family,
end_key = &end_storage;
}
vstorage->GetCleanInputsWithinInterval(i, begin_key, end_key,
&level_files, -1 /* hint_index */,
vstorage->GetCleanInputsWithinInterval(
i, begin_key, end_key, &level_files, -1 /* hint_index */,
nullptr /* file_index */);
FileMetaData* level_file;
for (uint32_t j = 0; j < level_files.size(); j++) {
@ -2241,7 +2239,8 @@ Status DBImpl::DeleteFilesInRanges(ColumnFamilyHandle* column_family,
continue;
}
if (!include_end && end != nullptr &&
cfd->user_comparator()->Compare(level_file->largest.user_key(), *end) == 0) {
cfd->user_comparator()->Compare(level_file->largest.user_key(),
*end) == 0) {
continue;
}
edit.SetColumnFamily(cfd->GetID());
@ -2285,8 +2284,7 @@ void DBImpl::GetLiveFilesMetaData(std::vector<LiveFileMetaData>* metadata) {
versions_->GetLiveFilesMetaData(metadata);
}
void DBImpl::GetColumnFamilyMetaData(
ColumnFamilyHandle* column_family,
void DBImpl::GetColumnFamilyMetaData(ColumnFamilyHandle* column_family,
ColumnFamilyMetaData* cf_meta) {
assert(column_family);
auto* cfd = reinterpret_cast<ColumnFamilyHandleImpl*>(column_family)->cfd();
@ -2413,8 +2411,7 @@ Status DB::ListColumnFamilies(const DBOptions& db_options,
return VersionSet::ListColumnFamilies(column_families, name, db_options.env);
}
Snapshot::~Snapshot() {
}
Snapshot::~Snapshot() {}
Status DestroyDB(const std::string& dbname, const Options& options,
const std::vector<ColumnFamilyDescriptor>& column_families) {
@ -2507,8 +2504,7 @@ Status DestroyDB(const std::string& dbname, const Options& options,
env->GetChildren(archivedir, &archiveFiles);
// Delete archival files.
for (size_t i = 0; i < archiveFiles.size(); ++i) {
if (ParseFileName(archiveFiles[i], &number, &type) &&
type == kLogFile) {
if (ParseFileName(archiveFiles[i], &number, &type) && type == kLogFile) {
Status del = env->DeleteFile(archivedir + "/" + archiveFiles[i]);
if (result.ok() && !del.ok()) {
result = del;
@ -2584,6 +2580,9 @@ Status DBImpl::WriteOptionsFile(bool need_mutex_lock,
s.ToString().c_str());
}
}
#else
(void)need_mutex_lock;
(void)need_enter_write_thread;
#endif // !ROCKSDB_LITE
return Status::OK();
}
@ -2652,22 +2651,21 @@ Status DBImpl::RenameTempFileToOptionsFile(const std::string& file_name) {
DeleteObsoleteOptionsFiles();
return s;
#else
(void)file_name;
return Status::OK();
#endif // !ROCKSDB_LITE
}
#ifdef ROCKSDB_USING_THREAD_STATUS
void DBImpl::NewThreadStatusCfInfo(
ColumnFamilyData* cfd) const {
void DBImpl::NewThreadStatusCfInfo(ColumnFamilyData* cfd) const {
if (immutable_db_options_.enable_thread_tracking) {
ThreadStatusUtil::NewColumnFamilyInfo(this, cfd, cfd->GetName(),
cfd->ioptions()->env);
}
}
void DBImpl::EraseThreadStatusCfInfo(
ColumnFamilyData* cfd) const {
void DBImpl::EraseThreadStatusCfInfo(ColumnFamilyData* cfd) const {
if (immutable_db_options_.enable_thread_tracking) {
ThreadStatusUtil::EraseColumnFamilyInfo(cfd);
}
@ -2680,21 +2678,16 @@ void DBImpl::EraseThreadStatusDbInfo() const {
}
#else
void DBImpl::NewThreadStatusCfInfo(
ColumnFamilyData* cfd) const {
}
void DBImpl::NewThreadStatusCfInfo(ColumnFamilyData* /*cfd*/) const {}
void DBImpl::EraseThreadStatusCfInfo(
ColumnFamilyData* cfd) const {
}
void DBImpl::EraseThreadStatusCfInfo(ColumnFamilyData* /*cfd*/) const {}
void DBImpl::EraseThreadStatusDbInfo() const {
}
void DBImpl::EraseThreadStatusDbInfo() const {}
#endif // ROCKSDB_USING_THREAD_STATUS
//
// A global method that can dump out the build version
void DumpRocksDBBuildVersion(Logger * log) {
void DumpRocksDBBuildVersion(Logger* log) {
#if !defined(IOS_CROSS_COMPILE)
// if we compile with Xcode, we don't run build_detect_version, so we don't
// generate util/build_version.cc

@ -38,6 +38,9 @@ bool DBImpl::EnoughRoomForCompaction(
*sfm_reserved_compact_space = true;
}
}
#else
(void)inputs;
(void)sfm_reserved_compact_space;
#endif // ROCKSDB_LITE
if (!enough_room) {
// Just in case tests want to change the value of enough_room
@ -121,8 +124,7 @@ Status DBImpl::FlushMemTableToOutputFile(
dbname_, cfd, immutable_db_options_, mutable_cf_options,
env_options_for_compaction_, versions_.get(), &mutex_, &shutting_down_,
snapshot_seqs, earliest_write_conflict_snapshot, snapshot_checker,
job_context, log_buffer, directories_.GetDbDir(),
GetDataDir(cfd, 0U),
job_context, log_buffer, directories_.GetDbDir(), GetDataDir(cfd, 0U),
GetCompressionFlush(*cfd->ioptions(), mutable_cf_options), stats_,
&event_logger_, mutable_cf_options.report_bg_io_stats);
@ -257,6 +259,12 @@ void DBImpl::NotifyOnFlushBegin(ColumnFamilyData* cfd, FileMetaData* file_meta,
mutex_.Lock();
// no need to signal bg_cv_ as it will be signaled at the end of the
// flush process.
#else
(void)cfd;
(void)file_meta;
(void)mutable_cf_options;
(void)job_id;
(void)prop;
#endif // ROCKSDB_LITE
}
@ -302,6 +310,12 @@ void DBImpl::NotifyOnFlushCompleted(ColumnFamilyData* cfd,
mutex_.Lock();
// no need to signal bg_cv_ as it will be signaled at the end of the
// flush process.
#else
(void)cfd;
(void)file_meta;
(void)mutable_cf_options;
(void)job_id;
(void)prop;
#endif // ROCKSDB_LITE
}
@ -410,8 +424,8 @@ Status DBImpl::CompactRange(const CompactRangeOptions& options,
final_output_level--;
}
s = RunManualCompaction(cfd, ColumnFamilyData::kCompactAllLevels,
final_output_level, options.target_path_id,
begin, end, exclusive);
final_output_level, options.target_path_id, begin,
end, exclusive);
} else {
for (int level = 0; level <= max_level_with_files; level++) {
int output_level;
@ -484,13 +498,18 @@ Status DBImpl::CompactRange(const CompactRangeOptions& options,
return s;
}
Status DBImpl::CompactFiles(
const CompactionOptions& compact_options,
Status DBImpl::CompactFiles(const CompactionOptions& compact_options,
ColumnFamilyHandle* column_family,
const std::vector<std::string>& input_file_names,
const int output_level, const int output_path_id,
std::vector<std::string>* const output_file_names) {
#ifdef ROCKSDB_LITE
(void)compact_options;
(void)column_family;
(void)input_file_names;
(void)output_level;
(void)output_path_id;
(void)output_file_names;
// not supported in lite version
return Status::NotSupported("Not supported in ROCKSDB LITE");
#else
@ -515,9 +534,9 @@ Status DBImpl::CompactFiles(
// IngestExternalFile() calls to finish.
WaitForIngestFile();
s = CompactFilesImpl(compact_options, cfd, sv->current,
input_file_names, output_file_names, output_level,
output_path_id, &job_context, &log_buffer);
s = CompactFilesImpl(compact_options, cfd, sv->current, input_file_names,
output_file_names, output_level, output_path_id,
&job_context, &log_buffer);
}
if (sv->Unref()) {
mutex_.Lock();
@ -560,9 +579,8 @@ Status DBImpl::CompactFiles(
Status DBImpl::CompactFilesImpl(
const CompactionOptions& compact_options, ColumnFamilyData* cfd,
Version* version, const std::vector<std::string>& input_file_names,
std::vector<std::string>* const output_file_names,
const int output_level, int output_path_id, JobContext* job_context,
LogBuffer* log_buffer) {
std::vector<std::string>* const output_file_names, const int output_level,
int output_path_id, JobContext* job_context, LogBuffer* log_buffer) {
mutex_.AssertHeld();
if (shutting_down_.load(std::memory_order_acquire)) {
@ -652,10 +670,9 @@ Status DBImpl::CompactFilesImpl(
job_context->job_id, c.get(), immutable_db_options_,
env_options_for_compaction_, versions_.get(), &shutting_down_,
preserve_deletes_seqnum_.load(), log_buffer, directories_.GetDbDir(),
GetDataDir(c->column_family_data(), c->output_path_id()),
stats_, &mutex_, &bg_error_, snapshot_seqs,
earliest_write_conflict_snapshot, snapshot_checker,
table_cache_, &event_logger_,
GetDataDir(c->column_family_data(), c->output_path_id()), stats_, &mutex_,
&bg_error_, snapshot_seqs, earliest_write_conflict_snapshot,
snapshot_checker, table_cache_, &event_logger_,
c->mutable_cf_options()->paranoid_file_checks,
c->mutable_cf_options()->report_bg_io_stats, dbname_,
nullptr); // Here we pass a nullptr for CompactionJobStats because
@ -730,9 +747,10 @@ Status DBImpl::CompactFilesImpl(
if (output_file_names != nullptr) {
for (const auto newf : c->edit()->GetNewFiles()) {
(*output_file_names).push_back(TableFileName(
c->immutable_cf_options()->cf_paths, newf.second.fd.GetNumber(),
newf.second.fd.GetPathId()) );
(*output_file_names)
.push_back(TableFileName(c->immutable_cf_options()->cf_paths,
newf.second.fd.GetNumber(),
newf.second.fd.GetPathId()));
}
}
@ -777,9 +795,8 @@ Status DBImpl::ContinueBackgroundWork() {
}
void DBImpl::NotifyOnCompactionCompleted(
ColumnFamilyData* cfd, Compaction *c, const Status &st,
const CompactionJobStats& compaction_job_stats,
const int job_id) {
ColumnFamilyData* cfd, Compaction* c, const Status& st,
const CompactionJobStats& compaction_job_stats, const int job_id) {
#ifndef ROCKSDB_LITE
if (immutable_db_options_.listeners.size() == 0U) {
return;
@ -821,8 +838,7 @@ void DBImpl::NotifyOnCompactionCompleted(
}
for (const auto newf : c->edit()->GetNewFiles()) {
info.output_files.push_back(TableFileName(
c->immutable_cf_options()->cf_paths,
newf.second.fd.GetNumber(),
c->immutable_cf_options()->cf_paths, newf.second.fd.GetNumber(),
newf.second.fd.GetPathId()));
}
for (auto listener : immutable_db_options_.listeners) {
@ -833,6 +849,12 @@ void DBImpl::NotifyOnCompactionCompleted(
current->Unref();
// no need to signal bg_cv_ as it will be signaled at the end of the
// flush process.
#else
(void)cfd;
(void)c;
(void)st;
(void)compaction_job_stats;
(void)job_id;
#endif // ROCKSDB_LITE
}
@ -929,8 +951,9 @@ int DBImpl::MaxMemCompactionLevel(ColumnFamilyHandle* /*column_family*/) {
int DBImpl::Level0StopWriteTrigger(ColumnFamilyHandle* column_family) {
auto cfh = reinterpret_cast<ColumnFamilyHandleImpl*>(column_family);
InstrumentedMutexLock l(&mutex_);
return cfh->cfd()->GetSuperVersion()->
mutable_cf_options.level0_stop_writes_trigger;
return cfh->cfd()
->GetSuperVersion()
->mutable_cf_options.level0_stop_writes_trigger;
}
Status DBImpl::Flush(const FlushOptions& flush_options,
@ -1800,11 +1823,11 @@ Status DBImpl::BackgroundCompaction(bool* made_progress,
f->largest, f->smallest_seqno, f->largest_seqno,
f->marked_for_compaction);
ROCKS_LOG_BUFFER(log_buffer, "[%s] Moving #%" PRIu64
" to level-%d %" PRIu64 " bytes\n",
c->column_family_data()->GetName().c_str(),
f->fd.GetNumber(), c->output_level(),
f->fd.GetFileSize());
ROCKS_LOG_BUFFER(
log_buffer,
"[%s] Moving #%" PRIu64 " to level-%d %" PRIu64 " bytes\n",
c->column_family_data()->GetName().c_str(), f->fd.GetNumber(),
c->output_level(), f->fd.GetFileSize());
++moved_files;
moved_bytes += f->fd.GetFileSize();
}
@ -1878,9 +1901,8 @@ Status DBImpl::BackgroundCompaction(bool* made_progress,
job_context->job_id, c.get(), immutable_db_options_,
env_options_for_compaction_, versions_.get(), &shutting_down_,
preserve_deletes_seqnum_.load(), log_buffer, directories_.GetDbDir(),
GetDataDir(c->column_family_data(), c->output_path_id()),
stats_, &mutex_, &bg_error_,
snapshot_seqs, earliest_write_conflict_snapshot,
GetDataDir(c->column_family_data(), c->output_path_id()), stats_,
&mutex_, &bg_error_, snapshot_seqs, earliest_write_conflict_snapshot,
snapshot_checker, table_cache_, &event_logger_,
c->mutable_cf_options()->paranoid_file_checks,
c->mutable_cf_options()->report_bg_io_stats, dbname_,
@ -1913,8 +1935,7 @@ Status DBImpl::BackgroundCompaction(bool* made_progress,
}
#endif // ROCKSDB_LITE
NotifyOnCompactionCompleted(
c->column_family_data(), c.get(), status,
NotifyOnCompactionCompleted(c->column_family_data(), c.get(), status,
compaction_job_stats, job_context->job_id);
}
// this will unref its input_version and column_family_data
@ -2100,8 +2121,7 @@ void DBImpl::InstallSuperVersionAndScheduleWork(
if (sv_context->new_superversion == nullptr) {
sv_context->NewSuperVersion();
}
cfd->InstallSuperVersion(sv_context, &mutex_,
mutable_cf_options);
cfd->InstallSuperVersion(sv_context, &mutex_, mutable_cf_options);
// Whenever we install new SuperVersion, we might need to issue new flushes or
// compactions.
@ -2110,8 +2130,7 @@ void DBImpl::InstallSuperVersionAndScheduleWork(
MaybeScheduleFlushOrCompaction();
// Update max_total_in_memory_state_
max_total_in_memory_state_ =
max_total_in_memory_state_ - old_memtable_size +
max_total_in_memory_state_ = max_total_in_memory_state_ - old_memtable_size +
mutable_cf_options.write_buffer_size *
mutable_cf_options.max_write_buffer_number;
}

@ -24,8 +24,7 @@ DBImplReadOnly::DBImplReadOnly(const DBOptions& db_options,
LogFlush(immutable_db_options_.info_log);
}
DBImplReadOnly::~DBImplReadOnly() {
}
DBImplReadOnly::~DBImplReadOnly() {}
// Implementations of the DB interface
Status DBImplReadOnly::Get(const ReadOptions& read_options,
@ -185,16 +184,17 @@ Status DB::OpenForReadOnly(
#else // !ROCKSDB_LITE
Status DB::OpenForReadOnly(const Options& options, const std::string& dbname,
DB** dbptr, bool error_if_log_file_exist) {
Status DB::OpenForReadOnly(const Options& /*options*/,
const std::string& /*dbname*/, DB** /*dbptr*/,
bool /*error_if_log_file_exist*/) {
return Status::NotSupported("Not supported in ROCKSDB_LITE.");
}
Status DB::OpenForReadOnly(
const DBOptions& db_options, const std::string& dbname,
const std::vector<ColumnFamilyDescriptor>& column_families,
std::vector<ColumnFamilyHandle*>* handles, DB** dbptr,
bool error_if_log_file_exist) {
const DBOptions& /*db_options*/, const std::string& /*dbname*/,
const std::vector<ColumnFamilyDescriptor>& /*column_families*/,
std::vector<ColumnFamilyHandle*>* /*handles*/, DB** /*dbptr*/,
bool /*error_if_log_file_exist*/) {
return Status::NotSupported("Not supported in ROCKSDB_LITE.");
}
#endif // !ROCKSDB_LITE

@ -2550,7 +2550,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace1) {
// and before an SeekToLast() is called.
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"MergeIterator::Prev:BeforeSeekToLast",
[&](void* arg) { internal_iter2_->Add("z", kTypeValue, "7", 12u); });
[&](void* /*arg*/) { internal_iter2_->Add("z", kTypeValue, "7", 12u); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
db_iter_->Prev();
@ -2585,7 +2585,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace2) {
// mem table after MergeIterator::Prev() realized the mem tableiterator is at
// its end and before an SeekToLast() is called.
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"MergeIterator::Prev:BeforeSeekToLast", [&](void* arg) {
"MergeIterator::Prev:BeforeSeekToLast", [&](void* /*arg*/) {
internal_iter2_->Add("z", kTypeValue, "7", 12u);
internal_iter2_->Add("z", kTypeValue, "7", 11u);
});
@ -2623,7 +2623,7 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace3) {
// mem table after MergeIterator::Prev() realized the mem table iterator is at
// its end and before an SeekToLast() is called.
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"MergeIterator::Prev:BeforeSeekToLast", [&](void* arg) {
"MergeIterator::Prev:BeforeSeekToLast", [&](void* /*arg*/) {
internal_iter2_->Add("z", kTypeValue, "7", 16u, true);
internal_iter2_->Add("z", kTypeValue, "7", 15u, true);
internal_iter2_->Add("z", kTypeValue, "7", 14u, true);

@ -134,7 +134,7 @@ TEST_F(DBOptionsTest, SetBytesPerSync) {
const std::string kValue(kValueSize, 'v');
ASSERT_EQ(options.bytes_per_sync, dbfull()->GetDBOptions().bytes_per_sync);
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"WritableFileWriter::RangeSync:0", [&](void* arg) {
"WritableFileWriter::RangeSync:0", [&](void* /*arg*/) {
counter++;
});
@ -183,7 +183,7 @@ TEST_F(DBOptionsTest, SetWalBytesPerSync) {
int counter = 0;
int low_bytes_per_sync = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"WritableFileWriter::RangeSync:0", [&](void* arg) {
"WritableFileWriter::RangeSync:0", [&](void* /*arg*/) {
counter++;
});
rocksdb::SyncPoint::GetInstance()->EnableProcessing();

@ -262,11 +262,11 @@ TEST_F(DBSSTTest, DBWithSstFileManager) {
int files_deleted = 0;
int files_moved = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"SstFileManagerImpl::OnAddFile", [&](void* arg) { files_added++; });
"SstFileManagerImpl::OnAddFile", [&](void* /*arg*/) { files_added++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"SstFileManagerImpl::OnDeleteFile", [&](void* arg) { files_deleted++; });
"SstFileManagerImpl::OnDeleteFile", [&](void* /*arg*/) { files_deleted++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"SstFileManagerImpl::OnMoveFile", [&](void* arg) { files_moved++; });
"SstFileManagerImpl::OnMoveFile", [&](void* /*arg*/) { files_moved++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
Options options = CurrentOptions();
@ -439,12 +439,12 @@ TEST_F(DBSSTTest, DeleteSchedulerMultipleDBPaths) {
int bg_delete_file = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DeleteScheduler::DeleteTrashFile:DeleteFile",
[&](void* arg) { bg_delete_file++; });
[&](void* /*arg*/) { bg_delete_file++; });
// The deletion scheduler sometimes skips marking file as trash according to
// a heuristic. In that case the deletion will go through the below SyncPoint.
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DeleteScheduler::DeleteFile",
[&](void* arg) { bg_delete_file++; });
[&](void* /*arg*/) { bg_delete_file++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
Options options = CurrentOptions();
@ -514,7 +514,7 @@ TEST_F(DBSSTTest, DestroyDBWithRateLimitedDelete) {
int bg_delete_file = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DeleteScheduler::DeleteTrashFile:DeleteFile",
[&](void* arg) { bg_delete_file++; });
[&](void* /*arg*/) { bg_delete_file++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
Status s;
@ -588,13 +588,13 @@ TEST_F(DBSSTTest, CancellingCompactionsWorks) {
int completed_compactions = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction():CancelledCompaction", [&](void* arg) {
"DBImpl::BackgroundCompaction():CancelledCompaction", [&](void* /*arg*/) {
sfm->SetMaxAllowedSpaceUsage(0);
ASSERT_EQ(sfm->GetCompactionsReservedSize(), 0);
});
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial:AfterRun",
[&](void* arg) { completed_compactions++; });
[&](void* /*arg*/) { completed_compactions++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
Random rnd(301);
@ -685,7 +685,7 @@ TEST_F(DBSSTTest, CancellingManualCompactionsWorks) {
sfm->SetMaxAllowedSpaceUsage(0);
int completed_compactions = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"CompactFilesImpl:End", [&](void* arg) { completed_compactions++; });
"CompactFilesImpl:End", [&](void* /*arg*/) { completed_compactions++; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
dbfull()->CompactFiles(rocksdb::CompactionOptions(), l0_files, 0);
@ -733,7 +733,7 @@ TEST_F(DBSSTTest, DBWithMaxSpaceAllowedRandomized) {
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"CompactionJob::FinishCompactionOutputFile:MaxAllowedSpaceReached",
[&](void* arg) {
[&](void* /*arg*/) {
bg_error_set = true;
GetAllSSTFiles(&total_sst_files_size);
reached_max_space_on_compaction++;

@ -157,10 +157,10 @@ TEST_F(DBTestTailingIterator, TailingIteratorTrimSeekToNext) {
});
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"ForwardIterator::RenewIterators:Null",
[&](void* arg) { file_iters_renewed_null = true; });
[&](void* /*arg*/) { file_iters_renewed_null = true; });
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"ForwardIterator::RenewIterators:Copy",
[&](void* arg) { file_iters_renewed_copy = true; });
[&](void* /*arg*/) { file_iters_renewed_copy = true; });
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
const int num_records = 1000;
for (int i = 1; i < num_records; ++i) {
@ -415,7 +415,7 @@ TEST_F(DBTestTailingIterator, TailingIteratorUpperBound) {
int immutable_seeks = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"ForwardIterator::SeekInternal:Immutable",
[&](void* arg) { ++immutable_seeks; });
[&](void* /*arg*/) { ++immutable_seeks; });
// Seek to 13. This should not require any immutable seeks.
rocksdb::SyncPoint::GetInstance()->EnableProcessing();

@ -234,11 +234,11 @@ TEST_F(DBTest, SkipDelay) {
std::atomic<int> sleep_count(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::DelayWrite:Sleep",
[&](void* arg) { sleep_count.fetch_add(1); });
[&](void* /*arg*/) { sleep_count.fetch_add(1); });
std::atomic<int> wait_count(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::DelayWrite:Wait",
[&](void* arg) { wait_count.fetch_add(1); });
[&](void* /*arg*/) { wait_count.fetch_add(1); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
WriteOptions wo;
@ -3491,7 +3491,7 @@ TEST_F(DBTest, DynamicMemtableOptions) {
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::DelayWrite:Wait",
[&](void* arg) { sleeping_task_low.WakeUp(); });
[&](void* /*arg*/) { sleeping_task_low.WakeUp(); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
while (!sleeping_task_low.WokenUp() && count < 256) {
@ -5194,7 +5194,7 @@ TEST_F(DBTest, AutomaticConflictsWithManualCompaction) {
std::atomic<int> callback_count(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::MaybeScheduleFlushOrCompaction:Conflict",
[&](void* arg) { callback_count.fetch_add(1); });
[&](void* /*arg*/) { callback_count.fetch_add(1); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
Random rnd(301);
@ -5417,7 +5417,7 @@ TEST_F(DBTest, HardLimit) {
std::atomic<int> callback_count(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack("DBImpl::DelayWrite:Wait",
[&](void* arg) {
[&](void* /*arg*/) {
callback_count.fetch_add(1);
sleeping_task_low.WakeUp();
});
@ -5554,7 +5554,7 @@ TEST_F(DBTest, SoftLimit) {
// Only allow one compactin going through.
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"BackgroundCallCompaction:0", [&](void* arg) {
"BackgroundCallCompaction:0", [&](void* /*arg*/) {
// Schedule a sleeping task.
sleeping_task_low.Reset();
env_->Schedule(&test::SleepingBackgroundTask::DoSleepTask,

@ -1691,7 +1691,7 @@ TEST_F(DBTest2, SyncPointMarker) {
std::atomic<int> sync_point_called(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBTest2::MarkedPoint",
[&](void* arg) { sync_point_called.fetch_add(1); });
[&](void* /*arg*/) { sync_point_called.fetch_add(1); });
// The first dependency enforces Marker can be loaded before MarkedPoint.
// The second checks that thread 1's MarkedPoint should be disabled here.
@ -1978,7 +1978,7 @@ TEST_F(DBTest2, AutomaticCompactionOverlapManualCompaction) {
// can fit in L2, these 2 files will be moved to L2 and overlap with
// the running compaction and break the LSM consistency.
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"CompactionJob::Run():Start", [&](void* arg) {
"CompactionJob::Run():Start", [&](void* /*arg*/) {
ASSERT_OK(
dbfull()->SetOptions({{"level0_file_num_compaction_trigger", "2"},
{"max_bytes_for_level_base", "1"}}));
@ -2044,7 +2044,7 @@ TEST_F(DBTest2, ManualCompactionOverlapManualCompaction) {
// the running compaction and break the LSM consistency.
std::atomic<bool> flag(false);
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"CompactionJob::Run():Start", [&](void* arg) {
"CompactionJob::Run():Start", [&](void* /*arg*/) {
if (flag.exchange(true)) {
// We want to make sure to call this callback only once
return;
@ -2478,7 +2478,7 @@ TEST_F(DBTest2, LiveFilesOmitObsoleteFiles) {
});
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::PurgeObsoleteFiles:Begin",
[&](void* arg) { env_->SleepForMicroseconds(1000000); });
[&](void* /*arg*/) { env_->SleepForMicroseconds(1000000); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
Put("key", "val");

@ -697,7 +697,7 @@ TEST_P(DBTestUniversalCompactionMultiLevels, UniversalCompactionTrivialMove) {
int32_t non_trivial_move = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:TrivialMove",
[&](void* arg) { trivial_move++; });
[&](void* /*arg*/) { trivial_move++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial", [&](void* arg) {
non_trivial_move++;
@ -769,7 +769,7 @@ TEST_P(DBTestUniversalCompactionParallel, UniversalCompactionParallel) {
std::atomic<int> num_compactions_running(0);
std::atomic<bool> has_parallel(false);
rocksdb::SyncPoint::GetInstance()->SetCallBack("CompactionJob::Run():Start",
[&](void* arg) {
[&](void* /*arg*/) {
if (num_compactions_running.fetch_add(1) > 0) {
has_parallel.store(true);
return;
@ -784,7 +784,7 @@ TEST_P(DBTestUniversalCompactionParallel, UniversalCompactionParallel) {
});
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"CompactionJob::Run():End",
[&](void* arg) { num_compactions_running.fetch_add(-1); });
[&](void* /*arg*/) { num_compactions_running.fetch_add(-1); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
options = CurrentOptions(options);
@ -1154,7 +1154,7 @@ TEST_P(DBTestUniversalCompaction, UniversalCompactionTrivialMoveTest1) {
int32_t non_trivial_move = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:TrivialMove",
[&](void* arg) { trivial_move++; });
[&](void* /*arg*/) { trivial_move++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial", [&](void* arg) {
non_trivial_move++;
@ -1200,7 +1200,7 @@ TEST_P(DBTestUniversalCompaction, UniversalCompactionTrivialMoveTest2) {
int32_t trivial_move = 0;
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:TrivialMove",
[&](void* arg) { trivial_move++; });
[&](void* /*arg*/) { trivial_move++; });
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:NonTrivial", [&](void* arg) {
ASSERT_TRUE(arg != nullptr);
@ -1698,7 +1698,7 @@ TEST_P(DBTestUniversalCompaction, FullCompactionInBottomPriThreadPool) {
int num_bottom_pri_compactions = 0;
SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BGWorkBottomCompaction",
[&](void* arg) { ++num_bottom_pri_compactions; });
[&](void* /*arg*/) { ++num_bottom_pri_compactions; });
SyncPoint::GetInstance()->EnableProcessing();
Random rnd(301);
@ -1796,7 +1796,7 @@ TEST_P(DBTestUniversalCompaction, RecalculateScoreAfterPicking) {
std::atomic<int> num_compactions_attempted(0);
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:Start", [&](void* arg) {
"DBImpl::BackgroundCompaction:Start", [&](void* /*arg*/) {
++num_compactions_attempted;
});
rocksdb::SyncPoint::GetInstance()->EnableProcessing();

@ -8,7 +8,7 @@
namespace rocksdb {
namespace {
template<class T>
template <class T>
inline T SafeDivide(T a, T b) {
return b == 0 ? 0 : a / b;
}
@ -17,7 +17,8 @@ inline T SafeDivide(T a, T b) {
void EventHelpers::AppendCurrentTime(JSONWriter* jwriter) {
*jwriter << "time_micros"
<< std::chrono::duration_cast<std::chrono::microseconds>(
std::chrono::system_clock::now().time_since_epoch()).count();
std::chrono::system_clock::now().time_since_epoch())
.count();
}
#ifndef ROCKSDB_LITE
@ -52,6 +53,11 @@ void EventHelpers::NotifyOnBackgroundError(
listener->OnBackgroundError(reason, bg_error);
}
db_mutex->Lock();
#else
(void)listeners;
(void)reason;
(void)bg_error;
(void)db_mutex;
#endif // ROCKSDB_LITE
}
@ -117,20 +123,25 @@ void EventHelpers::LogAndNotifyTableFileCreationFinished(
for (auto& listener : listeners) {
listener->OnTableFileCreated(info);
}
#else
(void)listeners;
(void)db_name;
(void)cf_name;
(void)file_path;
(void)reason;
#endif // !ROCKSDB_LITE
}
void EventHelpers::LogAndNotifyTableFileDeletion(
EventLogger* event_logger, int job_id,
uint64_t file_number, const std::string& file_path,
const Status& status, const std::string& dbname,
EventLogger* event_logger, int job_id, uint64_t file_number,
const std::string& file_path, const Status& status,
const std::string& dbname,
const std::vector<std::shared_ptr<EventListener>>& listeners) {
JSONWriter jwriter;
AppendCurrentTime(&jwriter);
jwriter << "job" << job_id
<< "event" << "table_file_deletion"
jwriter << "job" << job_id << "event"
<< "table_file_deletion"
<< "file_number" << file_number;
if (!status.ok()) {
jwriter << "status" << status.ToString();
@ -149,6 +160,10 @@ void EventHelpers::LogAndNotifyTableFileDeletion(
for (auto& listener : listeners) {
listener->OnTableFileDeleted(info);
}
#else
(void)file_path;
(void)dbname;
(void)listeners;
#endif // !ROCKSDB_LITE
}

@ -30,12 +30,13 @@ Status PromoteL0(DB* db, ColumnFamilyHandle* column_family, int target_level) {
#else // ROCKSDB_LITE
Status SuggestCompactRange(DB* db, ColumnFamilyHandle* column_family,
const Slice* begin, const Slice* end) {
Status SuggestCompactRange(DB* /*db*/, ColumnFamilyHandle* /*column_family*/,
const Slice* /*begin*/, const Slice* /*end*/) {
return Status::NotSupported("Not supported in RocksDB LITE");
}
Status PromoteL0(DB* db, ColumnFamilyHandle* column_family, int target_level) {
Status PromoteL0(DB* /*db*/, ColumnFamilyHandle* /*column_family*/,
int /*target_level*/) {
return Status::NotSupported("Not supported in RocksDB LITE");
}

@ -689,7 +689,7 @@ TEST_F(ExternalSSTFileTest, PurgeObsoleteFilesBug) {
DestroyAndReopen(options);
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::AddFile:FileCopied", [&](void* arg) {
"DBImpl::AddFile:FileCopied", [&](void* /*arg*/) {
ASSERT_OK(Put("aaa", "bbb"));
ASSERT_OK(Flush());
ASSERT_OK(Put("aaa", "xxx"));
@ -1128,7 +1128,7 @@ TEST_F(ExternalSSTFileTest, PickedLevelBug) {
std::atomic<bool> bg_compact_started(false);
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BackgroundCompaction:Start",
[&](void* arg) { bg_compact_started.store(true); });
[&](void* /*arg*/) { bg_compact_started.store(true); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
@ -1409,7 +1409,7 @@ TEST_F(ExternalSSTFileTest, AddFileTrivialMoveBug) {
ASSERT_OK(GenerateAndAddExternalFile(options, {22, 23}, 6)); // L2
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"CompactionJob::Run():Start", [&](void* arg) {
"CompactionJob::Run():Start", [&](void* /*arg*/) {
// fit in L3 but will overlap with compaction so will be added
// to L2 but a compaction will trivially move it to L3
// and break LSM consistency

@ -456,10 +456,10 @@ TEST_P(FaultInjectionTest, UninstalledCompaction) {
std::atomic<bool> opened(false);
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::Open:Opened", [&](void* arg) { opened.store(true); });
"DBImpl::Open:Opened", [&](void* /*arg*/) { opened.store(true); });
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"DBImpl::BGWorkCompaction",
[&](void* arg) { ASSERT_TRUE(opened.load()); });
[&](void* /*arg*/) { ASSERT_TRUE(opened.load()); });
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
ASSERT_OK(OpenDB());
ASSERT_OK(Verify(0, kNumKeys, FaultInjectionTest::kValExpectFound));

@ -86,8 +86,7 @@ void PrepareLevelStats(std::map<LevelStatType, double>* level_stats,
const InternalStats::CompactionStats& stats) {
uint64_t bytes_read =
stats.bytes_read_non_output_levels + stats.bytes_read_output_level;
int64_t bytes_new =
stats.bytes_written - stats.bytes_read_output_level;
int64_t bytes_new = stats.bytes_written - stats.bytes_read_output_level;
double elapsed = (stats.micros + 1) / kMicrosInSec;
(*level_stats)[LevelStatType::NUM_FILES] = num_files;
@ -117,7 +116,8 @@ void PrepareLevelStats(std::map<LevelStatType, double>* level_stats,
void PrintLevelStats(char* buf, size_t len, const std::string& name,
const std::map<LevelStatType, double>& stat_value) {
snprintf(buf, len,
snprintf(
buf, len,
"%4s " /* Level */
"%6d/%-3d " /* Files */
"%8s " /* Size */
@ -136,8 +136,7 @@ void PrintLevelStats(char* buf, size_t len, const std::string& name,
"%8.3f " /* Avg(sec) */
"%7s " /* KeyIn */
"%6s\n", /* KeyDrop */
name.c_str(),
static_cast<int>(stat_value.at(LevelStatType::NUM_FILES)),
name.c_str(), static_cast<int>(stat_value.at(LevelStatType::NUM_FILES)),
static_cast<int>(stat_value.at(LevelStatType::COMPACTED_FILES)),
BytesToHumanString(
static_cast<uint64_t>(stat_value.at(LevelStatType::SIZE_BYTES)))
@ -158,8 +157,8 @@ void PrintLevelStats(char* buf, size_t len, const std::string& name,
NumberToHumanString(
static_cast<std::int64_t>(stat_value.at(LevelStatType::KEY_IN)))
.c_str(),
NumberToHumanString(static_cast<std::int64_t>(
stat_value.at(LevelStatType::KEY_DROP)))
NumberToHumanString(
static_cast<std::int64_t>(stat_value.at(LevelStatType::KEY_DROP)))
.c_str());
}
@ -882,8 +881,7 @@ void InternalStats::DumpDBStats(std::string* value) {
value->append(buf);
// Stall
AppendHumanMicros(write_stall_micros, human_micros, kHumanMicrosLen, true);
snprintf(buf, sizeof(buf),
"Cumulative stall: %s, %.1f percent\n",
snprintf(buf, sizeof(buf), "Cumulative stall: %s, %.1f percent\n",
human_micros,
// 10000 = divide by 1M to get secs, then multiply by 100 for pct
write_stall_micros / 10000.0 / std::max(seconds_up, 0.001));
@ -894,11 +892,11 @@ void InternalStats::DumpDBStats(std::string* value) {
uint64_t interval_write_self = write_self - db_stats_snapshot_.write_self;
uint64_t interval_num_keys_written =
num_keys_written - db_stats_snapshot_.num_keys_written;
snprintf(buf, sizeof(buf),
snprintf(
buf, sizeof(buf),
"Interval writes: %s writes, %s keys, %s commit groups, "
"%.1f writes per commit group, ingest: %.2f MB, %.2f MB/s\n",
NumberToHumanString(
interval_write_other + interval_write_self).c_str(),
NumberToHumanString(interval_write_other + interval_write_self).c_str(),
NumberToHumanString(interval_num_keys_written).c_str(),
NumberToHumanString(interval_write_self).c_str(),
static_cast<double>(interval_write_other + interval_write_self) /
@ -913,24 +911,21 @@ void InternalStats::DumpDBStats(std::string* value) {
uint64_t interval_wal_synced = wal_synced - db_stats_snapshot_.wal_synced;
uint64_t interval_wal_bytes = wal_bytes - db_stats_snapshot_.wal_bytes;
snprintf(buf, sizeof(buf),
snprintf(
buf, sizeof(buf),
"Interval WAL: %s writes, %s syncs, "
"%.2f writes per sync, written: %.2f MB, %.2f MB/s\n",
NumberToHumanString(interval_write_with_wal).c_str(),
NumberToHumanString(interval_wal_synced).c_str(),
interval_write_with_wal /
static_cast<double>(interval_wal_synced + 1),
interval_write_with_wal / static_cast<double>(interval_wal_synced + 1),
interval_wal_bytes / kGB,
interval_wal_bytes / kMB / std::max(interval_seconds_up, 0.001));
value->append(buf);
// Stall
AppendHumanMicros(
write_stall_micros - db_stats_snapshot_.write_stall_micros,
AppendHumanMicros(write_stall_micros - db_stats_snapshot_.write_stall_micros,
human_micros, kHumanMicrosLen, true);
snprintf(buf, sizeof(buf),
"Interval stall: %s, %.1f percent\n",
human_micros,
snprintf(buf, sizeof(buf), "Interval stall: %s, %.1f percent\n", human_micros,
// 10000 = divide by 1M to get secs, then multiply by 100 for pct
(write_stall_micros - db_stats_snapshot_.write_stall_micros) /
10000.0 / std::max(interval_seconds_up, 0.001));
@ -1143,8 +1138,9 @@ void InternalStats::DumpCFStatsNoFileHistogram(std::string* value) {
uint64_t interval_ingest_files_addfile =
ingest_files_addfile - cf_stats_snapshot_.ingest_files_addfile;
snprintf(buf, sizeof(buf), "AddFile(Total Files): cumulative %" PRIu64
", interval %" PRIu64 "\n",
snprintf(buf, sizeof(buf),
"AddFile(Total Files): cumulative %" PRIu64 ", interval %" PRIu64
"\n",
ingest_files_addfile, interval_ingest_files_addfile);
value->append(buf);
@ -1262,7 +1258,9 @@ void InternalStats::DumpCFFileHistogram(std::string* value) {
#else
const DBPropertyInfo* GetPropertyInfo(const Slice& property) { return nullptr; }
const DBPropertyInfo* GetPropertyInfo(const Slice& /*property*/) {
return nullptr;
}
#endif // !ROCKSDB_LITE

@ -580,7 +580,7 @@ class InternalStats {
INTERNAL_DB_STATS_ENUM_MAX,
};
InternalStats(int num_levels, Env* env, ColumnFamilyData* cfd) {}
InternalStats(int /*num_levels*/, Env* /*env*/, ColumnFamilyData* /*cfd*/) {}
struct CompactionStats {
uint64_t micros;
@ -597,48 +597,48 @@ class InternalStats {
explicit CompactionStats() {}
explicit CompactionStats(CompactionReason reason, int c) {}
explicit CompactionStats(CompactionReason /*reason*/, int /*c*/) {}
explicit CompactionStats(const CompactionStats& c) {}
explicit CompactionStats(const CompactionStats& /*c*/) {}
void Add(const CompactionStats& c) {}
void Add(const CompactionStats& /*c*/) {}
void Subtract(const CompactionStats& c) {}
void Subtract(const CompactionStats& /*c*/) {}
};
void AddCompactionStats(int level, const CompactionStats& stats) {}
void AddCompactionStats(int /*level*/, const CompactionStats& /*stats*/) {}
void IncBytesMoved(int level, uint64_t amount) {}
void IncBytesMoved(int /*level*/, uint64_t /*amount*/) {}
void AddCFStats(InternalCFStatsType type, uint64_t value) {}
void AddCFStats(InternalCFStatsType /*type*/, uint64_t /*value*/) {}
void AddDBStats(InternalDBStatsType type, uint64_t value,
bool concurrent = false) {}
void AddDBStats(InternalDBStatsType /*type*/, uint64_t /*value*/,
bool /*concurrent */ = false) {}
HistogramImpl* GetFileReadHist(int level) { return nullptr; }
HistogramImpl* GetFileReadHist(int /*level*/) { return nullptr; }
uint64_t GetBackgroundErrorCount() const { return 0; }
uint64_t BumpAndGetBackgroundErrorCount() { return 0; }
bool GetStringProperty(const DBPropertyInfo& property_info,
const Slice& property, std::string* value) {
bool GetStringProperty(const DBPropertyInfo& /*property_info*/,
const Slice& /*property*/, std::string* /*value*/) {
return false;
}
bool GetMapProperty(const DBPropertyInfo& property_info,
const Slice& property,
std::map<std::string, std::string>* value) {
bool GetMapProperty(const DBPropertyInfo& /*property_info*/,
const Slice& /*property*/,
std::map<std::string, std::string>* /*value*/) {
return false;
}
bool GetIntProperty(const DBPropertyInfo& property_info, uint64_t* value,
DBImpl* db) const {
bool GetIntProperty(const DBPropertyInfo& /*property_info*/, uint64_t* /*value*/,
DBImpl* /*db*/) const {
return false;
}
bool GetIntPropertyOutOfMutex(const DBPropertyInfo& property_info,
Version* version, uint64_t* value) const {
bool GetIntPropertyOutOfMutex(const DBPropertyInfo& /*property_info*/,
Version* /*version*/, uint64_t* /*value*/) const {
return false;
}
};

@ -52,6 +52,11 @@ struct SuperVersionContext {
notif.write_stall_info.condition.cur = new_cond;
notif.immutable_cf_options = ioptions;
write_stall_notifications.push_back(notif);
#else
(void)old_cond;
(void)new_cond;
(void)name;
(void)ioptions;
#endif // !ROCKSDB_LITE
}

@ -135,6 +135,9 @@ class FilePicker {
file_indexer_(file_indexer),
user_comparator_(user_comparator),
internal_comparator_(internal_comparator) {
#ifdef NDEBUG
(void)files;
#endif
// Setup member variables to search first level.
search_ended_ = !PrepareNextLevel();
if (!search_ended_) {
@ -1764,6 +1767,8 @@ void VersionStorageInfo::AddFile(int level, FileMetaData* f, Logger* info_log) {
}
assert(false);
}
#else
(void)info_log;
#endif
f->refs++;
level_files->push_back(f);
@ -3028,6 +3033,9 @@ void VersionSet::LogAndApplyCFHelper(VersionEdit* edit) {
void VersionSet::LogAndApplyHelper(ColumnFamilyData* cfd,
VersionBuilder* builder, Version* /*v*/,
VersionEdit* edit, InstrumentedMutex* mu) {
#ifdef NDEBUG
(void)cfd;
#endif
mu->AssertHeld();
assert(!edit->IsColumnFamilyManipulation());
@ -4070,6 +4078,8 @@ bool VersionSet::VerifyCompactionFileConsistency(Compaction* c) {
}
}
}
#else
(void)c;
#endif
return true; // everything good
}

@ -1716,6 +1716,9 @@ Status WriteBatchInternal::InsertInto(
ColumnFamilyMemTables* memtables, FlushScheduler* flush_scheduler,
bool ignore_missing_column_families, uint64_t log_number, DB* db,
bool concurrent_memtable_writes, bool seq_per_batch, size_t batch_cnt) {
#ifdef NDEBUG
(void)batch_cnt;
#endif
assert(writer->ShouldWriteToMemtable());
MemTableInserter inserter(sequence, memtables, flush_scheduler,
ignore_missing_column_families, log_number, db,

3
env/env_posix.cc vendored

@ -799,6 +799,8 @@ class PosixEnv : public Env {
assert(pool >= Priority::BOTTOM && pool <= Priority::HIGH);
#ifdef OS_LINUX
thread_pools_[pool].LowerIOPriority();
#else
(void)pool;
#endif
}
@ -876,6 +878,7 @@ class PosixEnv : public Env {
return false;
}
#else
(void)path;
return false;
#endif
}

4
env/env_test.cc vendored

@ -1523,7 +1523,7 @@ class TestEnv : public EnvWrapper {
CloseHelper();
}
}
virtual void Logv(const char* format, va_list ap) override{};
virtual void Logv(const char* /*format*/, va_list /*ap*/) override{};
protected:
virtual Status CloseImpl() override { return CloseHelper(); }
@ -1540,7 +1540,7 @@ class TestEnv : public EnvWrapper {
int GetCloseCount() { return close_count; }
virtual Status NewLogger(const std::string& fname,
virtual Status NewLogger(const std::string& /*fname*/,
shared_ptr<Logger>* result) {
result->reset(new TestLogger(this));
return Status::OK();

21
env/io_posix.cc vendored

@ -48,6 +48,10 @@ int Fadvise(int fd, off_t offset, size_t len, int advice) {
#ifdef OS_LINUX
return posix_fadvise(fd, offset, len, advice);
#else
(void)fd;
(void)offset;
(void)len;
(void)advice;
return 0; // simply do nothing.
#endif
}
@ -227,6 +231,8 @@ Status PosixSequentialFile::Skip(uint64_t n) {
Status PosixSequentialFile::InvalidateCache(size_t offset, size_t length) {
#ifndef OS_LINUX
(void)offset;
(void)length;
return Status::OK();
#else
if (!use_direct_io()) {
@ -410,6 +416,8 @@ Status PosixRandomAccessFile::InvalidateCache(size_t offset, size_t length) {
return Status::OK();
}
#ifndef OS_LINUX
(void)offset;
(void)length;
return Status::OK();
#else
// free OS pages
@ -434,6 +442,9 @@ PosixMmapReadableFile::PosixMmapReadableFile(const int fd,
void* base, size_t length,
const EnvOptions& options)
: fd_(fd), filename_(fname), mmapped_region_(base), length_(length) {
#ifdef NDEBUG
(void)options;
#endif
fd_ = fd_ + 0; // suppress the warning for used variables
assert(options.use_mmap_reads);
assert(!options.use_direct_reads);
@ -464,6 +475,8 @@ Status PosixMmapReadableFile::Read(uint64_t offset, size_t n, Slice* result,
Status PosixMmapReadableFile::InvalidateCache(size_t offset, size_t length) {
#ifndef OS_LINUX
(void)offset;
(void)length;
return Status::OK();
#else
// free OS pages
@ -572,6 +585,8 @@ PosixMmapFile::PosixMmapFile(const std::string& fname, int fd, size_t page_size,
#ifdef ROCKSDB_FALLOCATE_PRESENT
allow_fallocate_ = options.allow_fallocate;
fallocate_with_keep_size_ = options.fallocate_with_keep_size;
#else
(void)options;
#endif
assert((page_size & (page_size - 1)) == 0);
assert(options.use_mmap_writes);
@ -672,6 +687,8 @@ uint64_t PosixMmapFile::GetFileSize() {
Status PosixMmapFile::InvalidateCache(size_t offset, size_t length) {
#ifndef OS_LINUX
(void)offset;
(void)length;
return Status::OK();
#else
// free OS pages
@ -874,6 +891,8 @@ void PosixWritableFile::SetWriteLifeTimeHint(Env::WriteLifeTimeHint hint) {
write_hint_ = hint;
}
#endif
#else
(void)hint;
#endif
}
@ -882,6 +901,8 @@ Status PosixWritableFile::InvalidateCache(size_t offset, size_t length) {
return Status::OK();
}
#ifndef OS_LINUX
(void)offset;
(void)length;
return Status::OK();
#else
// free OS pages

72
env/mock_env.cc vendored

@ -72,9 +72,7 @@ class MemFile {
}
}
uint64_t Size() const {
return size_;
}
uint64_t Size() const { return size_; }
void Truncate(size_t size) {
MutexLock lock(&mutex_);
@ -143,9 +141,7 @@ class MemFile {
return Status::OK();
}
uint64_t ModifiedTime() const {
return modified_time_;
}
uint64_t ModifiedTime() const { return modified_time_; }
private:
uint64_t Now() {
@ -156,9 +152,7 @@ class MemFile {
}
// Private since only Unref() should be used to delete it.
~MemFile() {
assert(refs_ == 0);
}
~MemFile() { assert(refs_ == 0); }
// No copying allowed.
MemFile(const MemFile&);
@ -189,9 +183,7 @@ class MockSequentialFile : public SequentialFile {
file_->Ref();
}
~MockSequentialFile() {
file_->Unref();
}
~MockSequentialFile() { file_->Unref(); }
virtual Status Read(size_t n, Slice* result, char* scratch) override {
Status s = file_->Read(pos_, n, result, scratch);
@ -220,13 +212,9 @@ class MockSequentialFile : public SequentialFile {
class MockRandomAccessFile : public RandomAccessFile {
public:
explicit MockRandomAccessFile(MemFile* file) : file_(file) {
file_->Ref();
}
explicit MockRandomAccessFile(MemFile* file) : file_(file) { file_->Ref(); }
~MockRandomAccessFile() {
file_->Unref();
}
~MockRandomAccessFile() { file_->Unref(); }
virtual Status Read(uint64_t offset, size_t n, Slice* result,
char* scratch) const override {
@ -265,14 +253,11 @@ class MockRandomRWFile : public RandomRWFile {
class MockWritableFile : public WritableFile {
public:
MockWritableFile(MemFile* file, RateLimiter* rate_limiter)
: file_(file),
rate_limiter_(rate_limiter) {
: file_(file), rate_limiter_(rate_limiter) {
file_->Ref();
}
~MockWritableFile() {
file_->Unref();
}
~MockWritableFile() { file_->Unref(); }
virtual Status Append(const Slice& data) override {
size_t bytes_written = 0;
@ -301,8 +286,8 @@ class MockWritableFile : public WritableFile {
private:
inline size_t RequestToken(size_t bytes) {
if (rate_limiter_ && io_priority_ < Env::IO_TOTAL) {
bytes = std::min(bytes,
static_cast<size_t>(rate_limiter_->GetSingleBurstBytes()));
bytes = std::min(
bytes, static_cast<size_t>(rate_limiter_->GetSingleBurstBytes()));
rate_limiter_->Request(bytes, io_priority_);
}
return bytes;
@ -319,12 +304,9 @@ class MockEnvDirectory : public Directory {
class MockEnvFileLock : public FileLock {
public:
explicit MockEnvFileLock(const std::string& fname)
: fname_(fname) {}
explicit MockEnvFileLock(const std::string& fname) : fname_(fname) {}
std::string FileName() const {
return fname_;
}
std::string FileName() const { return fname_; }
private:
const std::string fname_;
@ -348,8 +330,7 @@ class TestMemLogger : public Logger {
last_flush_micros_(0),
env_(env),
flush_pending_(false) {}
virtual ~TestMemLogger() {
}
virtual ~TestMemLogger() {}
virtual void Flush() override {
if (flush_pending_) {
@ -384,15 +365,9 @@ class TestMemLogger : public Logger {
struct tm* ret __attribute__((__unused__));
ret = localtime_r(&seconds, &t);
assert(ret);
p += snprintf(p, limit - p,
"%04d/%02d/%02d-%02d:%02d:%02d.%06d ",
t.tm_year + 1900,
t.tm_mon + 1,
t.tm_mday,
t.tm_hour,
t.tm_min,
t.tm_sec,
static_cast<int>(now_tv.tv_usec));
p += snprintf(p, limit - p, "%04d/%02d/%02d-%02d:%02d:%02d.%06d ",
t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, t.tm_hour,
t.tm_min, t.tm_sec, static_cast<int>(now_tv.tv_usec));
// Print the message
if (p < limit) {
@ -422,8 +397,8 @@ class TestMemLogger : public Logger {
file_->Append(Slice(base, write_size));
flush_pending_ = true;
log_size_ += write_size;
uint64_t now_micros = static_cast<uint64_t>(now_tv.tv_sec) * 1000000 +
now_tv.tv_usec;
uint64_t now_micros =
static_cast<uint64_t>(now_tv.tv_sec) * 1000000 + now_tv.tv_usec;
if (now_micros - last_flush_micros_ >= flush_every_seconds_ * 1000000) {
flush_pending_ = false;
last_flush_micros_ = now_micros;
@ -447,7 +422,7 @@ MockEnv::~MockEnv() {
}
}
// Partial implementation of the Env interface.
// Partial implementation of the Env interface.
Status MockEnv::NewSequentialFile(const std::string& fname,
unique_ptr<SequentialFile>* result,
const EnvOptions& /*soptions*/) {
@ -543,8 +518,7 @@ Status MockEnv::FileExists(const std::string& fname) {
// Now also check if fn exists as a dir
for (const auto& iter : file_map_) {
const std::string& filename = iter.first;
if (filename.size() >= fn.size() + 1 &&
filename[fn.size()] == '/' &&
if (filename.size() >= fn.size() + 1 && filename[fn.size()] == '/' &&
Slice(filename).starts_with(Slice(fn))) {
return Status::OK();
}
@ -569,8 +543,8 @@ Status MockEnv::GetChildren(const std::string& dir,
found_dir = true;
size_t next_slash = filename.find('/', d.size() + 1);
if (next_slash != std::string::npos) {
result->push_back(filename.substr(
d.size() + 1, next_slash - d.size() - 1));
result->push_back(
filename.substr(d.size() + 1, next_slash - d.size() - 1));
} else {
result->push_back(filename.substr(d.size() + 1));
}
@ -795,7 +769,7 @@ Env* NewMemEnv(Env* base_env) { return new MockEnv(base_env); }
#else // ROCKSDB_LITE
Env* NewMemEnv(Env* base_env) { return nullptr; }
Env* NewMemEnv(Env* /*base_env*/) { return nullptr; }
#endif // !ROCKSDB_LITE

@ -803,7 +803,7 @@ class Directory {
// Fsync directory. Can be called concurrently from multiple threads.
virtual Status Fsync() = 0;
virtual size_t GetUniqueId(char* id, size_t max_size) const {
virtual size_t GetUniqueId(char* /*id*/, size_t /*max_size*/) const {
return 0;
}
};

@ -168,8 +168,8 @@ class RocksLuaCompactionFilter : public rocksdb::CompactionFilter {
std::string* new_value,
bool* value_changed) const override;
// Not yet supported
virtual bool FilterMergeOperand(int level, const Slice& key,
const Slice& operand) const override {
virtual bool FilterMergeOperand(int /*level*/, const Slice& /*key*/,
const Slice& /*operand*/) const override {
return false;
}
virtual bool IgnoreSnapshots() const override;

@ -36,7 +36,7 @@ class RocksLuaCustomLibrary {
// and pushed on the top of the lua_State. This custom setup function
// allows developers to put additional table or constant values inside
// the same table / namespace.
virtual void CustomSetup(lua_State* L) const {}
virtual void CustomSetup(lua_State* /*L*/) const {}
};
} // namespace lua
} // namespace rocksdb

@ -7,15 +7,15 @@
// calling c++ rocksdb::BackupEnginge and rocksdb::BackupableDBOptions methods
// from Java side.
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <jni.h>
#include <string>
#include <vector>
#include "include/org_rocksdb_BackupableDBOptions.h"
#include "rocksjni/portal.h"
#include "rocksdb/utilities/backupable_db.h"
#include "rocksjni/portal.h"
///////////////////////////////////////////////////////////////////////////
// BackupDBOptions
@ -26,9 +26,9 @@
* Signature: (Ljava/lang/String;)J
*/
jlong Java_org_rocksdb_BackupableDBOptions_newBackupableDBOptions(
JNIEnv* env, jclass jcls, jstring jpath) {
JNIEnv* env, jclass /*jcls*/, jstring jpath) {
const char* cpath = env->GetStringUTFChars(jpath, nullptr);
if(cpath == nullptr) {
if (cpath == nullptr) {
// exception thrown: OutOfMemoryError
return 0;
}
@ -42,8 +42,9 @@ jlong Java_org_rocksdb_BackupableDBOptions_newBackupableDBOptions(
* Method: backupDir
* Signature: (J)Ljava/lang/String;
*/
jstring Java_org_rocksdb_BackupableDBOptions_backupDir(
JNIEnv* env, jobject jopt, jlong jhandle) {
jstring Java_org_rocksdb_BackupableDBOptions_backupDir(JNIEnv* env,
jobject /*jopt*/,
jlong jhandle) {
auto* bopt = reinterpret_cast<rocksdb::BackupableDBOptions*>(jhandle);
return env->NewStringUTF(bopt->backup_dir.c_str());
}
@ -54,7 +55,7 @@ jstring Java_org_rocksdb_BackupableDBOptions_backupDir(
* Signature: (JJ)V
*/
void Java_org_rocksdb_BackupableDBOptions_setBackupEnv(
JNIEnv* env, jobject jopt, jlong jhandle, jlong jrocks_env_handle) {
JNIEnv* /*env*/, jobject /*jopt*/, jlong jhandle, jlong jrocks_env_handle) {
auto* bopt = reinterpret_cast<rocksdb::BackupableDBOptions*>(jhandle);
auto* rocks_env = reinterpret_cast<rocksdb::Env*>(jrocks_env_handle);
bopt->backup_env = rocks_env;
@ -65,8 +66,10 @@ void Java_org_rocksdb_BackupableDBOptions_setBackupEnv(
* Method: setShareTableFiles
* Signature: (JZ)V
*/
void Java_org_rocksdb_BackupableDBOptions_setShareTableFiles(
JNIEnv* env, jobject jobj, jlong jhandle, jboolean flag) {
void Java_org_rocksdb_BackupableDBOptions_setShareTableFiles(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle,
jboolean flag) {
auto* bopt = reinterpret_cast<rocksdb::BackupableDBOptions*>(jhandle);
bopt->share_table_files = flag;
}
@ -76,8 +79,9 @@ void Java_org_rocksdb_BackupableDBOptions_setShareTableFiles(
* Method: shareTableFiles
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_BackupableDBOptions_shareTableFiles(
JNIEnv* env, jobject jobj, jlong jhandle) {
jboolean Java_org_rocksdb_BackupableDBOptions_shareTableFiles(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* bopt = reinterpret_cast<rocksdb::BackupableDBOptions*>(jhandle);
return bopt->share_table_files;
}
@ -87,11 +91,13 @@ jboolean Java_org_rocksdb_BackupableDBOptions_shareTableFiles(
* Method: setInfoLog
* Signature: (JJ)V
*/
void Java_org_rocksdb_BackupableDBOptions_setInfoLog(
JNIEnv* env, jobject jobj, jlong jhandle, jlong jlogger_handle) {
void Java_org_rocksdb_BackupableDBOptions_setInfoLog(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle,
jlong /*jlogger_handle*/) {
auto* bopt = reinterpret_cast<rocksdb::BackupableDBOptions*>(jhandle);
auto* sptr_logger =
reinterpret_cast<std::shared_ptr<rocksdb::LoggerJniCallback> *>(jhandle);
reinterpret_cast<std::shared_ptr<rocksdb::LoggerJniCallback>*>(jhandle);
bopt->info_log = sptr_logger->get();
}
@ -100,8 +106,10 @@ void Java_org_rocksdb_BackupableDBOptions_setInfoLog(
* Method: setSync
* Signature: (JZ)V
*/
void Java_org_rocksdb_BackupableDBOptions_setSync(
JNIEnv* env, jobject jobj, jlong jhandle, jboolean flag) {
void Java_org_rocksdb_BackupableDBOptions_setSync(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle,
jboolean flag) {
auto* bopt = reinterpret_cast<rocksdb::BackupableDBOptions*>(jhandle);
bopt->sync = flag;
}
@ -111,8 +119,9 @@ void Java_org_rocksdb_BackupableDBOptions_setSync(
* Method: sync
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_BackupableDBOptions_sync(
JNIEnv* env, jobject jobj, jlong jhandle) {
jboolean Java_org_rocksdb_BackupableDBOptions_sync(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* bopt = reinterpret_cast<rocksdb::BackupableDBOptions*>(jhandle);
return bopt->sync;
}
@ -122,8 +131,10 @@ jboolean Java_org_rocksdb_BackupableDBOptions_sync(
* Method: setDestroyOldData
* Signature: (JZ)V
*/
void Java_org_rocksdb_BackupableDBOptions_setDestroyOldData(
JNIEnv* env, jobject jobj, jlong jhandle, jboolean flag) {
void Java_org_rocksdb_BackupableDBOptions_setDestroyOldData(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle,
jboolean flag) {
auto* bopt = reinterpret_cast<rocksdb::BackupableDBOptions*>(jhandle);
bopt->destroy_old_data = flag;
}
@ -133,8 +144,9 @@ void Java_org_rocksdb_BackupableDBOptions_setDestroyOldData(
* Method: destroyOldData
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_BackupableDBOptions_destroyOldData(
JNIEnv* env, jobject jobj, jlong jhandle) {
jboolean Java_org_rocksdb_BackupableDBOptions_destroyOldData(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* bopt = reinterpret_cast<rocksdb::BackupableDBOptions*>(jhandle);
return bopt->destroy_old_data;
}
@ -144,8 +156,10 @@ jboolean Java_org_rocksdb_BackupableDBOptions_destroyOldData(
* Method: setBackupLogFiles
* Signature: (JZ)V
*/
void Java_org_rocksdb_BackupableDBOptions_setBackupLogFiles(
JNIEnv* env, jobject jobj, jlong jhandle, jboolean flag) {
void Java_org_rocksdb_BackupableDBOptions_setBackupLogFiles(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle,
jboolean flag) {
auto* bopt = reinterpret_cast<rocksdb::BackupableDBOptions*>(jhandle);
bopt->backup_log_files = flag;
}
@ -155,8 +169,9 @@ void Java_org_rocksdb_BackupableDBOptions_setBackupLogFiles(
* Method: backupLogFiles
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_BackupableDBOptions_backupLogFiles(
JNIEnv* env, jobject jobj, jlong jhandle) {
jboolean Java_org_rocksdb_BackupableDBOptions_backupLogFiles(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* bopt = reinterpret_cast<rocksdb::BackupableDBOptions*>(jhandle);
return bopt->backup_log_files;
}
@ -167,7 +182,8 @@ jboolean Java_org_rocksdb_BackupableDBOptions_backupLogFiles(
* Signature: (JJ)V
*/
void Java_org_rocksdb_BackupableDBOptions_setBackupRateLimit(
JNIEnv* env, jobject jobj, jlong jhandle, jlong jbackup_rate_limit) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jlong jbackup_rate_limit) {
auto* bopt = reinterpret_cast<rocksdb::BackupableDBOptions*>(jhandle);
bopt->backup_rate_limit = jbackup_rate_limit;
}
@ -177,8 +193,9 @@ void Java_org_rocksdb_BackupableDBOptions_setBackupRateLimit(
* Method: backupRateLimit
* Signature: (J)J
*/
jlong Java_org_rocksdb_BackupableDBOptions_backupRateLimit(
JNIEnv* env, jobject jobj, jlong jhandle) {
jlong Java_org_rocksdb_BackupableDBOptions_backupRateLimit(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* bopt = reinterpret_cast<rocksdb::BackupableDBOptions*>(jhandle);
return bopt->backup_rate_limit;
}
@ -189,10 +206,12 @@ jlong Java_org_rocksdb_BackupableDBOptions_backupRateLimit(
* Signature: (JJ)V
*/
void Java_org_rocksdb_BackupableDBOptions_setBackupRateLimiter(
JNIEnv* env, jobject jobj, jlong jhandle, jlong jrate_limiter_handle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jlong jrate_limiter_handle) {
auto* bopt = reinterpret_cast<rocksdb::BackupableDBOptions*>(jhandle);
auto* sptr_rate_limiter =
reinterpret_cast<std::shared_ptr<rocksdb::RateLimiter> *>(jrate_limiter_handle);
reinterpret_cast<std::shared_ptr<rocksdb::RateLimiter>*>(
jrate_limiter_handle);
bopt->backup_rate_limiter = *sptr_rate_limiter;
}
@ -202,7 +221,8 @@ void Java_org_rocksdb_BackupableDBOptions_setBackupRateLimiter(
* Signature: (JJ)V
*/
void Java_org_rocksdb_BackupableDBOptions_setRestoreRateLimit(
JNIEnv* env, jobject jobj, jlong jhandle, jlong jrestore_rate_limit) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jlong jrestore_rate_limit) {
auto* bopt = reinterpret_cast<rocksdb::BackupableDBOptions*>(jhandle);
bopt->restore_rate_limit = jrestore_rate_limit;
}
@ -212,8 +232,9 @@ void Java_org_rocksdb_BackupableDBOptions_setRestoreRateLimit(
* Method: restoreRateLimit
* Signature: (J)J
*/
jlong Java_org_rocksdb_BackupableDBOptions_restoreRateLimit(
JNIEnv* env, jobject jobj, jlong jhandle) {
jlong Java_org_rocksdb_BackupableDBOptions_restoreRateLimit(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* bopt = reinterpret_cast<rocksdb::BackupableDBOptions*>(jhandle);
return bopt->restore_rate_limit;
}
@ -224,10 +245,12 @@ jlong Java_org_rocksdb_BackupableDBOptions_restoreRateLimit(
* Signature: (JJ)V
*/
void Java_org_rocksdb_BackupableDBOptions_setRestoreRateLimiter(
JNIEnv* env, jobject jobj, jlong jhandle, jlong jrate_limiter_handle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jlong jrate_limiter_handle) {
auto* bopt = reinterpret_cast<rocksdb::BackupableDBOptions*>(jhandle);
auto* sptr_rate_limiter =
reinterpret_cast<std::shared_ptr<rocksdb::RateLimiter> *>(jrate_limiter_handle);
reinterpret_cast<std::shared_ptr<rocksdb::RateLimiter>*>(
jrate_limiter_handle);
bopt->restore_rate_limiter = *sptr_rate_limiter;
}
@ -237,7 +260,7 @@ void Java_org_rocksdb_BackupableDBOptions_setRestoreRateLimiter(
* Signature: (JZ)V
*/
void Java_org_rocksdb_BackupableDBOptions_setShareFilesWithChecksum(
JNIEnv* env, jobject jobj, jlong jhandle, jboolean flag) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jboolean flag) {
auto* bopt = reinterpret_cast<rocksdb::BackupableDBOptions*>(jhandle);
bopt->share_files_with_checksum = flag;
}
@ -248,7 +271,7 @@ void Java_org_rocksdb_BackupableDBOptions_setShareFilesWithChecksum(
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_BackupableDBOptions_shareFilesWithChecksum(
JNIEnv* env, jobject jobj, jlong jhandle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
auto* bopt = reinterpret_cast<rocksdb::BackupableDBOptions*>(jhandle);
return bopt->share_files_with_checksum;
}
@ -259,10 +282,10 @@ jboolean Java_org_rocksdb_BackupableDBOptions_shareFilesWithChecksum(
* Signature: (JI)V
*/
void Java_org_rocksdb_BackupableDBOptions_setMaxBackgroundOperations(
JNIEnv* env, jobject jobj, jlong jhandle, jint max_background_operations) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jint max_background_operations) {
auto* bopt = reinterpret_cast<rocksdb::BackupableDBOptions*>(jhandle);
bopt->max_background_operations =
static_cast<int>(max_background_operations);
bopt->max_background_operations = static_cast<int>(max_background_operations);
}
/*
@ -271,7 +294,7 @@ void Java_org_rocksdb_BackupableDBOptions_setMaxBackgroundOperations(
* Signature: (J)I
*/
jint Java_org_rocksdb_BackupableDBOptions_maxBackgroundOperations(
JNIEnv* env, jobject jobj, jlong jhandle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
auto* bopt = reinterpret_cast<rocksdb::BackupableDBOptions*>(jhandle);
return static_cast<jint>(bopt->max_background_operations);
}
@ -282,7 +305,7 @@ jint Java_org_rocksdb_BackupableDBOptions_maxBackgroundOperations(
* Signature: (JJ)V
*/
void Java_org_rocksdb_BackupableDBOptions_setCallbackTriggerIntervalSize(
JNIEnv* env, jobject jobj, jlong jhandle,
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jlong jcallback_trigger_interval_size) {
auto* bopt = reinterpret_cast<rocksdb::BackupableDBOptions*>(jhandle);
bopt->callback_trigger_interval_size =
@ -295,7 +318,7 @@ void Java_org_rocksdb_BackupableDBOptions_setCallbackTriggerIntervalSize(
* Signature: (J)J
*/
jlong Java_org_rocksdb_BackupableDBOptions_callbackTriggerIntervalSize(
JNIEnv* env, jobject jobj, jlong jhandle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
auto* bopt = reinterpret_cast<rocksdb::BackupableDBOptions*>(jhandle);
return static_cast<jlong>(bopt->callback_trigger_interval_size);
}
@ -305,8 +328,9 @@ jlong Java_org_rocksdb_BackupableDBOptions_callbackTriggerIntervalSize(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_BackupableDBOptions_disposeInternal(
JNIEnv* env, jobject jopt, jlong jhandle) {
void Java_org_rocksdb_BackupableDBOptions_disposeInternal(JNIEnv* /*env*/,
jobject /*jopt*/,
jlong jhandle) {
auto* bopt = reinterpret_cast<rocksdb::BackupableDBOptions*>(jhandle);
assert(bopt != nullptr);
delete bopt;

@ -18,16 +18,15 @@
* Method: open
* Signature: (JJ)J
*/
jlong Java_org_rocksdb_BackupEngine_open(
JNIEnv* env, jclass jcls, jlong env_handle,
jlong Java_org_rocksdb_BackupEngine_open(JNIEnv* env, jclass /*jcls*/,
jlong env_handle,
jlong backupable_db_options_handle) {
auto* rocks_env = reinterpret_cast<rocksdb::Env*>(env_handle);
auto* backupable_db_options =
reinterpret_cast<rocksdb::BackupableDBOptions*>(
auto* backupable_db_options = reinterpret_cast<rocksdb::BackupableDBOptions*>(
backupable_db_options_handle);
rocksdb::BackupEngine* backup_engine;
auto status = rocksdb::BackupEngine::Open(rocks_env,
*backupable_db_options, &backup_engine);
auto status = rocksdb::BackupEngine::Open(rocks_env, *backupable_db_options,
&backup_engine);
if (status.ok()) {
return reinterpret_cast<jlong>(backup_engine);
@ -43,12 +42,12 @@ jlong Java_org_rocksdb_BackupEngine_open(
* Signature: (JJZ)V
*/
void Java_org_rocksdb_BackupEngine_createNewBackup(
JNIEnv* env, jobject jbe, jlong jbe_handle, jlong db_handle,
JNIEnv* env, jobject /*jbe*/, jlong jbe_handle, jlong db_handle,
jboolean jflush_before_backup) {
auto* db = reinterpret_cast<rocksdb::DB*>(db_handle);
auto* backup_engine = reinterpret_cast<rocksdb::BackupEngine*>(jbe_handle);
auto status = backup_engine->CreateNewBackup(db,
static_cast<bool>(jflush_before_backup));
auto status = backup_engine->CreateNewBackup(
db, static_cast<bool>(jflush_before_backup));
if (status.ok()) {
return;
@ -62,8 +61,9 @@ void Java_org_rocksdb_BackupEngine_createNewBackup(
* Method: getBackupInfo
* Signature: (J)Ljava/util/List;
*/
jobject Java_org_rocksdb_BackupEngine_getBackupInfo(
JNIEnv* env, jobject jbe, jlong jbe_handle) {
jobject Java_org_rocksdb_BackupEngine_getBackupInfo(JNIEnv* env,
jobject /*jbe*/,
jlong jbe_handle) {
auto* backup_engine = reinterpret_cast<rocksdb::BackupEngine*>(jbe_handle);
std::vector<rocksdb::BackupInfo> backup_infos;
backup_engine->GetBackupInfo(&backup_infos);
@ -75,8 +75,9 @@ jobject Java_org_rocksdb_BackupEngine_getBackupInfo(
* Method: getCorruptedBackups
* Signature: (J)[I
*/
jintArray Java_org_rocksdb_BackupEngine_getCorruptedBackups(
JNIEnv* env, jobject jbe, jlong jbe_handle) {
jintArray Java_org_rocksdb_BackupEngine_getCorruptedBackups(JNIEnv* env,
jobject /*jbe*/,
jlong jbe_handle) {
auto* backup_engine = reinterpret_cast<rocksdb::BackupEngine*>(jbe_handle);
std::vector<rocksdb::BackupID> backup_ids;
backup_engine->GetCorruptedBackups(&backup_ids);
@ -87,7 +88,7 @@ jintArray Java_org_rocksdb_BackupEngine_getCorruptedBackups(
// Its ok to loose precision here (64->32)
jsize ret_backup_ids_size = static_cast<jsize>(backup_ids.size());
jintArray ret_backup_ids = env->NewIntArray(ret_backup_ids_size);
if(ret_backup_ids == nullptr) {
if (ret_backup_ids == nullptr) {
// exception thrown: OutOfMemoryError
return nullptr;
}
@ -101,8 +102,8 @@ jintArray Java_org_rocksdb_BackupEngine_getCorruptedBackups(
* Method: garbageCollect
* Signature: (J)V
*/
void Java_org_rocksdb_BackupEngine_garbageCollect(
JNIEnv* env, jobject jbe, jlong jbe_handle) {
void Java_org_rocksdb_BackupEngine_garbageCollect(JNIEnv* env, jobject /*jbe*/,
jlong jbe_handle) {
auto* backup_engine = reinterpret_cast<rocksdb::BackupEngine*>(jbe_handle);
auto status = backup_engine->GarbageCollect();
@ -118,12 +119,12 @@ void Java_org_rocksdb_BackupEngine_garbageCollect(
* Method: purgeOldBackups
* Signature: (JI)V
*/
void Java_org_rocksdb_BackupEngine_purgeOldBackups(
JNIEnv* env, jobject jbe, jlong jbe_handle, jint jnum_backups_to_keep) {
void Java_org_rocksdb_BackupEngine_purgeOldBackups(JNIEnv* env, jobject /*jbe*/,
jlong jbe_handle,
jint jnum_backups_to_keep) {
auto* backup_engine = reinterpret_cast<rocksdb::BackupEngine*>(jbe_handle);
auto status =
backup_engine->
PurgeOldBackups(static_cast<uint32_t>(jnum_backups_to_keep));
auto status = backup_engine->PurgeOldBackups(
static_cast<uint32_t>(jnum_backups_to_keep));
if (status.ok()) {
return;
@ -137,8 +138,9 @@ void Java_org_rocksdb_BackupEngine_purgeOldBackups(
* Method: deleteBackup
* Signature: (JI)V
*/
void Java_org_rocksdb_BackupEngine_deleteBackup(
JNIEnv* env, jobject jbe, jlong jbe_handle, jint jbackup_id) {
void Java_org_rocksdb_BackupEngine_deleteBackup(JNIEnv* env, jobject /*jbe*/,
jlong jbe_handle,
jint jbackup_id) {
auto* backup_engine = reinterpret_cast<rocksdb::BackupEngine*>(jbe_handle);
auto status =
backup_engine->DeleteBackup(static_cast<rocksdb::BackupID>(jbackup_id));
@ -156,24 +158,23 @@ void Java_org_rocksdb_BackupEngine_deleteBackup(
* Signature: (JILjava/lang/String;Ljava/lang/String;J)V
*/
void Java_org_rocksdb_BackupEngine_restoreDbFromBackup(
JNIEnv* env, jobject jbe, jlong jbe_handle, jint jbackup_id,
JNIEnv* env, jobject /*jbe*/, jlong jbe_handle, jint jbackup_id,
jstring jdb_dir, jstring jwal_dir, jlong jrestore_options_handle) {
auto* backup_engine = reinterpret_cast<rocksdb::BackupEngine*>(jbe_handle);
const char* db_dir = env->GetStringUTFChars(jdb_dir, nullptr);
if(db_dir == nullptr) {
if (db_dir == nullptr) {
// exception thrown: OutOfMemoryError
return;
}
const char* wal_dir = env->GetStringUTFChars(jwal_dir, nullptr);
if(wal_dir == nullptr) {
if (wal_dir == nullptr) {
// exception thrown: OutOfMemoryError
env->ReleaseStringUTFChars(jdb_dir, db_dir);
return;
}
auto* restore_options =
reinterpret_cast<rocksdb::RestoreOptions*>(jrestore_options_handle);
auto status =
backup_engine->RestoreDBFromBackup(
auto status = backup_engine->RestoreDBFromBackup(
static_cast<rocksdb::BackupID>(jbackup_id), db_dir, wal_dir,
*restore_options);
@ -193,24 +194,23 @@ void Java_org_rocksdb_BackupEngine_restoreDbFromBackup(
* Signature: (JLjava/lang/String;Ljava/lang/String;J)V
*/
void Java_org_rocksdb_BackupEngine_restoreDbFromLatestBackup(
JNIEnv* env, jobject jbe, jlong jbe_handle, jstring jdb_dir,
JNIEnv* env, jobject /*jbe*/, jlong jbe_handle, jstring jdb_dir,
jstring jwal_dir, jlong jrestore_options_handle) {
auto* backup_engine = reinterpret_cast<rocksdb::BackupEngine*>(jbe_handle);
const char* db_dir = env->GetStringUTFChars(jdb_dir, nullptr);
if(db_dir == nullptr) {
if (db_dir == nullptr) {
// exception thrown: OutOfMemoryError
return;
}
const char* wal_dir = env->GetStringUTFChars(jwal_dir, nullptr);
if(wal_dir == nullptr) {
if (wal_dir == nullptr) {
// exception thrown: OutOfMemoryError
env->ReleaseStringUTFChars(jdb_dir, db_dir);
return;
}
auto* restore_options =
reinterpret_cast<rocksdb::RestoreOptions*>(jrestore_options_handle);
auto status =
backup_engine->RestoreDBFromLatestBackup(db_dir, wal_dir,
auto status = backup_engine->RestoreDBFromLatestBackup(db_dir, wal_dir,
*restore_options);
env->ReleaseStringUTFChars(jwal_dir, wal_dir);
@ -228,8 +228,9 @@ void Java_org_rocksdb_BackupEngine_restoreDbFromLatestBackup(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_BackupEngine_disposeInternal(
JNIEnv* env, jobject jbe, jlong jbe_handle) {
void Java_org_rocksdb_BackupEngine_disposeInternal(JNIEnv* /*env*/,
jobject /*jbe*/,
jlong jbe_handle) {
auto* be = reinterpret_cast<rocksdb::BackupEngine*>(jbe_handle);
assert(be != nullptr);
delete be;

@ -14,7 +14,7 @@
* Signature: (ZI)J
*/
jlong Java_org_rocksdb_CassandraCompactionFilter_createNewCassandraCompactionFilter0(
JNIEnv* env, jclass jcls, jboolean purge_ttl_on_expiration,
JNIEnv* /*env*/, jclass /*jcls*/, jboolean purge_ttl_on_expiration,
jint gc_grace_period_in_seconds) {
auto* compaction_filter = new rocksdb::cassandra::CassandraCompactionFilter(
purge_ttl_on_expiration, gc_grace_period_in_seconds);

@ -3,21 +3,21 @@
// COPYING file in the root directory) and Apache 2.0 License
// (found in the LICENSE.Apache file in the root directory).
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <jni.h>
#include <string>
#include <memory>
#include <string>
#include "include/org_rocksdb_CassandraValueMergeOperator.h"
#include "rocksjni/portal.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/memtablerep.h"
#include "rocksdb/table.h"
#include "rocksdb/slice_transform.h"
#include "rocksdb/merge_operator.h"
#include "rocksjni/portal.h"
#include "utilities/cassandra/merge_operator.h"
/*
@ -26,7 +26,7 @@
* Signature: (II)J
*/
jlong Java_org_rocksdb_CassandraValueMergeOperator_newSharedCassandraValueMergeOperator(
JNIEnv* env, jclass jclazz, jint gcGracePeriodInSeconds,
JNIEnv* /*env*/, jclass /*jclazz*/, jint gcGracePeriodInSeconds,
jint operands_limit) {
auto* op = new std::shared_ptr<rocksdb::MergeOperator>(
new rocksdb::cassandra::CassandraValueMergeOperator(
@ -40,7 +40,7 @@ jlong Java_org_rocksdb_CassandraValueMergeOperator_newSharedCassandraValueMergeO
* Signature: (J)V
*/
void Java_org_rocksdb_CassandraValueMergeOperator_disposeInternal(
JNIEnv* env, jobject jobj, jlong jhandle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
auto* op =
reinterpret_cast<std::shared_ptr<rocksdb::MergeOperator>*>(jhandle);
delete op;

@ -6,22 +6,23 @@
// This file implements the "bridge" between Java and C++ and enables
// calling c++ rocksdb::Checkpoint methods from Java side.
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <jni.h>
#include <string>
#include "include/org_rocksdb_Checkpoint.h"
#include "rocksjni/portal.h"
#include "rocksdb/db.h"
#include "rocksdb/utilities/checkpoint.h"
#include "rocksjni/portal.h"
/*
* Class: org_rocksdb_Checkpoint
* Method: newCheckpoint
* Signature: (J)J
*/
jlong Java_org_rocksdb_Checkpoint_newCheckpoint(JNIEnv* env,
jclass jclazz, jlong jdb_handle) {
jlong Java_org_rocksdb_Checkpoint_newCheckpoint(JNIEnv* /*env*/,
jclass /*jclazz*/,
jlong jdb_handle) {
auto* db = reinterpret_cast<rocksdb::DB*>(jdb_handle);
rocksdb::Checkpoint* checkpoint;
rocksdb::Checkpoint::Create(db, &checkpoint);
@ -33,7 +34,8 @@ jlong Java_org_rocksdb_Checkpoint_newCheckpoint(JNIEnv* env,
* Method: dispose
* Signature: (J)V
*/
void Java_org_rocksdb_Checkpoint_disposeInternal(JNIEnv* env, jobject jobj,
void Java_org_rocksdb_Checkpoint_disposeInternal(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* checkpoint = reinterpret_cast<rocksdb::Checkpoint*>(jhandle);
assert(checkpoint != nullptr);
@ -45,20 +47,17 @@ void Java_org_rocksdb_Checkpoint_disposeInternal(JNIEnv* env, jobject jobj,
* Method: createCheckpoint
* Signature: (JLjava/lang/String;)V
*/
void Java_org_rocksdb_Checkpoint_createCheckpoint(
JNIEnv* env, jobject jobj, jlong jcheckpoint_handle,
void Java_org_rocksdb_Checkpoint_createCheckpoint(JNIEnv* env, jobject /*jobj*/,
jlong jcheckpoint_handle,
jstring jcheckpoint_path) {
const char* checkpoint_path = env->GetStringUTFChars(
jcheckpoint_path, 0);
if(checkpoint_path == nullptr) {
const char* checkpoint_path = env->GetStringUTFChars(jcheckpoint_path, 0);
if (checkpoint_path == nullptr) {
// exception thrown: OutOfMemoryError
return;
}
auto* checkpoint = reinterpret_cast<rocksdb::Checkpoint*>(
jcheckpoint_handle);
rocksdb::Status s = checkpoint->CreateCheckpoint(
checkpoint_path);
auto* checkpoint = reinterpret_cast<rocksdb::Checkpoint*>(jcheckpoint_handle);
rocksdb::Status s = checkpoint->CreateCheckpoint(checkpoint_path);
env->ReleaseStringUTFChars(jcheckpoint_path, checkpoint_path);

@ -17,12 +17,11 @@
* Signature: (JIZ)J
*/
jlong Java_org_rocksdb_ClockCache_newClockCache(
JNIEnv* env, jclass jcls, jlong jcapacity, jint jnum_shard_bits,
JNIEnv* /*env*/, jclass /*jcls*/, jlong jcapacity, jint jnum_shard_bits,
jboolean jstrict_capacity_limit) {
auto* sptr_clock_cache =
new std::shared_ptr<rocksdb::Cache>(rocksdb::NewClockCache(
static_cast<size_t>(jcapacity),
static_cast<int>(jnum_shard_bits),
static_cast<size_t>(jcapacity), static_cast<int>(jnum_shard_bits),
static_cast<bool>(jstrict_capacity_limit)));
return reinterpret_cast<jlong>(sptr_clock_cache);
}
@ -32,9 +31,10 @@ jlong Java_org_rocksdb_ClockCache_newClockCache(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_ClockCache_disposeInternal(
JNIEnv* env, jobject jobj, jlong jhandle) {
void Java_org_rocksdb_ClockCache_disposeInternal(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* sptr_clock_cache =
reinterpret_cast<std::shared_ptr<rocksdb::Cache> *>(jhandle);
reinterpret_cast<std::shared_ptr<rocksdb::Cache>*>(jhandle);
delete sptr_clock_cache; // delete std::shared_ptr
}

@ -6,9 +6,9 @@
// This file implements the "bridge" between Java and C++ for
// rocksdb::ColumnFamilyHandle.
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <jni.h>
#include "include/org_rocksdb_ColumnFamilyHandle.h"
#include "rocksjni/portal.h"
@ -18,20 +18,22 @@
* Method: getName
* Signature: (J)[B
*/
jbyteArray Java_org_rocksdb_ColumnFamilyHandle_getName(
JNIEnv* env, jobject jobj, jlong jhandle) {
jbyteArray Java_org_rocksdb_ColumnFamilyHandle_getName(JNIEnv* env,
jobject /*jobj*/,
jlong jhandle) {
auto* cfh = reinterpret_cast<rocksdb::ColumnFamilyHandle*>(jhandle);
std::string cf_name = cfh->GetName();
return rocksdb::JniUtil::copyBytes(env, cf_name);
}
/*
* Class: org_rocksdb_ColumnFamilyHandle
* Method: getID
* Signature: (J)I
*/
jint Java_org_rocksdb_ColumnFamilyHandle_getID(
JNIEnv* env, jobject jobj, jlong jhandle) {
* Class: org_rocksdb_ColumnFamilyHandle
* Method: getID
* Signature: (J)I
*/
jint Java_org_rocksdb_ColumnFamilyHandle_getID(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* cfh = reinterpret_cast<rocksdb::ColumnFamilyHandle*>(jhandle);
const int32_t id = cfh->GetID();
return static_cast<jint>(id);
@ -42,8 +44,9 @@ jint Java_org_rocksdb_ColumnFamilyHandle_getID(
* Method: getDescriptor
* Signature: (J)Lorg/rocksdb/ColumnFamilyDescriptor;
*/
jobject Java_org_rocksdb_ColumnFamilyHandle_getDescriptor(
JNIEnv* env, jobject jobj, jlong jhandle) {
jobject Java_org_rocksdb_ColumnFamilyHandle_getDescriptor(JNIEnv* env,
jobject /*jobj*/,
jlong jhandle) {
auto* cfh = reinterpret_cast<rocksdb::ColumnFamilyHandle*>(jhandle);
rocksdb::ColumnFamilyDescriptor desc;
rocksdb::Status s = cfh->GetDescriptor(&desc);
@ -60,8 +63,9 @@ jobject Java_org_rocksdb_ColumnFamilyHandle_getDescriptor(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_ColumnFamilyHandle_disposeInternal(
JNIEnv* env, jobject jobj, jlong jhandle) {
void Java_org_rocksdb_ColumnFamilyHandle_disposeInternal(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* cfh = reinterpret_cast<rocksdb::ColumnFamilyHandle*>(jhandle);
assert(cfh != nullptr);
delete cfh;

@ -18,8 +18,9 @@
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_AbstractCompactionFilter_disposeInternal(
JNIEnv* env, jobject jobj, jlong handle) {
void Java_org_rocksdb_AbstractCompactionFilter_disposeInternal(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong handle) {
auto* cf = reinterpret_cast<rocksdb::CompactionFilter*>(handle);
assert(cf != nullptr);
delete cf;

@ -20,7 +20,8 @@
jlong Java_org_rocksdb_AbstractCompactionFilterFactory_createNewCompactionFilterFactory0(
JNIEnv* env, jobject jobj) {
auto* cff = new rocksdb::CompactionFilterFactoryJniCallback(env, jobj);
auto* ptr_sptr_cff = new std::shared_ptr<rocksdb::CompactionFilterFactoryJniCallback>(cff);
auto* ptr_sptr_cff =
new std::shared_ptr<rocksdb::CompactionFilterFactoryJniCallback>(cff);
return reinterpret_cast<jlong>(ptr_sptr_cff);
}
@ -30,9 +31,9 @@ jlong Java_org_rocksdb_AbstractCompactionFilterFactory_createNewCompactionFilter
* Signature: (J)V
*/
void Java_org_rocksdb_AbstractCompactionFilterFactory_disposeInternal(
JNIEnv* env, jobject jobj, jlong jhandle) {
auto* ptr_sptr_cff =
reinterpret_cast<std::shared_ptr<rocksdb::CompactionFilterFactoryJniCallback> *>(jhandle);
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
auto* ptr_sptr_cff = reinterpret_cast<
std::shared_ptr<rocksdb::CompactionFilterFactoryJniCallback>*>(jhandle);
delete ptr_sptr_cff;
// @lint-ignore TXT4 T25377293 Grandfathered in
// @lint-ignore TXT4 T25377293 Grandfathered in
}

@ -17,7 +17,7 @@
* Signature: ()J
*/
jlong Java_org_rocksdb_CompactionOptionsFIFO_newCompactionOptionsFIFO(
JNIEnv* env, jclass jcls) {
JNIEnv* /*env*/, jclass /*jcls*/) {
const auto* opt = new rocksdb::CompactionOptionsFIFO();
return reinterpret_cast<jlong>(opt);
}
@ -28,7 +28,8 @@ jlong Java_org_rocksdb_CompactionOptionsFIFO_newCompactionOptionsFIFO(
* Signature: (JJ)V
*/
void Java_org_rocksdb_CompactionOptionsFIFO_setMaxTableFilesSize(
JNIEnv* env, jobject jobj, jlong jhandle, jlong jmax_table_files_size) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jlong jmax_table_files_size) {
auto* opt = reinterpret_cast<rocksdb::CompactionOptionsFIFO*>(jhandle);
opt->max_table_files_size = static_cast<uint64_t>(jmax_table_files_size);
}
@ -38,8 +39,9 @@ void Java_org_rocksdb_CompactionOptionsFIFO_setMaxTableFilesSize(
* Method: maxTableFilesSize
* Signature: (J)J
*/
jlong Java_org_rocksdb_CompactionOptionsFIFO_maxTableFilesSize(
JNIEnv* env, jobject jobj, jlong jhandle) {
jlong Java_org_rocksdb_CompactionOptionsFIFO_maxTableFilesSize(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* opt = reinterpret_cast<rocksdb::CompactionOptionsFIFO*>(jhandle);
return static_cast<jlong>(opt->max_table_files_size);
}
@ -49,7 +51,8 @@ jlong Java_org_rocksdb_CompactionOptionsFIFO_maxTableFilesSize(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_CompactionOptionsFIFO_disposeInternal(
JNIEnv* env, jobject jobj, jlong jhandle) {
void Java_org_rocksdb_CompactionOptionsFIFO_disposeInternal(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
delete reinterpret_cast<rocksdb::CompactionOptionsFIFO*>(jhandle);
}

@ -18,7 +18,7 @@
* Signature: ()J
*/
jlong Java_org_rocksdb_CompactionOptionsUniversal_newCompactionOptionsUniversal(
JNIEnv* env, jclass jcls) {
JNIEnv* /*env*/, jclass /*jcls*/) {
const auto* opt = new rocksdb::CompactionOptionsUniversal();
return reinterpret_cast<jlong>(opt);
}
@ -29,7 +29,7 @@ jlong Java_org_rocksdb_CompactionOptionsUniversal_newCompactionOptionsUniversal(
* Signature: (JI)V
*/
void Java_org_rocksdb_CompactionOptionsUniversal_setSizeRatio(
JNIEnv* env, jobject jobj, jlong jhandle, jint jsize_ratio) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jint jsize_ratio) {
auto* opt = reinterpret_cast<rocksdb::CompactionOptionsUniversal*>(jhandle);
opt->size_ratio = static_cast<unsigned int>(jsize_ratio);
}
@ -39,8 +39,9 @@ void Java_org_rocksdb_CompactionOptionsUniversal_setSizeRatio(
* Method: sizeRatio
* Signature: (J)I
*/
jint Java_org_rocksdb_CompactionOptionsUniversal_sizeRatio(
JNIEnv* env, jobject jobj, jlong jhandle) {
jint Java_org_rocksdb_CompactionOptionsUniversal_sizeRatio(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* opt = reinterpret_cast<rocksdb::CompactionOptionsUniversal*>(jhandle);
return static_cast<jint>(opt->size_ratio);
}
@ -51,7 +52,7 @@ jint Java_org_rocksdb_CompactionOptionsUniversal_sizeRatio(
* Signature: (JI)V
*/
void Java_org_rocksdb_CompactionOptionsUniversal_setMinMergeWidth(
JNIEnv* env, jobject jobj, jlong jhandle, jint jmin_merge_width) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jint jmin_merge_width) {
auto* opt = reinterpret_cast<rocksdb::CompactionOptionsUniversal*>(jhandle);
opt->min_merge_width = static_cast<unsigned int>(jmin_merge_width);
}
@ -61,8 +62,9 @@ void Java_org_rocksdb_CompactionOptionsUniversal_setMinMergeWidth(
* Method: minMergeWidth
* Signature: (J)I
*/
jint Java_org_rocksdb_CompactionOptionsUniversal_minMergeWidth(
JNIEnv* env, jobject jobj, jlong jhandle) {
jint Java_org_rocksdb_CompactionOptionsUniversal_minMergeWidth(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* opt = reinterpret_cast<rocksdb::CompactionOptionsUniversal*>(jhandle);
return static_cast<jint>(opt->min_merge_width);
}
@ -73,7 +75,7 @@ jint Java_org_rocksdb_CompactionOptionsUniversal_minMergeWidth(
* Signature: (JI)V
*/
void Java_org_rocksdb_CompactionOptionsUniversal_setMaxMergeWidth(
JNIEnv* env, jobject jobj, jlong jhandle, jint jmax_merge_width) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jint jmax_merge_width) {
auto* opt = reinterpret_cast<rocksdb::CompactionOptionsUniversal*>(jhandle);
opt->max_merge_width = static_cast<unsigned int>(jmax_merge_width);
}
@ -83,8 +85,9 @@ void Java_org_rocksdb_CompactionOptionsUniversal_setMaxMergeWidth(
* Method: maxMergeWidth
* Signature: (J)I
*/
jint Java_org_rocksdb_CompactionOptionsUniversal_maxMergeWidth(
JNIEnv* env, jobject jobj, jlong jhandle) {
jint Java_org_rocksdb_CompactionOptionsUniversal_maxMergeWidth(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* opt = reinterpret_cast<rocksdb::CompactionOptionsUniversal*>(jhandle);
return static_cast<jint>(opt->max_merge_width);
}
@ -95,7 +98,7 @@ jint Java_org_rocksdb_CompactionOptionsUniversal_maxMergeWidth(
* Signature: (JI)V
*/
void Java_org_rocksdb_CompactionOptionsUniversal_setMaxSizeAmplificationPercent(
JNIEnv* env, jobject jobj, jlong jhandle,
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jint jmax_size_amplification_percent) {
auto* opt = reinterpret_cast<rocksdb::CompactionOptionsUniversal*>(jhandle);
opt->max_size_amplification_percent =
@ -108,7 +111,7 @@ void Java_org_rocksdb_CompactionOptionsUniversal_setMaxSizeAmplificationPercent(
* Signature: (J)I
*/
jint Java_org_rocksdb_CompactionOptionsUniversal_maxSizeAmplificationPercent(
JNIEnv* env, jobject jobj, jlong jhandle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
auto* opt = reinterpret_cast<rocksdb::CompactionOptionsUniversal*>(jhandle);
return static_cast<jint>(opt->max_size_amplification_percent);
}
@ -119,7 +122,8 @@ jint Java_org_rocksdb_CompactionOptionsUniversal_maxSizeAmplificationPercent(
* Signature: (JI)V
*/
void Java_org_rocksdb_CompactionOptionsUniversal_setCompressionSizePercent(
JNIEnv* env, jobject jobj, jlong jhandle, jint jcompression_size_percent) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jint jcompression_size_percent) {
auto* opt = reinterpret_cast<rocksdb::CompactionOptionsUniversal*>(jhandle);
opt->compression_size_percent =
static_cast<unsigned int>(jcompression_size_percent);
@ -131,7 +135,7 @@ void Java_org_rocksdb_CompactionOptionsUniversal_setCompressionSizePercent(
* Signature: (J)I
*/
jint Java_org_rocksdb_CompactionOptionsUniversal_compressionSizePercent(
JNIEnv* env, jobject jobj, jlong jhandle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
auto* opt = reinterpret_cast<rocksdb::CompactionOptionsUniversal*>(jhandle);
return static_cast<jint>(opt->compression_size_percent);
}
@ -142,10 +146,9 @@ jint Java_org_rocksdb_CompactionOptionsUniversal_compressionSizePercent(
* Signature: (JB)V
*/
void Java_org_rocksdb_CompactionOptionsUniversal_setStopStyle(
JNIEnv* env, jobject jobj, jlong jhandle, jbyte jstop_style_value) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jbyte jstop_style_value) {
auto* opt = reinterpret_cast<rocksdb::CompactionOptionsUniversal*>(jhandle);
opt->stop_style =
rocksdb::CompactionStopStyleJni::toCppCompactionStopStyle(
opt->stop_style = rocksdb::CompactionStopStyleJni::toCppCompactionStopStyle(
jstop_style_value);
}
@ -154,8 +157,9 @@ void Java_org_rocksdb_CompactionOptionsUniversal_setStopStyle(
* Method: stopStyle
* Signature: (J)B
*/
jbyte Java_org_rocksdb_CompactionOptionsUniversal_stopStyle(
JNIEnv* env, jobject jobj, jlong jhandle) {
jbyte Java_org_rocksdb_CompactionOptionsUniversal_stopStyle(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* opt = reinterpret_cast<rocksdb::CompactionOptionsUniversal*>(jhandle);
return rocksdb::CompactionStopStyleJni::toJavaCompactionStopStyle(
opt->stop_style);
@ -167,7 +171,8 @@ jbyte Java_org_rocksdb_CompactionOptionsUniversal_stopStyle(
* Signature: (JZ)V
*/
void Java_org_rocksdb_CompactionOptionsUniversal_setAllowTrivialMove(
JNIEnv* env, jobject jobj, jlong jhandle, jboolean jallow_trivial_move) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jboolean jallow_trivial_move) {
auto* opt = reinterpret_cast<rocksdb::CompactionOptionsUniversal*>(jhandle);
opt->allow_trivial_move = static_cast<bool>(jallow_trivial_move);
}
@ -178,7 +183,7 @@ void Java_org_rocksdb_CompactionOptionsUniversal_setAllowTrivialMove(
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_CompactionOptionsUniversal_allowTrivialMove(
JNIEnv* env, jobject jobj, jlong jhandle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
auto* opt = reinterpret_cast<rocksdb::CompactionOptionsUniversal*>(jhandle);
return opt->allow_trivial_move;
}
@ -189,6 +194,6 @@ jboolean Java_org_rocksdb_CompactionOptionsUniversal_allowTrivialMove(
* Signature: (J)V
*/
void Java_org_rocksdb_CompactionOptionsUniversal_disposeInternal(
JNIEnv* env, jobject jobj, jlong jhandle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
delete reinterpret_cast<rocksdb::CompactionOptionsUniversal*>(jhandle);
}

@ -6,11 +6,11 @@
// This file implements the "bridge" between Java and C++ for
// rocksdb::Comparator.
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <jni.h>
#include <string>
#include <functional>
#include <string>
#include "include/org_rocksdb_Comparator.h"
#include "include/org_rocksdb_DirectComparator.h"
@ -25,12 +25,12 @@
* Method: createNewComparator0
* Signature: ()J
*/
jlong Java_org_rocksdb_Comparator_createNewComparator0(
JNIEnv* env, jobject jobj, jlong copt_handle) {
jlong Java_org_rocksdb_Comparator_createNewComparator0(JNIEnv* env,
jobject jobj,
jlong copt_handle) {
auto* copt =
reinterpret_cast<rocksdb::ComparatorJniCallbackOptions*>(copt_handle);
auto* c =
new rocksdb::ComparatorJniCallback(env, jobj, copt);
auto* c = new rocksdb::ComparatorJniCallback(env, jobj, copt);
return reinterpret_cast<jlong>(c);
}
// </editor-fold>
@ -46,8 +46,7 @@ jlong Java_org_rocksdb_DirectComparator_createNewDirectComparator0(
JNIEnv* env, jobject jobj, jlong copt_handle) {
auto* copt =
reinterpret_cast<rocksdb::ComparatorJniCallbackOptions*>(copt_handle);
auto* c =
new rocksdb::DirectComparatorJniCallback(env, jobj, copt);
auto* c = new rocksdb::DirectComparatorJniCallback(env, jobj, copt);
return reinterpret_cast<jlong>(c);
}
@ -57,9 +56,8 @@ jlong Java_org_rocksdb_DirectComparator_createNewDirectComparator0(
* Signature: (J)V
*/
void Java_org_rocksdb_NativeComparatorWrapper_disposeInternal(
JNIEnv* env, jobject jobj, jlong jcomparator_handle) {
auto* comparator =
reinterpret_cast<rocksdb::Comparator*>(jcomparator_handle);
JNIEnv* /*env*/, jobject /*jobj*/, jlong jcomparator_handle) {
auto* comparator = reinterpret_cast<rocksdb::Comparator*>(jcomparator_handle);
delete comparator;
}
// </editor-fold>

@ -17,7 +17,7 @@
* Signature: ()J
*/
jlong Java_org_rocksdb_CompressionOptions_newCompressionOptions(
JNIEnv* env, jclass jcls) {
JNIEnv* /*env*/, jclass /*jcls*/) {
const auto* opt = new rocksdb::CompressionOptions();
return reinterpret_cast<jlong>(opt);
}
@ -27,8 +27,10 @@ jlong Java_org_rocksdb_CompressionOptions_newCompressionOptions(
* Method: setWindowBits
* Signature: (JI)V
*/
void Java_org_rocksdb_CompressionOptions_setWindowBits(
JNIEnv* env, jobject jobj, jlong jhandle, jint jwindow_bits) {
void Java_org_rocksdb_CompressionOptions_setWindowBits(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle,
jint jwindow_bits) {
auto* opt = reinterpret_cast<rocksdb::CompressionOptions*>(jhandle);
opt->window_bits = static_cast<int>(jwindow_bits);
}
@ -38,8 +40,9 @@ void Java_org_rocksdb_CompressionOptions_setWindowBits(
* Method: windowBits
* Signature: (J)I
*/
jint Java_org_rocksdb_CompressionOptions_windowBits(
JNIEnv* env, jobject jobj, jlong jhandle) {
jint Java_org_rocksdb_CompressionOptions_windowBits(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* opt = reinterpret_cast<rocksdb::CompressionOptions*>(jhandle);
return static_cast<jint>(opt->window_bits);
}
@ -49,8 +52,9 @@ jint Java_org_rocksdb_CompressionOptions_windowBits(
* Method: setLevel
* Signature: (JI)V
*/
void Java_org_rocksdb_CompressionOptions_setLevel(
JNIEnv* env, jobject jobj, jlong jhandle, jint jlevel) {
void Java_org_rocksdb_CompressionOptions_setLevel(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle, jint jlevel) {
auto* opt = reinterpret_cast<rocksdb::CompressionOptions*>(jhandle);
opt->level = static_cast<int>(jlevel);
}
@ -60,8 +64,9 @@ void Java_org_rocksdb_CompressionOptions_setLevel(
* Method: level
* Signature: (J)I
*/
jint Java_org_rocksdb_CompressionOptions_level(
JNIEnv* env, jobject jobj, jlong jhandle) {
jint Java_org_rocksdb_CompressionOptions_level(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* opt = reinterpret_cast<rocksdb::CompressionOptions*>(jhandle);
return static_cast<jint>(opt->level);
}
@ -71,8 +76,10 @@ jint Java_org_rocksdb_CompressionOptions_level(
* Method: setStrategy
* Signature: (JI)V
*/
void Java_org_rocksdb_CompressionOptions_setStrategy(
JNIEnv* env, jobject jobj, jlong jhandle, jint jstrategy) {
void Java_org_rocksdb_CompressionOptions_setStrategy(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle,
jint jstrategy) {
auto* opt = reinterpret_cast<rocksdb::CompressionOptions*>(jhandle);
opt->strategy = static_cast<int>(jstrategy);
}
@ -82,8 +89,9 @@ void Java_org_rocksdb_CompressionOptions_setStrategy(
* Method: strategy
* Signature: (J)I
*/
jint Java_org_rocksdb_CompressionOptions_strategy(
JNIEnv* env, jobject jobj, jlong jhandle) {
jint Java_org_rocksdb_CompressionOptions_strategy(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* opt = reinterpret_cast<rocksdb::CompressionOptions*>(jhandle);
return static_cast<jint>(opt->strategy);
}
@ -93,8 +101,10 @@ jint Java_org_rocksdb_CompressionOptions_strategy(
* Method: setMaxDictBytes
* Signature: (JI)V
*/
void Java_org_rocksdb_CompressionOptions_setMaxDictBytes(
JNIEnv* env, jobject jobj, jlong jhandle, jint jmax_dict_bytes) {
void Java_org_rocksdb_CompressionOptions_setMaxDictBytes(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle,
jint jmax_dict_bytes) {
auto* opt = reinterpret_cast<rocksdb::CompressionOptions*>(jhandle);
opt->max_dict_bytes = static_cast<int>(jmax_dict_bytes);
}
@ -104,8 +114,9 @@ void Java_org_rocksdb_CompressionOptions_setMaxDictBytes(
* Method: maxDictBytes
* Signature: (J)I
*/
jint Java_org_rocksdb_CompressionOptions_maxDictBytes(
JNIEnv* env, jobject jobj, jlong jhandle) {
jint Java_org_rocksdb_CompressionOptions_maxDictBytes(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* opt = reinterpret_cast<rocksdb::CompressionOptions*>(jhandle);
return static_cast<jint>(opt->max_dict_bytes);
}
@ -115,7 +126,8 @@ jint Java_org_rocksdb_CompressionOptions_maxDictBytes(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_CompressionOptions_disposeInternal(
JNIEnv* env, jobject jobj, jlong jhandle) {
void Java_org_rocksdb_CompressionOptions_disposeInternal(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
delete reinterpret_cast<rocksdb::CompressionOptions*>(jhandle);
}

@ -6,18 +6,18 @@
// This file implements the "bridge" between Java and C++ and enables
// calling c++ rocksdb::Env methods from Java side.
#include "rocksdb/env.h"
#include "include/org_rocksdb_Env.h"
#include "include/org_rocksdb_RocksEnv.h"
#include "include/org_rocksdb_RocksMemEnv.h"
#include "rocksdb/env.h"
/*
* Class: org_rocksdb_Env
* Method: getDefaultEnvInternal
* Signature: ()J
*/
jlong Java_org_rocksdb_Env_getDefaultEnvInternal(
JNIEnv* env, jclass jclazz) {
jlong Java_org_rocksdb_Env_getDefaultEnvInternal(JNIEnv* /*env*/,
jclass /*jclazz*/) {
return reinterpret_cast<jlong>(rocksdb::Env::Default());
}
@ -26,8 +26,8 @@ jlong Java_org_rocksdb_Env_getDefaultEnvInternal(
* Method: setBackgroundThreads
* Signature: (JII)V
*/
void Java_org_rocksdb_Env_setBackgroundThreads(
JNIEnv* env, jobject jobj, jlong jhandle,
void Java_org_rocksdb_Env_setBackgroundThreads(JNIEnv* /*env*/,
jobject /*jobj*/, jlong jhandle,
jint num, jint priority) {
auto* rocks_env = reinterpret_cast<rocksdb::Env*>(jhandle);
switch (priority) {
@ -45,8 +45,9 @@ void Java_org_rocksdb_Env_setBackgroundThreads(
* Method: getThreadPoolQueueLen
* Signature: (JI)I
*/
jint Java_org_rocksdb_Env_getThreadPoolQueueLen(
JNIEnv* env, jobject jobj, jlong jhandle, jint pool_id) {
jint Java_org_rocksdb_Env_getThreadPoolQueueLen(JNIEnv* /*env*/,
jobject /*jobj*/, jlong jhandle,
jint pool_id) {
auto* rocks_env = reinterpret_cast<rocksdb::Env*>(jhandle);
switch (pool_id) {
case org_rocksdb_RocksEnv_FLUSH_POOL:
@ -62,10 +63,9 @@ jint Java_org_rocksdb_Env_getThreadPoolQueueLen(
* Method: createMemEnv
* Signature: ()J
*/
jlong Java_org_rocksdb_RocksMemEnv_createMemEnv(
JNIEnv* env, jclass jclazz) {
return reinterpret_cast<jlong>(rocksdb::NewMemEnv(
rocksdb::Env::Default()));
jlong Java_org_rocksdb_RocksMemEnv_createMemEnv(JNIEnv* /*env*/,
jclass /*jclazz*/) {
return reinterpret_cast<jlong>(rocksdb::NewMemEnv(rocksdb::Env::Default()));
}
/*
@ -73,8 +73,9 @@ jlong Java_org_rocksdb_RocksMemEnv_createMemEnv(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_RocksMemEnv_disposeInternal(
JNIEnv* env, jobject jobj, jlong jhandle) {
void Java_org_rocksdb_RocksMemEnv_disposeInternal(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* e = reinterpret_cast<rocksdb::Env*>(jhandle);
assert(e != nullptr);
delete e;

@ -32,7 +32,8 @@
* Method: newEnvOptions
* Signature: ()J
*/
jlong Java_org_rocksdb_EnvOptions_newEnvOptions(JNIEnv *env, jclass jcls) {
jlong Java_org_rocksdb_EnvOptions_newEnvOptions(JNIEnv * /*env*/,
jclass /*jcls*/) {
auto *env_opt = new rocksdb::EnvOptions();
return reinterpret_cast<jlong>(env_opt);
}
@ -42,9 +43,10 @@ jlong Java_org_rocksdb_EnvOptions_newEnvOptions(JNIEnv *env, jclass jcls) {
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_EnvOptions_disposeInternal(JNIEnv *env, jobject jobj,
void Java_org_rocksdb_EnvOptions_disposeInternal(JNIEnv * /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* eo = reinterpret_cast<rocksdb::EnvOptions *>(jhandle);
auto *eo = reinterpret_cast<rocksdb::EnvOptions *>(jhandle);
assert(eo != nullptr);
delete eo;
}
@ -54,7 +56,8 @@ void Java_org_rocksdb_EnvOptions_disposeInternal(JNIEnv *env, jobject jobj,
* Method: setUseDirectReads
* Signature: (JZ)V
*/
void Java_org_rocksdb_EnvOptions_setUseDirectReads(JNIEnv *env, jobject jobj,
void Java_org_rocksdb_EnvOptions_setUseDirectReads(JNIEnv * /*env*/,
jobject /*jobj*/,
jlong jhandle,
jboolean use_direct_reads) {
ENV_OPTIONS_SET_BOOL(jhandle, use_direct_reads);
@ -65,7 +68,8 @@ void Java_org_rocksdb_EnvOptions_setUseDirectReads(JNIEnv *env, jobject jobj,
* Method: useDirectReads
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_EnvOptions_useDirectReads(JNIEnv *env, jobject jobj,
jboolean Java_org_rocksdb_EnvOptions_useDirectReads(JNIEnv * /*env*/,
jobject /*jobj*/,
jlong jhandle) {
return ENV_OPTIONS_GET(jhandle, use_direct_reads);
}
@ -76,7 +80,8 @@ jboolean Java_org_rocksdb_EnvOptions_useDirectReads(JNIEnv *env, jobject jobj,
* Signature: (JZ)V
*/
void Java_org_rocksdb_EnvOptions_setUseDirectWrites(
JNIEnv *env, jobject jobj, jlong jhandle, jboolean use_direct_writes) {
JNIEnv * /*env*/, jobject /*jobj*/, jlong jhandle,
jboolean use_direct_writes) {
ENV_OPTIONS_SET_BOOL(jhandle, use_direct_writes);
}
@ -85,7 +90,8 @@ void Java_org_rocksdb_EnvOptions_setUseDirectWrites(
* Method: useDirectWrites
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_EnvOptions_useDirectWrites(JNIEnv *env, jobject jobj,
jboolean Java_org_rocksdb_EnvOptions_useDirectWrites(JNIEnv * /*env*/,
jobject /*jobj*/,
jlong jhandle) {
return ENV_OPTIONS_GET(jhandle, use_direct_writes);
}
@ -95,7 +101,8 @@ jboolean Java_org_rocksdb_EnvOptions_useDirectWrites(JNIEnv *env, jobject jobj,
* Method: setUseMmapReads
* Signature: (JZ)V
*/
void Java_org_rocksdb_EnvOptions_setUseMmapReads(JNIEnv *env, jobject jobj,
void Java_org_rocksdb_EnvOptions_setUseMmapReads(JNIEnv * /*env*/,
jobject /*jobj*/,
jlong jhandle,
jboolean use_mmap_reads) {
ENV_OPTIONS_SET_BOOL(jhandle, use_mmap_reads);
@ -106,7 +113,8 @@ void Java_org_rocksdb_EnvOptions_setUseMmapReads(JNIEnv *env, jobject jobj,
* Method: useMmapReads
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_EnvOptions_useMmapReads(JNIEnv *env, jobject jobj,
jboolean Java_org_rocksdb_EnvOptions_useMmapReads(JNIEnv * /*env*/,
jobject /*jobj*/,
jlong jhandle) {
return ENV_OPTIONS_GET(jhandle, use_mmap_reads);
}
@ -116,7 +124,8 @@ jboolean Java_org_rocksdb_EnvOptions_useMmapReads(JNIEnv *env, jobject jobj,
* Method: setUseMmapWrites
* Signature: (JZ)V
*/
void Java_org_rocksdb_EnvOptions_setUseMmapWrites(JNIEnv *env, jobject jobj,
void Java_org_rocksdb_EnvOptions_setUseMmapWrites(JNIEnv * /*env*/,
jobject /*jobj*/,
jlong jhandle,
jboolean use_mmap_writes) {
ENV_OPTIONS_SET_BOOL(jhandle, use_mmap_writes);
@ -127,7 +136,8 @@ void Java_org_rocksdb_EnvOptions_setUseMmapWrites(JNIEnv *env, jobject jobj,
* Method: useMmapWrites
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_EnvOptions_useMmapWrites(JNIEnv *env, jobject jobj,
jboolean Java_org_rocksdb_EnvOptions_useMmapWrites(JNIEnv * /*env*/,
jobject /*jobj*/,
jlong jhandle) {
return ENV_OPTIONS_GET(jhandle, use_mmap_writes);
}
@ -137,7 +147,8 @@ jboolean Java_org_rocksdb_EnvOptions_useMmapWrites(JNIEnv *env, jobject jobj,
* Method: setAllowFallocate
* Signature: (JZ)V
*/
void Java_org_rocksdb_EnvOptions_setAllowFallocate(JNIEnv *env, jobject jobj,
void Java_org_rocksdb_EnvOptions_setAllowFallocate(JNIEnv * /*env*/,
jobject /*jobj*/,
jlong jhandle,
jboolean allow_fallocate) {
ENV_OPTIONS_SET_BOOL(jhandle, allow_fallocate);
@ -148,7 +159,8 @@ void Java_org_rocksdb_EnvOptions_setAllowFallocate(JNIEnv *env, jobject jobj,
* Method: allowFallocate
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_EnvOptions_allowFallocate(JNIEnv *env, jobject jobj,
jboolean Java_org_rocksdb_EnvOptions_allowFallocate(JNIEnv * /*env*/,
jobject /*jobj*/,
jlong jhandle) {
return ENV_OPTIONS_GET(jhandle, allow_fallocate);
}
@ -158,7 +170,8 @@ jboolean Java_org_rocksdb_EnvOptions_allowFallocate(JNIEnv *env, jobject jobj,
* Method: setSetFdCloexec
* Signature: (JZ)V
*/
void Java_org_rocksdb_EnvOptions_setSetFdCloexec(JNIEnv *env, jobject jobj,
void Java_org_rocksdb_EnvOptions_setSetFdCloexec(JNIEnv * /*env*/,
jobject /*jobj*/,
jlong jhandle,
jboolean set_fd_cloexec) {
ENV_OPTIONS_SET_BOOL(jhandle, set_fd_cloexec);
@ -169,7 +182,8 @@ void Java_org_rocksdb_EnvOptions_setSetFdCloexec(JNIEnv *env, jobject jobj,
* Method: setFdCloexec
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_EnvOptions_setFdCloexec(JNIEnv *env, jobject jobj,
jboolean Java_org_rocksdb_EnvOptions_setFdCloexec(JNIEnv * /*env*/,
jobject /*jobj*/,
jlong jhandle) {
return ENV_OPTIONS_GET(jhandle, set_fd_cloexec);
}
@ -179,7 +193,8 @@ jboolean Java_org_rocksdb_EnvOptions_setFdCloexec(JNIEnv *env, jobject jobj,
* Method: setBytesPerSync
* Signature: (JJ)V
*/
void Java_org_rocksdb_EnvOptions_setBytesPerSync(JNIEnv *env, jobject jobj,
void Java_org_rocksdb_EnvOptions_setBytesPerSync(JNIEnv * /*env*/,
jobject /*jobj*/,
jlong jhandle,
jlong bytes_per_sync) {
ENV_OPTIONS_SET_UINT64_T(jhandle, bytes_per_sync);
@ -190,7 +205,8 @@ void Java_org_rocksdb_EnvOptions_setBytesPerSync(JNIEnv *env, jobject jobj,
* Method: bytesPerSync
* Signature: (J)J
*/
jlong Java_org_rocksdb_EnvOptions_bytesPerSync(JNIEnv *env, jobject jobj,
jlong Java_org_rocksdb_EnvOptions_bytesPerSync(JNIEnv * /*env*/,
jobject /*jobj*/,
jlong jhandle) {
return ENV_OPTIONS_GET(jhandle, bytes_per_sync);
}
@ -201,7 +217,7 @@ jlong Java_org_rocksdb_EnvOptions_bytesPerSync(JNIEnv *env, jobject jobj,
* Signature: (JZ)V
*/
void Java_org_rocksdb_EnvOptions_setFallocateWithKeepSize(
JNIEnv *env, jobject jobj, jlong jhandle,
JNIEnv * /*env*/, jobject /*jobj*/, jlong jhandle,
jboolean fallocate_with_keep_size) {
ENV_OPTIONS_SET_BOOL(jhandle, fallocate_with_keep_size);
}
@ -211,8 +227,8 @@ void Java_org_rocksdb_EnvOptions_setFallocateWithKeepSize(
* Method: fallocateWithKeepSize
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_EnvOptions_fallocateWithKeepSize(JNIEnv *env,
jobject jobj,
jboolean Java_org_rocksdb_EnvOptions_fallocateWithKeepSize(JNIEnv * /*env*/,
jobject /*jobj*/,
jlong jhandle) {
return ENV_OPTIONS_GET(jhandle, fallocate_with_keep_size);
}
@ -223,7 +239,8 @@ jboolean Java_org_rocksdb_EnvOptions_fallocateWithKeepSize(JNIEnv *env,
* Signature: (JJ)V
*/
void Java_org_rocksdb_EnvOptions_setCompactionReadaheadSize(
JNIEnv *env, jobject jobj, jlong jhandle, jlong compaction_readahead_size) {
JNIEnv * /*env*/, jobject /*jobj*/, jlong jhandle,
jlong compaction_readahead_size) {
ENV_OPTIONS_SET_SIZE_T(jhandle, compaction_readahead_size);
}
@ -232,8 +249,8 @@ void Java_org_rocksdb_EnvOptions_setCompactionReadaheadSize(
* Method: compactionReadaheadSize
* Signature: (J)J
*/
jlong Java_org_rocksdb_EnvOptions_compactionReadaheadSize(JNIEnv *env,
jobject jobj,
jlong Java_org_rocksdb_EnvOptions_compactionReadaheadSize(JNIEnv * /*env*/,
jobject /*jobj*/,
jlong jhandle) {
return ENV_OPTIONS_GET(jhandle, compaction_readahead_size);
}
@ -244,7 +261,7 @@ jlong Java_org_rocksdb_EnvOptions_compactionReadaheadSize(JNIEnv *env,
* Signature: (JJ)V
*/
void Java_org_rocksdb_EnvOptions_setRandomAccessMaxBufferSize(
JNIEnv *env, jobject jobj, jlong jhandle,
JNIEnv * /*env*/, jobject /*jobj*/, jlong jhandle,
jlong random_access_max_buffer_size) {
ENV_OPTIONS_SET_SIZE_T(jhandle, random_access_max_buffer_size);
}
@ -254,8 +271,8 @@ void Java_org_rocksdb_EnvOptions_setRandomAccessMaxBufferSize(
* Method: randomAccessMaxBufferSize
* Signature: (J)J
*/
jlong Java_org_rocksdb_EnvOptions_randomAccessMaxBufferSize(JNIEnv *env,
jobject jobj,
jlong Java_org_rocksdb_EnvOptions_randomAccessMaxBufferSize(JNIEnv * /*env*/,
jobject /*jobj*/,
jlong jhandle) {
return ENV_OPTIONS_GET(jhandle, random_access_max_buffer_size);
}
@ -266,7 +283,7 @@ jlong Java_org_rocksdb_EnvOptions_randomAccessMaxBufferSize(JNIEnv *env,
* Signature: (JJ)V
*/
void Java_org_rocksdb_EnvOptions_setWritableFileMaxBufferSize(
JNIEnv *env, jobject jobj, jlong jhandle,
JNIEnv * /*env*/, jobject /*jobj*/, jlong jhandle,
jlong writable_file_max_buffer_size) {
ENV_OPTIONS_SET_SIZE_T(jhandle, writable_file_max_buffer_size);
}
@ -276,8 +293,8 @@ void Java_org_rocksdb_EnvOptions_setWritableFileMaxBufferSize(
* Method: writableFileMaxBufferSize
* Signature: (J)J
*/
jlong Java_org_rocksdb_EnvOptions_writableFileMaxBufferSize(JNIEnv *env,
jobject jobj,
jlong Java_org_rocksdb_EnvOptions_writableFileMaxBufferSize(JNIEnv * /*env*/,
jobject /*jobj*/,
jlong jhandle) {
return ENV_OPTIONS_GET(jhandle, writable_file_max_buffer_size);
}
@ -287,11 +304,11 @@ jlong Java_org_rocksdb_EnvOptions_writableFileMaxBufferSize(JNIEnv *env,
* Method: setRateLimiter
* Signature: (JJ)V
*/
void Java_org_rocksdb_EnvOptions_setRateLimiter(JNIEnv *env, jobject jobj,
jlong jhandle,
void Java_org_rocksdb_EnvOptions_setRateLimiter(JNIEnv * /*env*/,
jobject /*jobj*/, jlong jhandle,
jlong rl_handle) {
auto* sptr_rate_limiter =
auto *sptr_rate_limiter =
reinterpret_cast<std::shared_ptr<rocksdb::RateLimiter> *>(rl_handle);
auto* env_opt = reinterpret_cast<rocksdb::EnvOptions *>(jhandle);
auto *env_opt = reinterpret_cast<rocksdb::EnvOptions *>(jhandle);
env_opt->rate_limiter = sptr_rate_limiter->get();
}

@ -6,15 +6,15 @@
// This file implements the "bridge" between Java and C++ for
// rocksdb::FilterPolicy.
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <jni.h>
#include <string>
#include "include/org_rocksdb_Filter.h"
#include "include/org_rocksdb_BloomFilter.h"
#include "rocksjni/portal.h"
#include "include/org_rocksdb_Filter.h"
#include "rocksdb/filter_policy.h"
#include "rocksjni/portal.h"
/*
* Class: org_rocksdb_BloomFilter
@ -22,10 +22,9 @@
* Signature: (IZ)J
*/
jlong Java_org_rocksdb_BloomFilter_createNewBloomFilter(
JNIEnv* env, jclass jcls, jint bits_per_key,
JNIEnv* /*env*/, jclass /*jcls*/, jint bits_per_key,
jboolean use_block_base_builder) {
auto* sptr_filter =
new std::shared_ptr<const rocksdb::FilterPolicy>(
auto* sptr_filter = new std::shared_ptr<const rocksdb::FilterPolicy>(
rocksdb::NewBloomFilterPolicy(bits_per_key, use_block_base_builder));
return reinterpret_cast<jlong>(sptr_filter);
}
@ -35,9 +34,9 @@ jlong Java_org_rocksdb_BloomFilter_createNewBloomFilter(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_Filter_disposeInternal(
JNIEnv* env, jobject jobj, jlong jhandle) {
void Java_org_rocksdb_Filter_disposeInternal(JNIEnv* /*env*/, jobject /*jobj*/,
jlong jhandle) {
auto* handle =
reinterpret_cast<std::shared_ptr<const rocksdb::FilterPolicy> *>(jhandle);
reinterpret_cast<std::shared_ptr<const rocksdb::FilterPolicy>*>(jhandle);
delete handle; // delete std::shared_ptr
}

@ -17,7 +17,7 @@
* Signature: ()J
*/
jlong Java_org_rocksdb_IngestExternalFileOptions_newIngestExternalFileOptions__(
JNIEnv* env, jclass jclazz) {
JNIEnv* /*env*/, jclass /*jclazz*/) {
auto* options = new rocksdb::IngestExternalFileOptions();
return reinterpret_cast<jlong>(options);
}
@ -28,7 +28,7 @@ jlong Java_org_rocksdb_IngestExternalFileOptions_newIngestExternalFileOptions__(
* Signature: (ZZZZ)J
*/
jlong Java_org_rocksdb_IngestExternalFileOptions_newIngestExternalFileOptions__ZZZZ(
JNIEnv* env, jclass jcls, jboolean jmove_files,
JNIEnv* /*env*/, jclass /*jcls*/, jboolean jmove_files,
jboolean jsnapshot_consistency, jboolean jallow_global_seqno,
jboolean jallow_blocking_flush) {
auto* options = new rocksdb::IngestExternalFileOptions();
@ -44,8 +44,9 @@ jlong Java_org_rocksdb_IngestExternalFileOptions_newIngestExternalFileOptions__Z
* Method: moveFiles
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_IngestExternalFileOptions_moveFiles(
JNIEnv* env, jobject jobj, jlong jhandle) {
jboolean Java_org_rocksdb_IngestExternalFileOptions_moveFiles(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* options =
reinterpret_cast<rocksdb::IngestExternalFileOptions*>(jhandle);
return static_cast<jboolean>(options->move_files);
@ -57,7 +58,7 @@ jboolean Java_org_rocksdb_IngestExternalFileOptions_moveFiles(
* Signature: (JZ)V
*/
void Java_org_rocksdb_IngestExternalFileOptions_setMoveFiles(
JNIEnv* env, jobject jobj, jlong jhandle, jboolean jmove_files) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jboolean jmove_files) {
auto* options =
reinterpret_cast<rocksdb::IngestExternalFileOptions*>(jhandle);
options->move_files = static_cast<bool>(jmove_files);
@ -69,7 +70,7 @@ void Java_org_rocksdb_IngestExternalFileOptions_setMoveFiles(
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_IngestExternalFileOptions_snapshotConsistency(
JNIEnv* env, jobject jobj, jlong jhandle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
auto* options =
reinterpret_cast<rocksdb::IngestExternalFileOptions*>(jhandle);
return static_cast<jboolean>(options->snapshot_consistency);
@ -81,7 +82,7 @@ jboolean Java_org_rocksdb_IngestExternalFileOptions_snapshotConsistency(
* Signature: (JZ)V
*/
void Java_org_rocksdb_IngestExternalFileOptions_setSnapshotConsistency(
JNIEnv* env, jobject jobj, jlong jhandle,
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jboolean jsnapshot_consistency) {
auto* options =
reinterpret_cast<rocksdb::IngestExternalFileOptions*>(jhandle);
@ -94,7 +95,7 @@ void Java_org_rocksdb_IngestExternalFileOptions_setSnapshotConsistency(
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_IngestExternalFileOptions_allowGlobalSeqNo(
JNIEnv* env, jobject jobj, jlong jhandle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
auto* options =
reinterpret_cast<rocksdb::IngestExternalFileOptions*>(jhandle);
return static_cast<jboolean>(options->allow_global_seqno);
@ -106,7 +107,8 @@ jboolean Java_org_rocksdb_IngestExternalFileOptions_allowGlobalSeqNo(
* Signature: (JZ)V
*/
void Java_org_rocksdb_IngestExternalFileOptions_setAllowGlobalSeqNo(
JNIEnv* env, jobject jobj, jlong jhandle, jboolean jallow_global_seqno) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jboolean jallow_global_seqno) {
auto* options =
reinterpret_cast<rocksdb::IngestExternalFileOptions*>(jhandle);
options->allow_global_seqno = static_cast<bool>(jallow_global_seqno);
@ -118,7 +120,7 @@ void Java_org_rocksdb_IngestExternalFileOptions_setAllowGlobalSeqNo(
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_IngestExternalFileOptions_allowBlockingFlush(
JNIEnv* env, jobject jobj, jlong jhandle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
auto* options =
reinterpret_cast<rocksdb::IngestExternalFileOptions*>(jhandle);
return static_cast<jboolean>(options->allow_blocking_flush);
@ -130,7 +132,8 @@ jboolean Java_org_rocksdb_IngestExternalFileOptions_allowBlockingFlush(
* Signature: (JZ)V
*/
void Java_org_rocksdb_IngestExternalFileOptions_setAllowBlockingFlush(
JNIEnv* env, jobject jobj, jlong jhandle, jboolean jallow_blocking_flush) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jboolean jallow_blocking_flush) {
auto* options =
reinterpret_cast<rocksdb::IngestExternalFileOptions*>(jhandle);
options->allow_blocking_flush = static_cast<bool>(jallow_blocking_flush);
@ -142,9 +145,9 @@ void Java_org_rocksdb_IngestExternalFileOptions_setAllowBlockingFlush(
* Signature: (J)V
*/
void Java_org_rocksdb_IngestExternalFileOptions_disposeInternal(
JNIEnv* env, jobject jobj, jlong jhandle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
auto* options =
reinterpret_cast<rocksdb::IngestExternalFileOptions*>(jhandle);
delete options;
// @lint-ignore TXT4 T25377293 Grandfathered in
// @lint-ignore TXT4 T25377293 Grandfathered in
}

@ -6,21 +6,22 @@
// This file implements the "bridge" between Java and C++ and enables
// calling c++ rocksdb::Iterator methods from Java side.
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <jni.h>
#include "include/org_rocksdb_RocksIterator.h"
#include "rocksjni/portal.h"
#include "rocksdb/iterator.h"
#include "rocksjni/portal.h"
/*
* Class: org_rocksdb_RocksIterator
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_RocksIterator_disposeInternal(
JNIEnv* env, jobject jobj, jlong handle) {
void Java_org_rocksdb_RocksIterator_disposeInternal(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong handle) {
auto* it = reinterpret_cast<rocksdb::Iterator*>(handle);
assert(it != nullptr);
delete it;
@ -31,8 +32,9 @@ void Java_org_rocksdb_RocksIterator_disposeInternal(
* Method: isValid0
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_RocksIterator_isValid0(
JNIEnv* env, jobject jobj, jlong handle) {
jboolean Java_org_rocksdb_RocksIterator_isValid0(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong handle) {
return reinterpret_cast<rocksdb::Iterator*>(handle)->Valid();
}
@ -41,8 +43,9 @@ jboolean Java_org_rocksdb_RocksIterator_isValid0(
* Method: seekToFirst0
* Signature: (J)V
*/
void Java_org_rocksdb_RocksIterator_seekToFirst0(
JNIEnv* env, jobject jobj, jlong handle) {
void Java_org_rocksdb_RocksIterator_seekToFirst0(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong handle) {
reinterpret_cast<rocksdb::Iterator*>(handle)->SeekToFirst();
}
@ -51,8 +54,9 @@ void Java_org_rocksdb_RocksIterator_seekToFirst0(
* Method: seekToLast0
* Signature: (J)V
*/
void Java_org_rocksdb_RocksIterator_seekToLast0(
JNIEnv* env, jobject jobj, jlong handle) {
void Java_org_rocksdb_RocksIterator_seekToLast0(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong handle) {
reinterpret_cast<rocksdb::Iterator*>(handle)->SeekToLast();
}
@ -61,8 +65,8 @@ void Java_org_rocksdb_RocksIterator_seekToLast0(
* Method: next0
* Signature: (J)V
*/
void Java_org_rocksdb_RocksIterator_next0(
JNIEnv* env, jobject jobj, jlong handle) {
void Java_org_rocksdb_RocksIterator_next0(JNIEnv* /*env*/, jobject /*jobj*/,
jlong handle) {
reinterpret_cast<rocksdb::Iterator*>(handle)->Next();
}
@ -71,8 +75,8 @@ void Java_org_rocksdb_RocksIterator_next0(
* Method: prev0
* Signature: (J)V
*/
void Java_org_rocksdb_RocksIterator_prev0(
JNIEnv* env, jobject jobj, jlong handle) {
void Java_org_rocksdb_RocksIterator_prev0(JNIEnv* /*env*/, jobject /*jobj*/,
jlong handle) {
reinterpret_cast<rocksdb::Iterator*>(handle)->Prev();
}
@ -81,17 +85,16 @@ void Java_org_rocksdb_RocksIterator_prev0(
* Method: seek0
* Signature: (J[BI)V
*/
void Java_org_rocksdb_RocksIterator_seek0(
JNIEnv* env, jobject jobj, jlong handle,
jbyteArray jtarget, jint jtarget_len) {
void Java_org_rocksdb_RocksIterator_seek0(JNIEnv* env, jobject /*jobj*/,
jlong handle, jbyteArray jtarget,
jint jtarget_len) {
jbyte* target = env->GetByteArrayElements(jtarget, nullptr);
if(target == nullptr) {
if (target == nullptr) {
// exception thrown: OutOfMemoryError
return;
}
rocksdb::Slice target_slice(
reinterpret_cast<char*>(target), jtarget_len);
rocksdb::Slice target_slice(reinterpret_cast<char*>(target), jtarget_len);
auto* it = reinterpret_cast<rocksdb::Iterator*>(handle);
it->Seek(target_slice);
@ -104,17 +107,17 @@ void Java_org_rocksdb_RocksIterator_seek0(
* Method: seekForPrev0
* Signature: (J[BI)V
*/
void Java_org_rocksdb_RocksIterator_seekForPrev0(
JNIEnv* env, jobject jobj, jlong handle,
jbyteArray jtarget, jint jtarget_len) {
void Java_org_rocksdb_RocksIterator_seekForPrev0(JNIEnv* env, jobject /*jobj*/,
jlong handle,
jbyteArray jtarget,
jint jtarget_len) {
jbyte* target = env->GetByteArrayElements(jtarget, nullptr);
if(target == nullptr) {
if (target == nullptr) {
// exception thrown: OutOfMemoryError
return;
}
rocksdb::Slice target_slice(
reinterpret_cast<char*>(target), jtarget_len);
rocksdb::Slice target_slice(reinterpret_cast<char*>(target), jtarget_len);
auto* it = reinterpret_cast<rocksdb::Iterator*>(handle);
it->SeekForPrev(target_slice);
@ -127,8 +130,8 @@ void Java_org_rocksdb_RocksIterator_seekForPrev0(
* Method: status0
* Signature: (J)V
*/
void Java_org_rocksdb_RocksIterator_status0(
JNIEnv* env, jobject jobj, jlong handle) {
void Java_org_rocksdb_RocksIterator_status0(JNIEnv* env, jobject /*jobj*/,
jlong handle) {
auto* it = reinterpret_cast<rocksdb::Iterator*>(handle);
rocksdb::Status s = it->status();
@ -144,17 +147,18 @@ void Java_org_rocksdb_RocksIterator_status0(
* Method: key0
* Signature: (J)[B
*/
jbyteArray Java_org_rocksdb_RocksIterator_key0(
JNIEnv* env, jobject jobj, jlong handle) {
jbyteArray Java_org_rocksdb_RocksIterator_key0(JNIEnv* env, jobject /*jobj*/,
jlong handle) {
auto* it = reinterpret_cast<rocksdb::Iterator*>(handle);
rocksdb::Slice key_slice = it->key();
jbyteArray jkey = env->NewByteArray(static_cast<jsize>(key_slice.size()));
if(jkey == nullptr) {
if (jkey == nullptr) {
// exception thrown: OutOfMemoryError
return nullptr;
}
env->SetByteArrayRegion(jkey, 0, static_cast<jsize>(key_slice.size()),
env->SetByteArrayRegion(
jkey, 0, static_cast<jsize>(key_slice.size()),
const_cast<jbyte*>(reinterpret_cast<const jbyte*>(key_slice.data())));
return jkey;
}
@ -164,18 +168,19 @@ jbyteArray Java_org_rocksdb_RocksIterator_key0(
* Method: value0
* Signature: (J)[B
*/
jbyteArray Java_org_rocksdb_RocksIterator_value0(
JNIEnv* env, jobject jobj, jlong handle) {
jbyteArray Java_org_rocksdb_RocksIterator_value0(JNIEnv* env, jobject /*jobj*/,
jlong handle) {
auto* it = reinterpret_cast<rocksdb::Iterator*>(handle);
rocksdb::Slice value_slice = it->value();
jbyteArray jkeyValue =
env->NewByteArray(static_cast<jsize>(value_slice.size()));
if(jkeyValue == nullptr) {
if (jkeyValue == nullptr) {
// exception thrown: OutOfMemoryError
return nullptr;
}
env->SetByteArrayRegion(jkeyValue, 0, static_cast<jsize>(value_slice.size()),
env->SetByteArrayRegion(
jkeyValue, 0, static_cast<jsize>(value_slice.size()),
const_cast<jbyte*>(reinterpret_cast<const jbyte*>(value_slice.data())));
return jkeyValue;
}

@ -8,104 +8,102 @@
#include "include/org_rocksdb_Logger.h"
#include "rocksjni/loggerjnicallback.h"
#include "rocksjni/portal.h"
#include <cstdarg>
#include <cstdio>
#include "rocksjni/loggerjnicallback.h"
#include "rocksjni/portal.h"
namespace rocksdb {
LoggerJniCallback::LoggerJniCallback(
JNIEnv* env, jobject jlogger) : JniCallback(env, jlogger) {
LoggerJniCallback::LoggerJniCallback(JNIEnv* env, jobject jlogger)
: JniCallback(env, jlogger) {
m_jLogMethodId = LoggerJni::getLogMethodId(env);
if(m_jLogMethodId == nullptr) {
if (m_jLogMethodId == nullptr) {
// exception thrown: NoSuchMethodException or OutOfMemoryError
return;
}
jobject jdebug_level = InfoLogLevelJni::DEBUG_LEVEL(env);
if(jdebug_level == nullptr) {
if (jdebug_level == nullptr) {
// exception thrown: NoSuchFieldError, ExceptionInInitializerError
// or OutOfMemoryError
return;
}
m_jdebug_level = env->NewGlobalRef(jdebug_level);
if(m_jdebug_level == nullptr) {
if (m_jdebug_level == nullptr) {
// exception thrown: OutOfMemoryError
return;
}
jobject jinfo_level = InfoLogLevelJni::INFO_LEVEL(env);
if(jinfo_level == nullptr) {
if (jinfo_level == nullptr) {
// exception thrown: NoSuchFieldError, ExceptionInInitializerError
// or OutOfMemoryError
return;
}
m_jinfo_level = env->NewGlobalRef(jinfo_level);
if(m_jinfo_level == nullptr) {
if (m_jinfo_level == nullptr) {
// exception thrown: OutOfMemoryError
return;
}
jobject jwarn_level = InfoLogLevelJni::WARN_LEVEL(env);
if(jwarn_level == nullptr) {
if (jwarn_level == nullptr) {
// exception thrown: NoSuchFieldError, ExceptionInInitializerError
// or OutOfMemoryError
return;
}
m_jwarn_level = env->NewGlobalRef(jwarn_level);
if(m_jwarn_level == nullptr) {
if (m_jwarn_level == nullptr) {
// exception thrown: OutOfMemoryError
return;
}
jobject jerror_level = InfoLogLevelJni::ERROR_LEVEL(env);
if(jerror_level == nullptr) {
if (jerror_level == nullptr) {
// exception thrown: NoSuchFieldError, ExceptionInInitializerError
// or OutOfMemoryError
return;
}
m_jerror_level = env->NewGlobalRef(jerror_level);
if(m_jerror_level == nullptr) {
if (m_jerror_level == nullptr) {
// exception thrown: OutOfMemoryError
return;
}
jobject jfatal_level = InfoLogLevelJni::FATAL_LEVEL(env);
if(jfatal_level == nullptr) {
if (jfatal_level == nullptr) {
// exception thrown: NoSuchFieldError, ExceptionInInitializerError
// or OutOfMemoryError
return;
}
m_jfatal_level = env->NewGlobalRef(jfatal_level);
if(m_jfatal_level == nullptr) {
if (m_jfatal_level == nullptr) {
// exception thrown: OutOfMemoryError
return;
}
jobject jheader_level = InfoLogLevelJni::HEADER_LEVEL(env);
if(jheader_level == nullptr) {
if (jheader_level == nullptr) {
// exception thrown: NoSuchFieldError, ExceptionInInitializerError
// or OutOfMemoryError
return;
}
m_jheader_level = env->NewGlobalRef(jheader_level);
if(m_jheader_level == nullptr) {
if (m_jheader_level == nullptr) {
// exception thrown: OutOfMemoryError
return;
}
}
void LoggerJniCallback::Logv(const char* format, va_list ap) {
void LoggerJniCallback::Logv(const char* /*format*/, va_list /*ap*/) {
// We implement this method because it is virtual but we don't
// use it because we need to know about the log level.
}
void LoggerJniCallback::Logv(const InfoLogLevel log_level,
const char* format, va_list ap) {
void LoggerJniCallback::Logv(const InfoLogLevel log_level, const char* format,
va_list ap) {
if (GetInfoLogLevel() <= log_level) {
// determine InfoLogLevel java enum instance
jobject jlog_level;
switch (log_level) {
@ -142,15 +140,15 @@ void LoggerJniCallback::Logv(const InfoLogLevel log_level,
assert(env != nullptr);
jstring jmsg = env->NewStringUTF(msg.get());
if(jmsg == nullptr) {
if (jmsg == nullptr) {
// unable to construct string
if(env->ExceptionCheck()) {
if (env->ExceptionCheck()) {
env->ExceptionDescribe(); // print out exception to stderr
}
releaseJniEnv(attached_thread);
return;
}
if(env->ExceptionCheck()) {
if (env->ExceptionCheck()) {
// exception thrown: OutOfMemoryError
env->ExceptionDescribe(); // print out exception to stderr
env->DeleteLocalRef(jmsg);
@ -159,7 +157,7 @@ void LoggerJniCallback::Logv(const InfoLogLevel log_level,
}
env->CallVoidMethod(m_jcallback_obj, m_jLogMethodId, jlog_level, jmsg);
if(env->ExceptionCheck()) {
if (env->ExceptionCheck()) {
// exception thrown
env->ExceptionDescribe(); // print out exception to stderr
env->DeleteLocalRef(jmsg);
@ -172,11 +170,13 @@ void LoggerJniCallback::Logv(const InfoLogLevel log_level,
}
}
std::unique_ptr<char[]> LoggerJniCallback::format_str(const char* format, va_list ap) const {
std::unique_ptr<char[]> LoggerJniCallback::format_str(const char* format,
va_list ap) const {
va_list ap_copy;
va_copy(ap_copy, ap);
const size_t required = vsnprintf(nullptr, 0, format, ap_copy) + 1; // Extra space for '\0'
const size_t required =
vsnprintf(nullptr, 0, format, ap_copy) + 1; // Extra space for '\0'
va_end(ap_copy);
std::unique_ptr<char[]> buf(new char[required]);
@ -192,27 +192,27 @@ LoggerJniCallback::~LoggerJniCallback() {
JNIEnv* env = getJniEnv(&attached_thread);
assert(env != nullptr);
if(m_jdebug_level != nullptr) {
if (m_jdebug_level != nullptr) {
env->DeleteGlobalRef(m_jdebug_level);
}
if(m_jinfo_level != nullptr) {
if (m_jinfo_level != nullptr) {
env->DeleteGlobalRef(m_jinfo_level);
}
if(m_jwarn_level != nullptr) {
if (m_jwarn_level != nullptr) {
env->DeleteGlobalRef(m_jwarn_level);
}
if(m_jerror_level != nullptr) {
if (m_jerror_level != nullptr) {
env->DeleteGlobalRef(m_jerror_level);
}
if(m_jfatal_level != nullptr) {
if (m_jfatal_level != nullptr) {
env->DeleteGlobalRef(m_jfatal_level);
}
if(m_jheader_level != nullptr) {
if (m_jheader_level != nullptr) {
env->DeleteGlobalRef(m_jheader_level);
}
@ -226,8 +226,8 @@ LoggerJniCallback::~LoggerJniCallback() {
* Method: createNewLoggerOptions
* Signature: (J)J
*/
jlong Java_org_rocksdb_Logger_createNewLoggerOptions(
JNIEnv* env, jobject jobj, jlong joptions) {
jlong Java_org_rocksdb_Logger_createNewLoggerOptions(JNIEnv* env, jobject jobj,
jlong joptions) {
auto* sptr_logger = new std::shared_ptr<rocksdb::LoggerJniCallback>(
new rocksdb::LoggerJniCallback(env, jobj));
@ -243,8 +243,9 @@ jlong Java_org_rocksdb_Logger_createNewLoggerOptions(
* Method: createNewLoggerDbOptions
* Signature: (J)J
*/
jlong Java_org_rocksdb_Logger_createNewLoggerDbOptions(
JNIEnv* env, jobject jobj, jlong jdb_options) {
jlong Java_org_rocksdb_Logger_createNewLoggerDbOptions(JNIEnv* env,
jobject jobj,
jlong jdb_options) {
auto* sptr_logger = new std::shared_ptr<rocksdb::LoggerJniCallback>(
new rocksdb::LoggerJniCallback(env, jobj));
@ -260,12 +261,12 @@ jlong Java_org_rocksdb_Logger_createNewLoggerDbOptions(
* Method: setInfoLogLevel
* Signature: (JB)V
*/
void Java_org_rocksdb_Logger_setInfoLogLevel(
JNIEnv* env, jobject jobj, jlong jhandle, jbyte jlog_level) {
void Java_org_rocksdb_Logger_setInfoLogLevel(JNIEnv* /*env*/, jobject /*jobj*/,
jlong jhandle, jbyte jlog_level) {
auto* handle =
reinterpret_cast<std::shared_ptr<rocksdb::LoggerJniCallback> *>(jhandle);
handle->get()->
SetInfoLogLevel(static_cast<rocksdb::InfoLogLevel>(jlog_level));
reinterpret_cast<std::shared_ptr<rocksdb::LoggerJniCallback>*>(jhandle);
handle->get()->SetInfoLogLevel(
static_cast<rocksdb::InfoLogLevel>(jlog_level));
}
/*
@ -273,10 +274,10 @@ void Java_org_rocksdb_Logger_setInfoLogLevel(
* Method: infoLogLevel
* Signature: (J)B
*/
jbyte Java_org_rocksdb_Logger_infoLogLevel(
JNIEnv* env, jobject jobj, jlong jhandle) {
jbyte Java_org_rocksdb_Logger_infoLogLevel(JNIEnv* /*env*/, jobject /*jobj*/,
jlong jhandle) {
auto* handle =
reinterpret_cast<std::shared_ptr<rocksdb::LoggerJniCallback> *>(jhandle);
reinterpret_cast<std::shared_ptr<rocksdb::LoggerJniCallback>*>(jhandle);
return static_cast<jbyte>(handle->get()->GetInfoLogLevel());
}
@ -285,9 +286,9 @@ jbyte Java_org_rocksdb_Logger_infoLogLevel(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_Logger_disposeInternal(
JNIEnv* env, jobject jobj, jlong jhandle) {
void Java_org_rocksdb_Logger_disposeInternal(JNIEnv* /*env*/, jobject /*jobj*/,
jlong jhandle) {
auto* handle =
reinterpret_cast<std::shared_ptr<rocksdb::LoggerJniCallback> *>(jhandle);
reinterpret_cast<std::shared_ptr<rocksdb::LoggerJniCallback>*>(jhandle);
delete handle; // delete std::shared_ptr
}

@ -16,13 +16,14 @@
* Method: newLRUCache
* Signature: (JIZD)J
*/
jlong Java_org_rocksdb_LRUCache_newLRUCache(
JNIEnv* env, jclass jcls, jlong jcapacity, jint jnum_shard_bits,
jboolean jstrict_capacity_limit, jdouble jhigh_pri_pool_ratio) {
jlong Java_org_rocksdb_LRUCache_newLRUCache(JNIEnv* /*env*/, jclass /*jcls*/,
jlong jcapacity,
jint jnum_shard_bits,
jboolean jstrict_capacity_limit,
jdouble jhigh_pri_pool_ratio) {
auto* sptr_lru_cache =
new std::shared_ptr<rocksdb::Cache>(rocksdb::NewLRUCache(
static_cast<size_t>(jcapacity),
static_cast<int>(jnum_shard_bits),
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<jlong>(sptr_lru_cache);
@ -33,9 +34,10 @@ jlong Java_org_rocksdb_LRUCache_newLRUCache(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_LRUCache_disposeInternal(
JNIEnv* env, jobject jobj, jlong jhandle) {
void Java_org_rocksdb_LRUCache_disposeInternal(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* sptr_lru_cache =
reinterpret_cast<std::shared_ptr<rocksdb::Cache> *>(jhandle);
reinterpret_cast<std::shared_ptr<rocksdb::Cache>*>(jhandle);
delete sptr_lru_cache; // delete std::shared_ptr
}

@ -5,12 +5,12 @@
//
// This file implements the "bridge" between Java and C++ for MemTables.
#include "rocksjni/portal.h"
#include "include/org_rocksdb_HashSkipListMemTableConfig.h"
#include "include/org_rocksdb_HashLinkedListMemTableConfig.h"
#include "include/org_rocksdb_VectorMemTableConfig.h"
#include "include/org_rocksdb_HashSkipListMemTableConfig.h"
#include "include/org_rocksdb_SkipListMemTableConfig.h"
#include "include/org_rocksdb_VectorMemTableConfig.h"
#include "rocksdb/memtablerep.h"
#include "rocksjni/portal.h"
/*
* Class: org_rocksdb_HashSkipListMemTableConfig
@ -18,13 +18,12 @@
* Signature: (JII)J
*/
jlong Java_org_rocksdb_HashSkipListMemTableConfig_newMemTableFactoryHandle(
JNIEnv* env, jobject jobj, jlong jbucket_count,
jint jheight, jint jbranching_factor) {
JNIEnv* env, jobject /*jobj*/, jlong jbucket_count, jint jheight,
jint jbranching_factor) {
rocksdb::Status s = rocksdb::check_if_jlong_fits_size_t(jbucket_count);
if (s.ok()) {
return reinterpret_cast<jlong>(rocksdb::NewHashSkipListRepFactory(
static_cast<size_t>(jbucket_count),
static_cast<int32_t>(jheight),
static_cast<size_t>(jbucket_count), static_cast<int32_t>(jheight),
static_cast<int32_t>(jbranching_factor)));
}
rocksdb::IllegalArgumentExceptionJni::ThrowNew(env, s);
@ -37,8 +36,8 @@ jlong Java_org_rocksdb_HashSkipListMemTableConfig_newMemTableFactoryHandle(
* Signature: (JJIZI)J
*/
jlong Java_org_rocksdb_HashLinkedListMemTableConfig_newMemTableFactoryHandle(
JNIEnv* env, jobject jobj, jlong jbucket_count, jlong jhuge_page_tlb_size,
jint jbucket_entries_logging_threshold,
JNIEnv* env, jobject /*jobj*/, jlong jbucket_count,
jlong jhuge_page_tlb_size, jint jbucket_entries_logging_threshold,
jboolean jif_log_bucket_dist_when_flash, jint jthreshold_use_skiplist) {
rocksdb::Status statusBucketCount =
rocksdb::check_if_jlong_fits_size_t(jbucket_count);
@ -52,8 +51,8 @@ jlong Java_org_rocksdb_HashLinkedListMemTableConfig_newMemTableFactoryHandle(
static_cast<bool>(jif_log_bucket_dist_when_flash),
static_cast<int32_t>(jthreshold_use_skiplist)));
}
rocksdb::IllegalArgumentExceptionJni::ThrowNew(env,
!statusBucketCount.ok()?statusBucketCount:statusHugePageTlb);
rocksdb::IllegalArgumentExceptionJni::ThrowNew(
env, !statusBucketCount.ok() ? statusBucketCount : statusHugePageTlb);
return 0;
}
@ -63,11 +62,11 @@ jlong Java_org_rocksdb_HashLinkedListMemTableConfig_newMemTableFactoryHandle(
* Signature: (J)J
*/
jlong Java_org_rocksdb_VectorMemTableConfig_newMemTableFactoryHandle(
JNIEnv* env, jobject jobj, jlong jreserved_size) {
JNIEnv* env, jobject /*jobj*/, jlong jreserved_size) {
rocksdb::Status s = rocksdb::check_if_jlong_fits_size_t(jreserved_size);
if (s.ok()) {
return reinterpret_cast<jlong>(new rocksdb::VectorRepFactory(
static_cast<size_t>(jreserved_size)));
return reinterpret_cast<jlong>(
new rocksdb::VectorRepFactory(static_cast<size_t>(jreserved_size)));
}
rocksdb::IllegalArgumentExceptionJni::ThrowNew(env, s);
return 0;
@ -79,11 +78,11 @@ jlong Java_org_rocksdb_VectorMemTableConfig_newMemTableFactoryHandle(
* Signature: (J)J
*/
jlong Java_org_rocksdb_SkipListMemTableConfig_newMemTableFactoryHandle0(
JNIEnv* env, jobject jobj, jlong jlookahead) {
JNIEnv* env, jobject /*jobj*/, jlong jlookahead) {
rocksdb::Status s = rocksdb::check_if_jlong_fits_size_t(jlookahead);
if (s.ok()) {
return reinterpret_cast<jlong>(new rocksdb::SkipListFactory(
static_cast<size_t>(jlookahead)));
return reinterpret_cast<jlong>(
new rocksdb::SkipListFactory(static_cast<size_t>(jlookahead)));
}
rocksdb::IllegalArgumentExceptionJni::ThrowNew(env, s);
return 0;

@ -6,21 +6,21 @@
// This file implements the "bridge" between Java and C++
// for rocksdb::MergeOperator.
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <jni.h>
#include <string>
#include <memory>
#include <string>
#include "include/org_rocksdb_StringAppendOperator.h"
#include "rocksjni/portal.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/memtablerep.h"
#include "rocksdb/table.h"
#include "rocksdb/slice_transform.h"
#include "rocksdb/merge_operator.h"
#include "rocksjni/portal.h"
#include "utilities/merge_operators.h"
/*
@ -28,10 +28,10 @@
* Method: newSharedStringAppendOperator
* Signature: (C)J
*/
jlong Java_org_rocksdb_StringAppendOperator_newSharedStringAppendOperator
(JNIEnv* env, jclass jclazz, jchar jdelim) {
jlong Java_org_rocksdb_StringAppendOperator_newSharedStringAppendOperator(
JNIEnv* /*env*/, jclass /*jclazz*/, jchar jdelim) {
auto* sptr_string_append_op = new std::shared_ptr<rocksdb::MergeOperator>(
rocksdb::MergeOperators::CreateStringAppendOperator((char) jdelim));
rocksdb::MergeOperators::CreateStringAppendOperator((char)jdelim));
return reinterpret_cast<jlong>(sptr_string_append_op);
}
@ -40,9 +40,10 @@ jlong Java_org_rocksdb_StringAppendOperator_newSharedStringAppendOperator
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_StringAppendOperator_disposeInternal(
JNIEnv* env, jobject jobj, jlong jhandle) {
void Java_org_rocksdb_StringAppendOperator_disposeInternal(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* sptr_string_append_op =
reinterpret_cast<std::shared_ptr<rocksdb::MergeOperator>* >(jhandle);
reinterpret_cast<std::shared_ptr<rocksdb::MergeOperator>*>(jhandle);
delete sptr_string_append_op; // delete std::shared_ptr
}

@ -13,29 +13,23 @@
namespace rocksdb {
class NativeComparatorWrapperTestStringComparator
: public Comparator {
class NativeComparatorWrapperTestStringComparator : public Comparator {
const char* Name() const {
return "NativeComparatorWrapperTestStringComparator";
}
int Compare(
const Slice& a, const Slice& b) const {
int Compare(const Slice& a, const Slice& b) const {
return a.ToString().compare(b.ToString());
}
void FindShortestSeparator(
std::string* start, const Slice& limit) const {
void FindShortestSeparator(std::string* /*start*/,
const Slice& /*limit*/) const {
return;
}
void FindShortSuccessor(
std::string* key) const {
return;
}
void FindShortSuccessor(std::string* /*key*/) const { return; }
};
} // end of rocksdb namespace
} // namespace rocksdb
/*
* Class: org_rocksdb_NativeComparatorWrapperTest_NativeStringComparatorWrapper
@ -43,8 +37,7 @@ class NativeComparatorWrapperTestStringComparator
* Signature: ()J
*/
jlong Java_org_rocksdb_NativeComparatorWrapperTest_00024NativeStringComparatorWrapper_newStringComparator(
JNIEnv* env , jobject jobj) {
auto* comparator =
new rocksdb::NativeComparatorWrapperTestStringComparator();
JNIEnv* /*env*/, jobject /*jobj*/) {
auto* comparator = new rocksdb::NativeComparatorWrapperTestStringComparator();
return reinterpret_cast<jlong>(comparator);
}

@ -22,7 +22,7 @@
* Signature: (JLjava/lang/String;)J
*/
jlong Java_org_rocksdb_OptimisticTransactionDB_open__JLjava_lang_String_2(
JNIEnv* env, jclass jcls, jlong joptions_handle, jstring jdb_path) {
JNIEnv* env, jclass /*jcls*/, jlong joptions_handle, jstring jdb_path) {
const char* db_path = env->GetStringUTFChars(jdb_path, nullptr);
if (db_path == nullptr) {
// exception thrown: OutOfMemoryError
@ -48,8 +48,9 @@ jlong Java_org_rocksdb_OptimisticTransactionDB_open__JLjava_lang_String_2(
* Method: open
* Signature: (JLjava/lang/String;[[B[J)[J
*/
jlongArray Java_org_rocksdb_OptimisticTransactionDB_open__JLjava_lang_String_2_3_3B_3J(
JNIEnv* env, jclass jcls, jlong jdb_options_handle, jstring jdb_path,
jlongArray
Java_org_rocksdb_OptimisticTransactionDB_open__JLjava_lang_String_2_3_3B_3J(
JNIEnv* env, jclass /*jcls*/, jlong jdb_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) {
@ -66,9 +67,8 @@ jlongArray Java_org_rocksdb_OptimisticTransactionDB_open__JLjava_lang_String_2_3
return nullptr;
}
jlong* jco =
env->GetLongArrayElements(jcolumn_options_handles, nullptr);
if(jco == nullptr) {
jlong* jco = env->GetLongArrayElements(jcolumn_options_handles, nullptr);
if (jco == nullptr) {
// exception thrown: OutOfMemoryError
env->ReleaseStringUTFChars(jdb_path, db_path);
return nullptr;
@ -102,7 +102,8 @@ jlongArray Java_org_rocksdb_OptimisticTransactionDB_open__JLjava_lang_String_2_3
return nullptr;
}
const std::string cf_name(reinterpret_cast<char *>(jcf_name), jcf_name_len);
const std::string cf_name(reinterpret_cast<char*>(jcf_name),
jcf_name_len);
const rocksdb::ColumnFamilyOptions* cf_options =
reinterpret_cast<rocksdb::ColumnFamilyOptions*>(jco[i]);
column_families.push_back(
@ -117,8 +118,8 @@ jlongArray Java_org_rocksdb_OptimisticTransactionDB_open__JLjava_lang_String_2_3
auto* db_options = reinterpret_cast<rocksdb::DBOptions*>(jdb_options_handle);
std::vector<rocksdb::ColumnFamilyHandle*> handles;
rocksdb::OptimisticTransactionDB* otdb = nullptr;
const rocksdb::Status s = rocksdb::OptimisticTransactionDB::Open(*db_options,
db_path, column_families, &handles, &otdb);
const rocksdb::Status s = rocksdb::OptimisticTransactionDB::Open(
*db_options, db_path, column_families, &handles, &otdb);
env->ReleaseStringUTFChars(jdb_path, db_path);
@ -155,7 +156,8 @@ jlongArray Java_org_rocksdb_OptimisticTransactionDB_open__JLjava_lang_String_2_3
* Signature: (JJ)J
*/
jlong Java_org_rocksdb_OptimisticTransactionDB_beginTransaction__JJ(
JNIEnv* env, jobject jobj, jlong jhandle, jlong jwrite_options_handle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jlong jwrite_options_handle) {
auto* optimistic_txn_db =
reinterpret_cast<rocksdb::OptimisticTransactionDB*>(jhandle);
auto* write_options =
@ -171,8 +173,8 @@ jlong Java_org_rocksdb_OptimisticTransactionDB_beginTransaction__JJ(
* Signature: (JJJ)J
*/
jlong Java_org_rocksdb_OptimisticTransactionDB_beginTransaction__JJJ(
JNIEnv* env, jobject jobj, jlong jhandle, jlong jwrite_options_handle,
jlong joptimistic_txn_options_handle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jlong jwrite_options_handle, jlong joptimistic_txn_options_handle) {
auto* optimistic_txn_db =
reinterpret_cast<rocksdb::OptimisticTransactionDB*>(jhandle);
auto* write_options =
@ -180,9 +182,8 @@ jlong Java_org_rocksdb_OptimisticTransactionDB_beginTransaction__JJJ(
auto* optimistic_txn_options =
reinterpret_cast<rocksdb::OptimisticTransactionOptions*>(
joptimistic_txn_options_handle);
rocksdb::Transaction* txn =
optimistic_txn_db->BeginTransaction(*write_options,
*optimistic_txn_options);
rocksdb::Transaction* txn = optimistic_txn_db->BeginTransaction(
*write_options, *optimistic_txn_options);
return reinterpret_cast<jlong>(txn);
}
@ -192,19 +193,16 @@ jlong Java_org_rocksdb_OptimisticTransactionDB_beginTransaction__JJJ(
* Signature: (JJJ)J
*/
jlong Java_org_rocksdb_OptimisticTransactionDB_beginTransaction_1withOld__JJJ(
JNIEnv* env, jobject jobj, jlong jhandle, jlong jwrite_options_handle,
jlong jold_txn_handle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jlong jwrite_options_handle, jlong jold_txn_handle) {
auto* optimistic_txn_db =
reinterpret_cast<rocksdb::OptimisticTransactionDB*>(jhandle);
auto* write_options =
reinterpret_cast<rocksdb::WriteOptions*>(jwrite_options_handle);
auto* old_txn =
reinterpret_cast<rocksdb::Transaction*>(
jold_txn_handle);
auto* old_txn = reinterpret_cast<rocksdb::Transaction*>(jold_txn_handle);
rocksdb::OptimisticTransactionOptions optimistic_txn_options;
rocksdb::Transaction* txn =
optimistic_txn_db->BeginTransaction(*write_options,
optimistic_txn_options, old_txn);
rocksdb::Transaction* txn = optimistic_txn_db->BeginTransaction(
*write_options, optimistic_txn_options, old_txn);
// RocksJava relies on the assumption that
// we do not allocate a new Transaction object
@ -220,8 +218,9 @@ jlong Java_org_rocksdb_OptimisticTransactionDB_beginTransaction_1withOld__JJJ(
* Signature: (JJJJ)J
*/
jlong Java_org_rocksdb_OptimisticTransactionDB_beginTransaction_1withOld__JJJJ(
JNIEnv* env, jobject jobj, jlong jhandle, jlong jwrite_options_handle,
jlong joptimistic_txn_options_handle, jlong jold_txn_handle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jlong jwrite_options_handle, jlong joptimistic_txn_options_handle,
jlong jold_txn_handle) {
auto* optimistic_txn_db =
reinterpret_cast<rocksdb::OptimisticTransactionDB*>(jhandle);
auto* write_options =
@ -229,12 +228,9 @@ jlong Java_org_rocksdb_OptimisticTransactionDB_beginTransaction_1withOld__JJJJ(
auto* optimistic_txn_options =
reinterpret_cast<rocksdb::OptimisticTransactionOptions*>(
joptimistic_txn_options_handle);
auto* old_txn =
reinterpret_cast<rocksdb::Transaction*>(
jold_txn_handle);
rocksdb::Transaction* txn =
optimistic_txn_db->BeginTransaction(*write_options,
*optimistic_txn_options, old_txn);
auto* old_txn = reinterpret_cast<rocksdb::Transaction*>(jold_txn_handle);
rocksdb::Transaction* txn = optimistic_txn_db->BeginTransaction(
*write_options, *optimistic_txn_options, old_txn);
// RocksJava relies on the assumption that
// we do not allocate a new Transaction object
@ -249,8 +245,9 @@ jlong Java_org_rocksdb_OptimisticTransactionDB_beginTransaction_1withOld__JJJJ(
* Method: getBaseDB
* Signature: (J)J
*/
jlong Java_org_rocksdb_OptimisticTransactionDB_getBaseDB(
JNIEnv* env, jobject jobj, jlong jhandle) {
jlong Java_org_rocksdb_OptimisticTransactionDB_getBaseDB(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* optimistic_txn_db =
reinterpret_cast<rocksdb::OptimisticTransactionDB*>(jhandle);
return reinterpret_cast<jlong>(optimistic_txn_db->GetBaseDB());
@ -261,7 +258,8 @@ jlong Java_org_rocksdb_OptimisticTransactionDB_getBaseDB(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_OptimisticTransactionDB_disposeInternal(JNIEnv* env,
jobject jobj, jlong jhandle) {
void Java_org_rocksdb_OptimisticTransactionDB_disposeInternal(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
delete reinterpret_cast<rocksdb::OptimisticTransactionDB*>(jhandle);
}

@ -19,7 +19,7 @@
* Signature: ()J
*/
jlong Java_org_rocksdb_OptimisticTransactionOptions_newOptimisticTransactionOptions(
JNIEnv* env, jclass jcls) {
JNIEnv* /*env*/, jclass /*jcls*/) {
rocksdb::OptimisticTransactionOptions* opts =
new rocksdb::OptimisticTransactionOptions();
return reinterpret_cast<jlong>(opts);
@ -31,7 +31,7 @@ jlong Java_org_rocksdb_OptimisticTransactionOptions_newOptimisticTransactionOpti
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_OptimisticTransactionOptions_isSetSnapshot(
JNIEnv* env, jobject jobj, jlong jhandle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
auto* opts =
reinterpret_cast<rocksdb::OptimisticTransactionOptions*>(jhandle);
return opts->set_snapshot;
@ -42,8 +42,8 @@ jboolean Java_org_rocksdb_OptimisticTransactionOptions_isSetSnapshot(
* Method: setSetSnapshot
* Signature: (JZ)V
*/
void Java_org_rocksdb_OptimisticTransactionOptions_setSetSnapshot(JNIEnv* env,
jobject jobj, jlong jhandle, jboolean jset_snapshot) {
void Java_org_rocksdb_OptimisticTransactionOptions_setSetSnapshot(
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jboolean jset_snapshot) {
auto* opts =
reinterpret_cast<rocksdb::OptimisticTransactionOptions*>(jhandle);
opts->set_snapshot = jset_snapshot;
@ -55,7 +55,8 @@ void Java_org_rocksdb_OptimisticTransactionOptions_setSetSnapshot(JNIEnv* env,
* Signature: (JJ)V
*/
void Java_org_rocksdb_OptimisticTransactionOptions_setComparator(
JNIEnv* env, jobject jobj, jlong jhandle, jlong jcomparator_handle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jlong jcomparator_handle) {
auto* opts =
reinterpret_cast<rocksdb::OptimisticTransactionOptions*>(jhandle);
opts->cmp = reinterpret_cast<rocksdb::Comparator*>(jcomparator_handle);
@ -66,7 +67,7 @@ void Java_org_rocksdb_OptimisticTransactionOptions_setComparator(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_OptimisticTransactionOptions_disposeInternal(JNIEnv* env,
jobject jobj, jlong jhandle) {
void Java_org_rocksdb_OptimisticTransactionOptions_disposeInternal(
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
delete reinterpret_cast<rocksdb::OptimisticTransactionOptions*>(jhandle);
}

File diff suppressed because it is too large Load Diff

@ -54,7 +54,7 @@ void build_column_family_descriptor_list(
* Signature: (Ljava/lang/String;JLjava/util/List;Z)V
*/
void Java_org_rocksdb_OptionsUtil_loadLatestOptions(
JNIEnv* env, jclass jcls, jstring jdbpath, jlong jenv_handle,
JNIEnv* env, jclass /*jcls*/, jstring jdbpath, jlong jenv_handle,
jlong jdb_opts_handle, jobject jcfds, jboolean ignore_unknown_options) {
const char* db_path = env->GetStringUTFChars(jdbpath, nullptr);
std::vector<rocksdb::ColumnFamilyDescriptor> cf_descs;
@ -77,7 +77,7 @@ void Java_org_rocksdb_OptionsUtil_loadLatestOptions(
* Signature: (Ljava/lang/String;JJLjava/util/List;Z)V
*/
void Java_org_rocksdb_OptionsUtil_loadOptionsFromFile(
JNIEnv* env, jclass jcls, jstring jopts_file_name, jlong jenv_handle,
JNIEnv* env, jclass /*jcls*/, jstring jopts_file_name, jlong jenv_handle,
jlong jdb_opts_handle, jobject jcfds, jboolean ignore_unknown_options) {
const char* opts_file_name = env->GetStringUTFChars(jopts_file_name, nullptr);
std::vector<rocksdb::ColumnFamilyDescriptor> cf_descs;
@ -100,7 +100,7 @@ void Java_org_rocksdb_OptionsUtil_loadOptionsFromFile(
* Signature: (Ljava/lang/String;J)Ljava/lang/String;
*/
jstring Java_org_rocksdb_OptionsUtil_getLatestOptionsFileName(
JNIEnv* env, jclass jcls, jstring jdbpath, jlong jenv_handle) {
JNIEnv* env, jclass /*jcls*/, jstring jdbpath, jlong jenv_handle) {
const char* db_path = env->GetStringUTFChars(jdbpath, nullptr);
std::string options_file_name;
if (db_path != nullptr) {

@ -4506,7 +4506,7 @@ class JniUtil {
*/
static std::unique_ptr<rocksdb::Status> kv_op(
std::function<rocksdb::Status(rocksdb::Slice, rocksdb::Slice)> op,
JNIEnv* env, jobject jobj,
JNIEnv* env, jobject /*jobj*/,
jbyteArray jkey, jint jkey_len,
jbyteArray jvalue, jint jvalue_len) {
jbyte* key = env->GetByteArrayElements(jkey, nullptr);
@ -4548,7 +4548,7 @@ class JniUtil {
*/
static std::unique_ptr<rocksdb::Status> k_op(
std::function<rocksdb::Status(rocksdb::Slice)> op,
JNIEnv* env, jobject jobj,
JNIEnv* env, jobject /*jobj*/,
jbyteArray jkey, jint jkey_len) {
jbyte* key = env->GetByteArrayElements(jkey, nullptr);
if(env->ExceptionCheck()) {

@ -5,9 +5,9 @@
//
// This file implements the "bridge" between Java and C++ for RateLimiter.
#include "rocksjni/portal.h"
#include "include/org_rocksdb_RateLimiter.h"
#include "rocksdb/rate_limiter.h"
#include "rocksjni/portal.h"
/*
* Class: org_rocksdb_RateLimiter
@ -15,18 +15,16 @@
* Signature: (JJIBZ)J
*/
jlong Java_org_rocksdb_RateLimiter_newRateLimiterHandle(
JNIEnv* env, jclass jclazz, jlong jrate_bytes_per_second,
JNIEnv* /*env*/, jclass /*jclazz*/, jlong jrate_bytes_per_second,
jlong jrefill_period_micros, jint jfairness, jbyte jrate_limiter_mode,
jboolean jauto_tune) {
auto rate_limiter_mode = rocksdb::RateLimiterModeJni::toCppRateLimiterMode(
jrate_limiter_mode);
auto * sptr_rate_limiter =
auto rate_limiter_mode =
rocksdb::RateLimiterModeJni::toCppRateLimiterMode(jrate_limiter_mode);
auto* sptr_rate_limiter =
new std::shared_ptr<rocksdb::RateLimiter>(rocksdb::NewGenericRateLimiter(
static_cast<int64_t>(jrate_bytes_per_second),
static_cast<int64_t>(jrefill_period_micros),
static_cast<int32_t>(jfairness),
rate_limiter_mode,
jauto_tune));
static_cast<int32_t>(jfairness), rate_limiter_mode, jauto_tune));
return reinterpret_cast<jlong>(sptr_rate_limiter);
}
@ -36,10 +34,11 @@ jlong Java_org_rocksdb_RateLimiter_newRateLimiterHandle(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_RateLimiter_disposeInternal(
JNIEnv* env, jobject jobj, jlong jhandle) {
void Java_org_rocksdb_RateLimiter_disposeInternal(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* handle =
reinterpret_cast<std::shared_ptr<rocksdb::RateLimiter> *>(jhandle);
reinterpret_cast<std::shared_ptr<rocksdb::RateLimiter>*>(jhandle);
delete handle; // delete std::shared_ptr
}
@ -48,11 +47,13 @@ void Java_org_rocksdb_RateLimiter_disposeInternal(
* Method: setBytesPerSecond
* Signature: (JJ)V
*/
void Java_org_rocksdb_RateLimiter_setBytesPerSecond(
JNIEnv* env, jobject jobj, jlong handle,
void Java_org_rocksdb_RateLimiter_setBytesPerSecond(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong handle,
jlong jbytes_per_second) {
reinterpret_cast<std::shared_ptr<rocksdb::RateLimiter> *>(handle)->get()->
SetBytesPerSecond(jbytes_per_second);
reinterpret_cast<std::shared_ptr<rocksdb::RateLimiter>*>(handle)
->get()
->SetBytesPerSecond(jbytes_per_second);
}
/*
@ -60,10 +61,12 @@ void Java_org_rocksdb_RateLimiter_setBytesPerSecond(
* Method: getBytesPerSecond
* Signature: (J)J
*/
jlong Java_org_rocksdb_RateLimiter_getBytesPerSecond(
JNIEnv* env, jobject jobj, jlong handle) {
return reinterpret_cast<std::shared_ptr<rocksdb::RateLimiter> *>(handle)->get()->
GetBytesPerSecond();
jlong Java_org_rocksdb_RateLimiter_getBytesPerSecond(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong handle) {
return reinterpret_cast<std::shared_ptr<rocksdb::RateLimiter>*>(handle)
->get()
->GetBytesPerSecond();
}
/*
@ -71,11 +74,11 @@ jlong Java_org_rocksdb_RateLimiter_getBytesPerSecond(
* Method: request
* Signature: (JJ)V
*/
void Java_org_rocksdb_RateLimiter_request(
JNIEnv* env, jobject jobj, jlong handle,
jlong jbytes) {
reinterpret_cast<std::shared_ptr<rocksdb::RateLimiter> *>(handle)->get()->
Request(jbytes, rocksdb::Env::IO_TOTAL);
void Java_org_rocksdb_RateLimiter_request(JNIEnv* /*env*/, jobject /*jobj*/,
jlong handle, jlong jbytes) {
reinterpret_cast<std::shared_ptr<rocksdb::RateLimiter>*>(handle)
->get()
->Request(jbytes, rocksdb::Env::IO_TOTAL);
}
/*
@ -83,10 +86,12 @@ void Java_org_rocksdb_RateLimiter_request(
* Method: getSingleBurstBytes
* Signature: (J)J
*/
jlong Java_org_rocksdb_RateLimiter_getSingleBurstBytes(
JNIEnv* env, jobject jobj, jlong handle) {
return reinterpret_cast<std::shared_ptr<rocksdb::RateLimiter> *>(handle)->
get()->GetSingleBurstBytes();
jlong Java_org_rocksdb_RateLimiter_getSingleBurstBytes(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong handle) {
return reinterpret_cast<std::shared_ptr<rocksdb::RateLimiter>*>(handle)
->get()
->GetSingleBurstBytes();
}
/*
@ -94,10 +99,12 @@ jlong Java_org_rocksdb_RateLimiter_getSingleBurstBytes(
* Method: getTotalBytesThrough
* Signature: (J)J
*/
jlong Java_org_rocksdb_RateLimiter_getTotalBytesThrough(
JNIEnv* env, jobject jobj, jlong handle) {
return reinterpret_cast<std::shared_ptr<rocksdb::RateLimiter> *>(handle)->
get()->GetTotalBytesThrough();
jlong Java_org_rocksdb_RateLimiter_getTotalBytesThrough(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong handle) {
return reinterpret_cast<std::shared_ptr<rocksdb::RateLimiter>*>(handle)
->get()
->GetTotalBytesThrough();
}
/*
@ -105,8 +112,10 @@ jlong Java_org_rocksdb_RateLimiter_getTotalBytesThrough(
* Method: getTotalRequests
* Signature: (J)J
*/
jlong Java_org_rocksdb_RateLimiter_getTotalRequests(
JNIEnv* env, jobject jobj, jlong handle) {
return reinterpret_cast<std::shared_ptr<rocksdb::RateLimiter> *>(handle)->
get()->GetTotalRequests();
jlong Java_org_rocksdb_RateLimiter_getTotalRequests(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong handle) {
return reinterpret_cast<std::shared_ptr<rocksdb::RateLimiter>*>(handle)
->get()
->GetTotalRequests();
}

@ -8,16 +8,14 @@
#include "include/org_rocksdb_RemoveEmptyValueCompactionFilter.h"
#include "utilities/compaction_filters/remove_emptyvalue_compactionfilter.h"
/*
* Class: org_rocksdb_RemoveEmptyValueCompactionFilter
* Method: createNewRemoveEmptyValueCompactionFilter0
* Signature: ()J
*/
jlong Java_org_rocksdb_RemoveEmptyValueCompactionFilter_createNewRemoveEmptyValueCompactionFilter0(
JNIEnv* env, jclass jcls) {
auto* compaction_filter =
new rocksdb::RemoveEmptyValueCompactionFilter();
JNIEnv* /*env*/, jclass /*jcls*/) {
auto* compaction_filter = new rocksdb::RemoveEmptyValueCompactionFilter();
// set the native handle to our native compaction filter
return reinterpret_cast<jlong>(compaction_filter);

@ -7,21 +7,21 @@
// calling C++ rocksdb::RestoreOptions methods
// from Java side.
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <jni.h>
#include <string>
#include "include/org_rocksdb_RestoreOptions.h"
#include "rocksjni/portal.h"
#include "rocksdb/utilities/backupable_db.h"
#include "rocksjni/portal.h"
/*
* Class: org_rocksdb_RestoreOptions
* Method: newRestoreOptions
* Signature: (Z)J
*/
jlong Java_org_rocksdb_RestoreOptions_newRestoreOptions(JNIEnv* env,
jclass jcls, jboolean keep_log_files) {
jlong Java_org_rocksdb_RestoreOptions_newRestoreOptions(
JNIEnv* /*env*/, jclass /*jcls*/, jboolean keep_log_files) {
auto* ropt = new rocksdb::RestoreOptions(keep_log_files);
return reinterpret_cast<jlong>(ropt);
}
@ -31,7 +31,8 @@ jlong Java_org_rocksdb_RestoreOptions_newRestoreOptions(JNIEnv* env,
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_RestoreOptions_disposeInternal(JNIEnv* env, jobject jobj,
void Java_org_rocksdb_RestoreOptions_disposeInternal(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* ropt = reinterpret_cast<rocksdb::RestoreOptions*>(jhandle);
assert(ropt);

@ -16,13 +16,16 @@
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_RocksCallbackObject_disposeInternal(
JNIEnv* env, jobject jobj, jlong handle) {
// TODO(AR) is deleting from the super class JniCallback OK, or must we delete the subclass?
// Example hierarchies:
// 1) Comparator -> BaseComparatorJniCallback + JniCallback -> DirectComparatorJniCallback
// 2) Comparator -> BaseComparatorJniCallback + JniCallback -> ComparatorJniCallback
// I think this is okay, as Comparator and JniCallback both have virtual destructors...
void Java_org_rocksdb_RocksCallbackObject_disposeInternal(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong handle) {
// TODO(AR) is deleting from the super class JniCallback OK, or must we delete
// the subclass? Example hierarchies:
// 1) Comparator -> BaseComparatorJniCallback + JniCallback ->
// DirectComparatorJniCallback 2) Comparator -> BaseComparatorJniCallback +
// JniCallback -> ComparatorJniCallback
// I think this is okay, as Comparator and JniCallback both have virtual
// destructors...
delete reinterpret_cast<rocksdb::JniCallback*>(handle);
// @lint-ignore TXT4 T25377293 Grandfathered in
// @lint-ignore TXT4 T25377293 Grandfathered in
}

@ -17,7 +17,7 @@
* Signature: ()V
*/
void Java_org_rocksdb_RocksDBExceptionTest_raiseException(JNIEnv* env,
jobject jobj) {
jobject /*jobj*/) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, std::string("test message"));
}
@ -27,7 +27,7 @@ void Java_org_rocksdb_RocksDBExceptionTest_raiseException(JNIEnv* env,
* Signature: ()V
*/
void Java_org_rocksdb_RocksDBExceptionTest_raiseExceptionWithStatusCode(
JNIEnv* env, jobject jobj) {
JNIEnv* env, jobject /*jobj*/) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, "test message",
rocksdb::Status::NotSupported());
}
@ -38,7 +38,7 @@ void Java_org_rocksdb_RocksDBExceptionTest_raiseExceptionWithStatusCode(
* Signature: ()V
*/
void Java_org_rocksdb_RocksDBExceptionTest_raiseExceptionNoMsgWithStatusCode(
JNIEnv* env, jobject jobj) {
JNIEnv* env, jobject /*jobj*/) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, rocksdb::Status::NotSupported());
}
@ -48,7 +48,7 @@ void Java_org_rocksdb_RocksDBExceptionTest_raiseExceptionNoMsgWithStatusCode(
* Signature: ()V
*/
void Java_org_rocksdb_RocksDBExceptionTest_raiseExceptionWithStatusCodeSubCode(
JNIEnv* env, jobject jobj) {
JNIEnv* env, jobject /*jobj*/) {
rocksdb::RocksDBExceptionJni::ThrowNew(
env, "test message",
rocksdb::Status::TimedOut(rocksdb::Status::SubCode::kLockTimeout));
@ -60,7 +60,7 @@ void Java_org_rocksdb_RocksDBExceptionTest_raiseExceptionWithStatusCodeSubCode(
* Signature: ()V
*/
void Java_org_rocksdb_RocksDBExceptionTest_raiseExceptionNoMsgWithStatusCodeSubCode(
JNIEnv* env, jobject jobj) {
JNIEnv* env, jobject /*jobj*/) {
rocksdb::RocksDBExceptionJni::ThrowNew(
env, rocksdb::Status::TimedOut(rocksdb::Status::SubCode::kLockTimeout));
}
@ -71,7 +71,7 @@ void Java_org_rocksdb_RocksDBExceptionTest_raiseExceptionNoMsgWithStatusCodeSubC
* Signature: ()V
*/
void Java_org_rocksdb_RocksDBExceptionTest_raiseExceptionWithStatusCodeState(
JNIEnv* env, jobject jobj) {
JNIEnv* env, jobject /*jobj*/) {
rocksdb::Slice state("test state");
rocksdb::RocksDBExceptionJni::ThrowNew(env, "test message",
rocksdb::Status::NotSupported(state));

File diff suppressed because it is too large Load Diff

@ -6,14 +6,14 @@
// This file implements the "bridge" between Java and C++ for
// rocksdb::Slice.
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <jni.h>
#include <string>
#include "include/org_rocksdb_AbstractSlice.h"
#include "include/org_rocksdb_Slice.h"
#include "include/org_rocksdb_DirectSlice.h"
#include "include/org_rocksdb_Slice.h"
#include "rocksdb/slice.h"
#include "rocksjni/portal.h"
@ -24,10 +24,11 @@
* Method: createNewSliceFromString
* Signature: (Ljava/lang/String;)J
*/
jlong Java_org_rocksdb_AbstractSlice_createNewSliceFromString(
JNIEnv * env, jclass jcls, jstring jstr) {
jlong Java_org_rocksdb_AbstractSlice_createNewSliceFromString(JNIEnv* env,
jclass /*jcls*/,
jstring jstr) {
const auto* str = env->GetStringUTFChars(jstr, nullptr);
if(str == nullptr) {
if (str == nullptr) {
// exception thrown: OutOfMemoryError
return 0;
}
@ -51,8 +52,8 @@ jlong Java_org_rocksdb_AbstractSlice_createNewSliceFromString(
* Method: size0
* Signature: (J)I
*/
jint Java_org_rocksdb_AbstractSlice_size0(
JNIEnv* env, jobject jobj, jlong handle) {
jint Java_org_rocksdb_AbstractSlice_size0(JNIEnv* /*env*/, jobject /*jobj*/,
jlong handle) {
const auto* slice = reinterpret_cast<rocksdb::Slice*>(handle);
return static_cast<jint>(slice->size());
}
@ -62,8 +63,8 @@ jint Java_org_rocksdb_AbstractSlice_size0(
* Method: empty0
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_AbstractSlice_empty0(
JNIEnv* env, jobject jobj, jlong handle) {
jboolean Java_org_rocksdb_AbstractSlice_empty0(JNIEnv* /*env*/,
jobject /*jobj*/, jlong handle) {
const auto* slice = reinterpret_cast<rocksdb::Slice*>(handle);
return slice->empty();
}
@ -73,8 +74,8 @@ jboolean Java_org_rocksdb_AbstractSlice_empty0(
* Method: toString0
* Signature: (JZ)Ljava/lang/String;
*/
jstring Java_org_rocksdb_AbstractSlice_toString0(
JNIEnv* env, jobject jobj, jlong handle, jboolean hex) {
jstring Java_org_rocksdb_AbstractSlice_toString0(JNIEnv* env, jobject /*jobj*/,
jlong handle, jboolean hex) {
const auto* slice = reinterpret_cast<rocksdb::Slice*>(handle);
const std::string s = slice->ToString(hex);
return env->NewStringUTF(s.c_str());
@ -85,11 +86,10 @@ jstring Java_org_rocksdb_AbstractSlice_toString0(
* Method: compare0
* Signature: (JJ)I;
*/
jint Java_org_rocksdb_AbstractSlice_compare0(
JNIEnv* env, jobject jobj, jlong handle, jlong otherHandle) {
jint Java_org_rocksdb_AbstractSlice_compare0(JNIEnv* /*env*/, jobject /*jobj*/,
jlong handle, jlong otherHandle) {
const auto* slice = reinterpret_cast<rocksdb::Slice*>(handle);
const auto* otherSlice =
reinterpret_cast<rocksdb::Slice*>(otherHandle);
const auto* otherSlice = reinterpret_cast<rocksdb::Slice*>(otherHandle);
return slice->compare(*otherSlice);
}
@ -98,11 +98,12 @@ jint Java_org_rocksdb_AbstractSlice_compare0(
* Method: startsWith0
* Signature: (JJ)Z;
*/
jboolean Java_org_rocksdb_AbstractSlice_startsWith0(
JNIEnv* env, jobject jobj, jlong handle, jlong otherHandle) {
jboolean Java_org_rocksdb_AbstractSlice_startsWith0(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong handle,
jlong otherHandle) {
const auto* slice = reinterpret_cast<rocksdb::Slice*>(handle);
const auto* otherSlice =
reinterpret_cast<rocksdb::Slice*>(otherHandle);
const auto* otherSlice = reinterpret_cast<rocksdb::Slice*>(otherHandle);
return slice->starts_with(*otherSlice);
}
@ -111,8 +112,9 @@ jboolean Java_org_rocksdb_AbstractSlice_startsWith0(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_AbstractSlice_disposeInternal(
JNIEnv* env, jobject jobj, jlong handle) {
void Java_org_rocksdb_AbstractSlice_disposeInternal(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong handle) {
delete reinterpret_cast<rocksdb::Slice*>(handle);
}
@ -125,15 +127,16 @@ void Java_org_rocksdb_AbstractSlice_disposeInternal(
* Method: createNewSlice0
* Signature: ([BI)J
*/
jlong Java_org_rocksdb_Slice_createNewSlice0(
JNIEnv * env, jclass jcls, jbyteArray data, jint offset) {
jlong Java_org_rocksdb_Slice_createNewSlice0(JNIEnv* env, jclass /*jcls*/,
jbyteArray data, jint offset) {
const jsize dataSize = env->GetArrayLength(data);
const int len = dataSize - offset;
// NOTE: buf will be deleted in the Java_org_rocksdb_Slice_disposeInternalBuf method
// NOTE: buf will be deleted in the Java_org_rocksdb_Slice_disposeInternalBuf
// method
jbyte* buf = new jbyte[len];
env->GetByteArrayRegion(data, offset, len, buf);
if(env->ExceptionCheck()) {
if (env->ExceptionCheck()) {
// exception thrown: ArrayIndexOutOfBoundsException
return 0;
}
@ -147,22 +150,22 @@ jlong Java_org_rocksdb_Slice_createNewSlice0(
* Method: createNewSlice1
* Signature: ([B)J
*/
jlong Java_org_rocksdb_Slice_createNewSlice1(
JNIEnv * env, jclass jcls, jbyteArray data) {
jlong Java_org_rocksdb_Slice_createNewSlice1(JNIEnv* env, jclass /*jcls*/,
jbyteArray data) {
jbyte* ptrData = env->GetByteArrayElements(data, nullptr);
if(ptrData == nullptr) {
if (ptrData == nullptr) {
// exception thrown: OutOfMemoryError
return 0;
}
const int len = env->GetArrayLength(data) + 1;
// NOTE: buf will be deleted in the Java_org_rocksdb_Slice_disposeInternalBuf method
// NOTE: buf will be deleted in the Java_org_rocksdb_Slice_disposeInternalBuf
// method
char* buf = new char[len];
memcpy(buf, ptrData, len - 1);
buf[len-1] = '\0';
buf[len - 1] = '\0';
const auto* slice =
new rocksdb::Slice(buf, len - 1);
const auto* slice = new rocksdb::Slice(buf, len - 1);
env->ReleaseByteArrayElements(data, ptrData, JNI_ABORT);
@ -174,19 +177,20 @@ jlong Java_org_rocksdb_Slice_createNewSlice1(
* Method: data0
* Signature: (J)[B
*/
jbyteArray Java_org_rocksdb_Slice_data0(
JNIEnv* env, jobject jobj, jlong handle) {
jbyteArray Java_org_rocksdb_Slice_data0(JNIEnv* env, jobject /*jobj*/,
jlong handle) {
const auto* slice = reinterpret_cast<rocksdb::Slice*>(handle);
const jsize len = static_cast<jsize>(slice->size());
const jbyteArray data = env->NewByteArray(len);
if(data == nullptr) {
if (data == nullptr) {
// exception thrown: OutOfMemoryError
return nullptr;
}
env->SetByteArrayRegion(data, 0, len,
env->SetByteArrayRegion(
data, 0, len,
const_cast<jbyte*>(reinterpret_cast<const jbyte*>(slice->data())));
if(env->ExceptionCheck()) {
if (env->ExceptionCheck()) {
// exception thrown: ArrayIndexOutOfBoundsException
env->DeleteLocalRef(data);
return nullptr;
@ -200,13 +204,13 @@ jbyteArray Java_org_rocksdb_Slice_data0(
* Method: clear0
* Signature: (JZJ)V
*/
void Java_org_rocksdb_Slice_clear0(
JNIEnv * env, jobject jobj, jlong handle, jboolean shouldRelease,
void Java_org_rocksdb_Slice_clear0(JNIEnv* /*env*/, jobject /*jobj*/,
jlong handle, jboolean shouldRelease,
jlong internalBufferOffset) {
auto* slice = reinterpret_cast<rocksdb::Slice*>(handle);
if(shouldRelease == JNI_TRUE) {
if (shouldRelease == JNI_TRUE) {
const char* buf = slice->data_ - internalBufferOffset;
delete [] buf;
delete[] buf;
}
slice->clear();
}
@ -216,8 +220,8 @@ void Java_org_rocksdb_Slice_clear0(
* Method: removePrefix0
* Signature: (JI)V
*/
void Java_org_rocksdb_Slice_removePrefix0(
JNIEnv * env, jobject jobj, jlong handle, jint length) {
void Java_org_rocksdb_Slice_removePrefix0(JNIEnv* /*env*/, jobject /*jobj*/,
jlong handle, jint length) {
auto* slice = reinterpret_cast<rocksdb::Slice*>(handle);
slice->remove_prefix(length);
}
@ -227,11 +231,12 @@ void Java_org_rocksdb_Slice_removePrefix0(
* Method: disposeInternalBuf
* Signature: (JJ)V
*/
void Java_org_rocksdb_Slice_disposeInternalBuf(
JNIEnv * env, jobject jobj, jlong handle, jlong internalBufferOffset) {
void Java_org_rocksdb_Slice_disposeInternalBuf(JNIEnv* /*env*/,
jobject /*jobj*/, jlong handle,
jlong internalBufferOffset) {
const auto* slice = reinterpret_cast<rocksdb::Slice*>(handle);
const char* buf = slice->data_ - internalBufferOffset;
delete [] buf;
delete[] buf;
}
// </editor-fold>
@ -243,21 +248,21 @@ void Java_org_rocksdb_Slice_disposeInternalBuf(
* Method: createNewDirectSlice0
* Signature: (Ljava/nio/ByteBuffer;I)J
*/
jlong Java_org_rocksdb_DirectSlice_createNewDirectSlice0(
JNIEnv* env, jclass jcls, jobject data, jint length) {
jlong Java_org_rocksdb_DirectSlice_createNewDirectSlice0(JNIEnv* env,
jclass /*jcls*/,
jobject data,
jint length) {
assert(data != nullptr);
void* data_addr = env->GetDirectBufferAddress(data);
if(data_addr == nullptr) {
if (data_addr == nullptr) {
// error: memory region is undefined, given object is not a direct
// java.nio.Buffer, or JNI access to direct buffers is not supported by JVM
rocksdb::IllegalArgumentExceptionJni::ThrowNew(env,
rocksdb::Status::InvalidArgument(
"Could not access DirectBuffer"));
rocksdb::IllegalArgumentExceptionJni::ThrowNew(
env, rocksdb::Status::InvalidArgument("Could not access DirectBuffer"));
return 0;
}
const auto* ptrData =
reinterpret_cast<char*>(data_addr);
const auto* ptrData = reinterpret_cast<char*>(data_addr);
const auto* slice = new rocksdb::Slice(ptrData, length);
return reinterpret_cast<jlong>(slice);
}
@ -267,15 +272,15 @@ jlong Java_org_rocksdb_DirectSlice_createNewDirectSlice0(
* Method: createNewDirectSlice1
* Signature: (Ljava/nio/ByteBuffer;)J
*/
jlong Java_org_rocksdb_DirectSlice_createNewDirectSlice1(
JNIEnv* env, jclass jcls, jobject data) {
jlong Java_org_rocksdb_DirectSlice_createNewDirectSlice1(JNIEnv* env,
jclass /*jcls*/,
jobject data) {
void* data_addr = env->GetDirectBufferAddress(data);
if(data_addr == nullptr) {
if (data_addr == nullptr) {
// error: memory region is undefined, given object is not a direct
// java.nio.Buffer, or JNI access to direct buffers is not supported by JVM
rocksdb::IllegalArgumentExceptionJni::ThrowNew(env,
rocksdb::Status::InvalidArgument(
"Could not access DirectBuffer"));
rocksdb::IllegalArgumentExceptionJni::ThrowNew(
env, rocksdb::Status::InvalidArgument("Could not access DirectBuffer"));
return 0;
}
@ -289,8 +294,8 @@ jlong Java_org_rocksdb_DirectSlice_createNewDirectSlice1(
* Method: data0
* Signature: (J)Ljava/lang/Object;
*/
jobject Java_org_rocksdb_DirectSlice_data0(
JNIEnv* env, jobject jobj, jlong handle) {
jobject Java_org_rocksdb_DirectSlice_data0(JNIEnv* env, jobject /*jobj*/,
jlong handle) {
const auto* slice = reinterpret_cast<rocksdb::Slice*>(handle);
return env->NewDirectByteBuffer(const_cast<char*>(slice->data()),
slice->size());
@ -301,8 +306,8 @@ jobject Java_org_rocksdb_DirectSlice_data0(
* Method: get0
* Signature: (JI)B
*/
jbyte Java_org_rocksdb_DirectSlice_get0(
JNIEnv* env, jobject jobj, jlong handle, jint offset) {
jbyte Java_org_rocksdb_DirectSlice_get0(JNIEnv* /*env*/, jobject /*jobj*/,
jlong handle, jint offset) {
const auto* slice = reinterpret_cast<rocksdb::Slice*>(handle);
return (*slice)[offset];
}
@ -312,13 +317,13 @@ jbyte Java_org_rocksdb_DirectSlice_get0(
* Method: clear0
* Signature: (JZJ)V
*/
void Java_org_rocksdb_DirectSlice_clear0(
JNIEnv* env, jobject jobj, jlong handle,
jboolean shouldRelease, jlong internalBufferOffset) {
void Java_org_rocksdb_DirectSlice_clear0(JNIEnv* /*env*/, jobject /*jobj*/,
jlong handle, jboolean shouldRelease,
jlong internalBufferOffset) {
auto* slice = reinterpret_cast<rocksdb::Slice*>(handle);
if(shouldRelease == JNI_TRUE) {
if (shouldRelease == JNI_TRUE) {
const char* buf = slice->data_ - internalBufferOffset;
delete [] buf;
delete[] buf;
}
slice->clear();
}
@ -328,8 +333,9 @@ void Java_org_rocksdb_DirectSlice_clear0(
* Method: removePrefix0
* Signature: (JI)V
*/
void Java_org_rocksdb_DirectSlice_removePrefix0(
JNIEnv* env, jobject jobj, jlong handle, jint length) {
void Java_org_rocksdb_DirectSlice_removePrefix0(JNIEnv* /*env*/,
jobject /*jobj*/, jlong handle,
jint length) {
auto* slice = reinterpret_cast<rocksdb::Slice*>(handle);
slice->remove_prefix(length);
}
@ -340,10 +346,11 @@ void Java_org_rocksdb_DirectSlice_removePrefix0(
* Signature: (JJ)V
*/
void Java_org_rocksdb_DirectSlice_disposeInternalBuf(
JNIEnv* env, jobject jobj, jlong handle, jlong internalBufferOffset) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong handle,
jlong internalBufferOffset) {
const auto* slice = reinterpret_cast<rocksdb::Slice*>(handle);
const char* buf = slice->data_ - internalBufferOffset;
delete [] buf;
delete[] buf;
}
// </editor-fold>

@ -18,9 +18,9 @@
* Method: getSequenceNumber
* Signature: (J)J
*/
jlong Java_org_rocksdb_Snapshot_getSequenceNumber(JNIEnv* env,
jobject jobj, jlong jsnapshot_handle) {
auto* snapshot = reinterpret_cast<rocksdb::Snapshot*>(
jsnapshot_handle);
jlong Java_org_rocksdb_Snapshot_getSequenceNumber(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jsnapshot_handle) {
auto* snapshot = reinterpret_cast<rocksdb::Snapshot*>(jsnapshot_handle);
return snapshot->GetSequenceNumber();
}

@ -20,23 +20,22 @@
* Signature: (JJJDJ)J
*/
jlong Java_org_rocksdb_SstFileManager_newSstFileManager(
JNIEnv* jnienv, jclass jcls, jlong jenv_handle, jlong jlogger_handle,
JNIEnv* jnienv, jclass /*jcls*/, jlong jenv_handle, jlong jlogger_handle,
jlong jrate_bytes, jdouble jmax_trash_db_ratio,
jlong jmax_delete_chunk_bytes) {
auto* env = reinterpret_cast<rocksdb::Env*>(jenv_handle);
rocksdb::Status s;
rocksdb::SstFileManager* sst_file_manager = nullptr;
if (jlogger_handle != 0) {
auto* sptr_logger =
reinterpret_cast<std::shared_ptr<rocksdb::Logger> *>(jlogger_handle);
sst_file_manager = rocksdb::NewSstFileManager(env, *sptr_logger, "",
jrate_bytes, true, &s, jmax_trash_db_ratio,
reinterpret_cast<std::shared_ptr<rocksdb::Logger>*>(jlogger_handle);
sst_file_manager = rocksdb::NewSstFileManager(
env, *sptr_logger, "", jrate_bytes, true, &s, jmax_trash_db_ratio,
jmax_delete_chunk_bytes);
} else {
sst_file_manager = rocksdb::NewSstFileManager(env, nullptr, "",
jrate_bytes, true, &s, jmax_trash_db_ratio,
sst_file_manager = rocksdb::NewSstFileManager(env, nullptr, "", jrate_bytes,
true, &s, jmax_trash_db_ratio,
jmax_delete_chunk_bytes);
}
@ -46,8 +45,8 @@ jlong Java_org_rocksdb_SstFileManager_newSstFileManager(
}
rocksdb::RocksDBExceptionJni::ThrowNew(jnienv, s);
}
auto* sptr_sst_file_manager
= new std::shared_ptr<rocksdb::SstFileManager>(sst_file_manager);
auto* sptr_sst_file_manager =
new std::shared_ptr<rocksdb::SstFileManager>(sst_file_manager);
return reinterpret_cast<jlong>(sptr_sst_file_manager);
}
@ -58,9 +57,10 @@ jlong Java_org_rocksdb_SstFileManager_newSstFileManager(
* Signature: (JJ)V
*/
void Java_org_rocksdb_SstFileManager_setMaxAllowedSpaceUsage(
JNIEnv* env, jobject jobj, jlong jhandle, jlong jmax_allowed_space) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jlong jmax_allowed_space) {
auto* sptr_sst_file_manager =
reinterpret_cast<std::shared_ptr<rocksdb::SstFileManager> *>(jhandle);
reinterpret_cast<std::shared_ptr<rocksdb::SstFileManager>*>(jhandle);
sptr_sst_file_manager->get()->SetMaxAllowedSpaceUsage(jmax_allowed_space);
}
@ -70,10 +70,12 @@ void Java_org_rocksdb_SstFileManager_setMaxAllowedSpaceUsage(
* Signature: (JJ)V
*/
void Java_org_rocksdb_SstFileManager_setCompactionBufferSize(
JNIEnv* env, jobject jobj, jlong jhandle, jlong jcompaction_buffer_size) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jlong jcompaction_buffer_size) {
auto* sptr_sst_file_manager =
reinterpret_cast<std::shared_ptr<rocksdb::SstFileManager> *>(jhandle);
sptr_sst_file_manager->get()->SetCompactionBufferSize(jcompaction_buffer_size);
reinterpret_cast<std::shared_ptr<rocksdb::SstFileManager>*>(jhandle);
sptr_sst_file_manager->get()->SetCompactionBufferSize(
jcompaction_buffer_size);
}
/*
@ -82,9 +84,9 @@ void Java_org_rocksdb_SstFileManager_setCompactionBufferSize(
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_SstFileManager_isMaxAllowedSpaceReached(
JNIEnv* env, jobject jobj, jlong jhandle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
auto* sptr_sst_file_manager =
reinterpret_cast<std::shared_ptr<rocksdb::SstFileManager> *>(jhandle);
reinterpret_cast<std::shared_ptr<rocksdb::SstFileManager>*>(jhandle);
return sptr_sst_file_manager->get()->IsMaxAllowedSpaceReached();
}
@ -93,11 +95,13 @@ jboolean Java_org_rocksdb_SstFileManager_isMaxAllowedSpaceReached(
* Method: isMaxAllowedSpaceReachedIncludingCompactions
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_SstFileManager_isMaxAllowedSpaceReachedIncludingCompactions(
JNIEnv* env, jobject jobj, jlong jhandle) {
jboolean
Java_org_rocksdb_SstFileManager_isMaxAllowedSpaceReachedIncludingCompactions(
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
auto* sptr_sst_file_manager =
reinterpret_cast<std::shared_ptr<rocksdb::SstFileManager> *>(jhandle);
return sptr_sst_file_manager->get()->IsMaxAllowedSpaceReachedIncludingCompactions();
reinterpret_cast<std::shared_ptr<rocksdb::SstFileManager>*>(jhandle);
return sptr_sst_file_manager->get()
->IsMaxAllowedSpaceReachedIncludingCompactions();
}
/*
@ -105,10 +109,11 @@ jboolean Java_org_rocksdb_SstFileManager_isMaxAllowedSpaceReachedIncludingCompac
* Method: getTotalSize
* Signature: (J)J
*/
jlong Java_org_rocksdb_SstFileManager_getTotalSize(
JNIEnv* env, jobject jobj, jlong jhandle) {
jlong Java_org_rocksdb_SstFileManager_getTotalSize(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* sptr_sst_file_manager =
reinterpret_cast<std::shared_ptr<rocksdb::SstFileManager> *>(jhandle);
reinterpret_cast<std::shared_ptr<rocksdb::SstFileManager>*>(jhandle);
return sptr_sst_file_manager->get()->GetTotalSize();
}
@ -117,22 +122,26 @@ jlong Java_org_rocksdb_SstFileManager_getTotalSize(
* Method: getTrackedFiles
* Signature: (J)Ljava/util/Map;
*/
jobject Java_org_rocksdb_SstFileManager_getTrackedFiles(
JNIEnv* env, jobject jobj, jlong jhandle) {
jobject Java_org_rocksdb_SstFileManager_getTrackedFiles(JNIEnv* env,
jobject /*jobj*/,
jlong jhandle) {
auto* sptr_sst_file_manager =
reinterpret_cast<std::shared_ptr<rocksdb::SstFileManager> *>(jhandle);
reinterpret_cast<std::shared_ptr<rocksdb::SstFileManager>*>(jhandle);
auto tracked_files = sptr_sst_file_manager->get()->GetTrackedFiles();
const jobject jtracked_files = rocksdb::HashMapJni::construct(env,
static_cast<uint32_t>(tracked_files.size()));
const jobject jtracked_files = rocksdb::HashMapJni::construct(
env, static_cast<uint32_t>(tracked_files.size()));
if (jtracked_files == nullptr) {
// exception occurred
return nullptr;
}
const rocksdb::HashMapJni::FnMapKV<const std::string, const uint64_t> fn_map_kv =
[env, &tracked_files](const std::pair<const std::string, const uint64_t>& pair) {
const jstring jtracked_file_path = env->NewStringUTF(pair.first.c_str());
const rocksdb::HashMapJni::FnMapKV<const std::string, const uint64_t>
fn_map_kv =
[env, &tracked_files](
const std::pair<const std::string, const uint64_t>& pair) {
const jstring jtracked_file_path =
env->NewStringUTF(pair.first.c_str());
if (jtracked_file_path == nullptr) {
// an error occurred
return std::unique_ptr<std::pair<jobject, jobject>>(nullptr);
@ -143,12 +152,13 @@ jobject Java_org_rocksdb_SstFileManager_getTrackedFiles(
// an error occurred
return std::unique_ptr<std::pair<jobject, jobject>>(nullptr);
}
return std::unique_ptr<std::pair<jobject, jobject>>(new std::pair<jobject, jobject>(jtracked_file_path,
return std::unique_ptr<std::pair<jobject, jobject>>(
new std::pair<jobject, jobject>(jtracked_file_path,
jtracked_file_size));
};
if(!rocksdb::HashMapJni::putAll(env, jtracked_files,
tracked_files.begin(), tracked_files.end(), fn_map_kv)) {
if (!rocksdb::HashMapJni::putAll(env, jtracked_files, tracked_files.begin(),
tracked_files.end(), fn_map_kv)) {
// exception occcurred
return nullptr;
}
@ -162,9 +172,9 @@ jobject Java_org_rocksdb_SstFileManager_getTrackedFiles(
* Signature: (J)J
*/
jlong Java_org_rocksdb_SstFileManager_getDeleteRateBytesPerSecond(
JNIEnv* env, jobject jobj, jlong jhandle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
auto* sptr_sst_file_manager =
reinterpret_cast<std::shared_ptr<rocksdb::SstFileManager> *>(jhandle);
reinterpret_cast<std::shared_ptr<rocksdb::SstFileManager>*>(jhandle);
return sptr_sst_file_manager->get()->GetDeleteRateBytesPerSecond();
}
@ -174,9 +184,9 @@ jlong Java_org_rocksdb_SstFileManager_getDeleteRateBytesPerSecond(
* Signature: (JJ)V
*/
void Java_org_rocksdb_SstFileManager_setDeleteRateBytesPerSecond(
JNIEnv* env, jobject jobj, jlong jhandle, jlong jdelete_rate) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jlong jdelete_rate) {
auto* sptr_sst_file_manager =
reinterpret_cast<std::shared_ptr<rocksdb::SstFileManager> *>(jhandle);
reinterpret_cast<std::shared_ptr<rocksdb::SstFileManager>*>(jhandle);
sptr_sst_file_manager->get()->SetDeleteRateBytesPerSecond(jdelete_rate);
}
@ -185,10 +195,11 @@ void Java_org_rocksdb_SstFileManager_setDeleteRateBytesPerSecond(
* Method: getMaxTrashDBRatio
* Signature: (J)D
*/
jdouble Java_org_rocksdb_SstFileManager_getMaxTrashDBRatio(
JNIEnv* env, jobject jobj, jlong jhandle) {
jdouble Java_org_rocksdb_SstFileManager_getMaxTrashDBRatio(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* sptr_sst_file_manager =
reinterpret_cast<std::shared_ptr<rocksdb::SstFileManager> *>(jhandle);
reinterpret_cast<std::shared_ptr<rocksdb::SstFileManager>*>(jhandle);
return sptr_sst_file_manager->get()->GetMaxTrashDBRatio();
}
@ -197,10 +208,12 @@ jdouble Java_org_rocksdb_SstFileManager_getMaxTrashDBRatio(
* Method: setMaxTrashDBRatio
* Signature: (JD)V
*/
void Java_org_rocksdb_SstFileManager_setMaxTrashDBRatio(
JNIEnv* env, jobject jobj, jlong jhandle, jdouble jratio) {
void Java_org_rocksdb_SstFileManager_setMaxTrashDBRatio(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle,
jdouble jratio) {
auto* sptr_sst_file_manager =
reinterpret_cast<std::shared_ptr<rocksdb::SstFileManager> *>(jhandle);
reinterpret_cast<std::shared_ptr<rocksdb::SstFileManager>*>(jhandle);
sptr_sst_file_manager->get()->SetMaxTrashDBRatio(jratio);
}
@ -209,9 +222,10 @@ void Java_org_rocksdb_SstFileManager_setMaxTrashDBRatio(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_SstFileManager_disposeInternal(
JNIEnv* env, jobject jobj, jlong jhandle) {
void Java_org_rocksdb_SstFileManager_disposeInternal(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* sptr_sst_file_manager =
reinterpret_cast<std::shared_ptr<rocksdb::SstFileManager> *>(jhandle);
reinterpret_cast<std::shared_ptr<rocksdb::SstFileManager>*>(jhandle);
delete sptr_sst_file_manager;
}

@ -22,27 +22,26 @@
* Method: newSstFileWriter
* Signature: (JJJB)J
*/
jlong Java_org_rocksdb_SstFileWriter_newSstFileWriter__JJJB(JNIEnv *env,
jclass jcls, jlong jenvoptions, jlong joptions, jlong jcomparator_handle,
jbyte jcomparator_type) {
jlong Java_org_rocksdb_SstFileWriter_newSstFileWriter__JJJB(
JNIEnv * /*env*/, jclass /*jcls*/, jlong jenvoptions, jlong joptions,
jlong jcomparator_handle, jbyte jcomparator_type) {
rocksdb::Comparator *comparator = nullptr;
switch(jcomparator_type) {
switch (jcomparator_type) {
// JAVA_COMPARATOR
case 0x0:
comparator =
reinterpret_cast<rocksdb::ComparatorJniCallback*>(jcomparator_handle);
comparator = reinterpret_cast<rocksdb::ComparatorJniCallback *>(
jcomparator_handle);
break;
// JAVA_DIRECT_COMPARATOR
case 0x1:
comparator =
reinterpret_cast<rocksdb::DirectComparatorJniCallback*>(jcomparator_handle);
comparator = reinterpret_cast<rocksdb::DirectComparatorJniCallback *>(
jcomparator_handle);
break;
// JAVA_NATIVE_COMPARATOR_WRAPPER
case 0x2:
comparator =
reinterpret_cast<rocksdb::Comparator*>(jcomparator_handle);
comparator = reinterpret_cast<rocksdb::Comparator *>(jcomparator_handle);
break;
}
auto *env_options =
@ -58,7 +57,8 @@ jlong Java_org_rocksdb_SstFileWriter_newSstFileWriter__JJJB(JNIEnv *env,
* Method: newSstFileWriter
* Signature: (JJ)J
*/
jlong Java_org_rocksdb_SstFileWriter_newSstFileWriter__JJ(JNIEnv *env, jclass jcls,
jlong Java_org_rocksdb_SstFileWriter_newSstFileWriter__JJ(JNIEnv * /*env*/,
jclass /*jcls*/,
jlong jenvoptions,
jlong joptions) {
auto *env_options =
@ -74,10 +74,10 @@ jlong Java_org_rocksdb_SstFileWriter_newSstFileWriter__JJ(JNIEnv *env, jclass jc
* Method: open
* Signature: (JLjava/lang/String;)V
*/
void Java_org_rocksdb_SstFileWriter_open(JNIEnv *env, jobject jobj,
void Java_org_rocksdb_SstFileWriter_open(JNIEnv *env, jobject /*jobj*/,
jlong jhandle, jstring jfile_path) {
const char *file_path = env->GetStringUTFChars(jfile_path, nullptr);
if(file_path == nullptr) {
if (file_path == nullptr) {
// exception thrown: OutOfMemoryError
return;
}
@ -95,14 +95,13 @@ void Java_org_rocksdb_SstFileWriter_open(JNIEnv *env, jobject jobj,
* Method: put
* Signature: (JJJ)V
*/
void Java_org_rocksdb_SstFileWriter_put__JJJ(JNIEnv *env, jobject jobj,
void Java_org_rocksdb_SstFileWriter_put__JJJ(JNIEnv *env, jobject /*jobj*/,
jlong jhandle, jlong jkey_handle,
jlong jvalue_handle) {
auto *key_slice = reinterpret_cast<rocksdb::Slice *>(jkey_handle);
auto *value_slice = reinterpret_cast<rocksdb::Slice *>(jvalue_handle);
rocksdb::Status s =
reinterpret_cast<rocksdb::SstFileWriter *>(jhandle)->Put(*key_slice,
*value_slice);
rocksdb::Status s = reinterpret_cast<rocksdb::SstFileWriter *>(jhandle)->Put(
*key_slice, *value_slice);
if (!s.ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, s);
}
@ -113,29 +112,28 @@ void Java_org_rocksdb_SstFileWriter_put__JJJ(JNIEnv *env, jobject jobj,
* Method: put
* Signature: (JJJ)V
*/
void Java_org_rocksdb_SstFileWriter_put__J_3B_3B(JNIEnv *env, jobject jobj,
void Java_org_rocksdb_SstFileWriter_put__J_3B_3B(JNIEnv *env, jobject /*jobj*/,
jlong jhandle, jbyteArray jkey,
jbyteArray jval) {
jbyte* key = env->GetByteArrayElements(jkey, nullptr);
if(key == nullptr) {
jbyte *key = env->GetByteArrayElements(jkey, nullptr);
if (key == nullptr) {
// exception thrown: OutOfMemoryError
return;
}
rocksdb::Slice key_slice(
reinterpret_cast<char*>(key), env->GetArrayLength(jkey));
rocksdb::Slice key_slice(reinterpret_cast<char *>(key),
env->GetArrayLength(jkey));
jbyte* value = env->GetByteArrayElements(jval, nullptr);
if(value == nullptr) {
jbyte *value = env->GetByteArrayElements(jval, nullptr);
if (value == nullptr) {
// exception thrown: OutOfMemoryError
env->ReleaseByteArrayElements(jkey, key, JNI_ABORT);
return;
}
rocksdb::Slice value_slice(
reinterpret_cast<char*>(value), env->GetArrayLength(jval));
rocksdb::Slice value_slice(reinterpret_cast<char *>(value),
env->GetArrayLength(jval));
rocksdb::Status s =
reinterpret_cast<rocksdb::SstFileWriter *>(jhandle)->Put(key_slice,
value_slice);
rocksdb::Status s = reinterpret_cast<rocksdb::SstFileWriter *>(jhandle)->Put(
key_slice, value_slice);
env->ReleaseByteArrayElements(jkey, key, JNI_ABORT);
env->ReleaseByteArrayElements(jval, value, JNI_ABORT);
@ -150,7 +148,7 @@ void Java_org_rocksdb_SstFileWriter_put__JJJ(JNIEnv *env, jobject jobj,
* Method: merge
* Signature: (JJJ)V
*/
void Java_org_rocksdb_SstFileWriter_merge__JJJ(JNIEnv *env, jobject jobj,
void Java_org_rocksdb_SstFileWriter_merge__JJJ(JNIEnv *env, jobject /*jobj*/,
jlong jhandle, jlong jkey_handle,
jlong jvalue_handle) {
auto *key_slice = reinterpret_cast<rocksdb::Slice *>(jkey_handle);
@ -168,26 +166,27 @@ void Java_org_rocksdb_SstFileWriter_merge__JJJ(JNIEnv *env, jobject jobj,
* Method: merge
* Signature: (J[B[B)V
*/
void Java_org_rocksdb_SstFileWriter_merge__J_3B_3B(JNIEnv *env, jobject jobj,
jlong jhandle, jbyteArray jkey,
void Java_org_rocksdb_SstFileWriter_merge__J_3B_3B(JNIEnv *env,
jobject /*jobj*/,
jlong jhandle,
jbyteArray jkey,
jbyteArray jval) {
jbyte* key = env->GetByteArrayElements(jkey, nullptr);
if(key == nullptr) {
jbyte *key = env->GetByteArrayElements(jkey, nullptr);
if (key == nullptr) {
// exception thrown: OutOfMemoryError
return;
}
rocksdb::Slice key_slice(
reinterpret_cast<char*>(key), env->GetArrayLength(jkey));
rocksdb::Slice key_slice(reinterpret_cast<char *>(key),
env->GetArrayLength(jkey));
jbyte* value = env->GetByteArrayElements(jval, nullptr);
if(value == nullptr) {
jbyte *value = env->GetByteArrayElements(jval, nullptr);
if (value == nullptr) {
// exception thrown: OutOfMemoryError
env->ReleaseByteArrayElements(jkey, key, JNI_ABORT);
return;
}
rocksdb::Slice value_slice(
reinterpret_cast<char*>(value), env->GetArrayLength(jval));
rocksdb::Slice value_slice(reinterpret_cast<char *>(value),
env->GetArrayLength(jval));
rocksdb::Status s =
reinterpret_cast<rocksdb::SstFileWriter *>(jhandle)->Merge(key_slice,
@ -206,15 +205,16 @@ void Java_org_rocksdb_SstFileWriter_merge__J_3B_3B(JNIEnv *env, jobject jobj,
* Method: delete
* Signature: (JJJ)V
*/
void Java_org_rocksdb_SstFileWriter_delete__J_3B(JNIEnv *env, jobject jobj,
jlong jhandle, jbyteArray jkey) {
jbyte* key = env->GetByteArrayElements(jkey, nullptr);
if(key == nullptr) {
void Java_org_rocksdb_SstFileWriter_delete__J_3B(JNIEnv *env, jobject /*jobj*/,
jlong jhandle,
jbyteArray jkey) {
jbyte *key = env->GetByteArrayElements(jkey, nullptr);
if (key == nullptr) {
// exception thrown: OutOfMemoryError
return;
}
rocksdb::Slice key_slice(
reinterpret_cast<char*>(key), env->GetArrayLength(jkey));
rocksdb::Slice key_slice(reinterpret_cast<char *>(key),
env->GetArrayLength(jkey));
rocksdb::Status s =
reinterpret_cast<rocksdb::SstFileWriter *>(jhandle)->Delete(key_slice);
@ -231,8 +231,9 @@ void Java_org_rocksdb_SstFileWriter_delete__J_3B(JNIEnv *env, jobject jobj,
* Method: delete
* Signature: (JJJ)V
*/
void Java_org_rocksdb_SstFileWriter_delete__JJ(JNIEnv *env, jobject jobj,
jlong jhandle, jlong jkey_handle) {
void Java_org_rocksdb_SstFileWriter_delete__JJ(JNIEnv *env, jobject /*jobj*/,
jlong jhandle,
jlong jkey_handle) {
auto *key_slice = reinterpret_cast<rocksdb::Slice *>(jkey_handle);
rocksdb::Status s =
reinterpret_cast<rocksdb::SstFileWriter *>(jhandle)->Delete(*key_slice);
@ -246,7 +247,7 @@ void Java_org_rocksdb_SstFileWriter_delete__J_3B(JNIEnv *env, jobject jobj,
* Method: finish
* Signature: (J)V
*/
void Java_org_rocksdb_SstFileWriter_finish(JNIEnv *env, jobject jobj,
void Java_org_rocksdb_SstFileWriter_finish(JNIEnv *env, jobject /*jobj*/,
jlong jhandle) {
rocksdb::Status s =
reinterpret_cast<rocksdb::SstFileWriter *>(jhandle)->Finish();
@ -260,7 +261,8 @@ void Java_org_rocksdb_SstFileWriter_finish(JNIEnv *env, jobject jobj,
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_SstFileWriter_disposeInternal(JNIEnv *env, jobject jobj,
void Java_org_rocksdb_SstFileWriter_disposeInternal(JNIEnv * /*env*/,
jobject /*jobj*/,
jlong jhandle) {
delete reinterpret_cast<rocksdb::SstFileWriter *>(jhandle);
}

@ -11,9 +11,9 @@
#include <set>
#include "include/org_rocksdb_Statistics.h"
#include "rocksdb/statistics.h"
#include "rocksjni/portal.h"
#include "rocksjni/statisticsjni.h"
#include "rocksdb/statistics.h"
/*
* Class: org_rocksdb_Statistics
@ -21,8 +21,7 @@
* Signature: ()J
*/
jlong Java_org_rocksdb_Statistics_newStatistics__(JNIEnv* env, jclass jcls) {
return Java_org_rocksdb_Statistics_newStatistics___3BJ(
env, jcls, nullptr, 0);
return Java_org_rocksdb_Statistics_newStatistics___3BJ(env, jcls, nullptr, 0);
}
/*
@ -41,10 +40,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);
}
/*
@ -53,9 +52,8 @@ jlong Java_org_rocksdb_Statistics_newStatistics___3B(
* Signature: ([BJ)J
*/
jlong Java_org_rocksdb_Statistics_newStatistics___3BJ(
JNIEnv* env, jclass jcls, jbyteArray jhistograms,
JNIEnv* env, jclass /*jcls*/, jbyteArray jhistograms,
jlong jother_statistics_handle) {
std::shared_ptr<rocksdb::Statistics>* pSptr_other_statistics = nullptr;
if (jother_statistics_handle > 0) {
pSptr_other_statistics =
@ -68,7 +66,7 @@ jlong Java_org_rocksdb_Statistics_newStatistics___3BJ(
const jsize len = env->GetArrayLength(jhistograms);
if (len > 0) {
jbyte* jhistogram = env->GetByteArrayElements(jhistograms, nullptr);
if (jhistogram == nullptr ) {
if (jhistogram == nullptr) {
// exception thrown: OutOfMemoryError
return 0;
}
@ -99,9 +97,10 @@ jlong Java_org_rocksdb_Statistics_newStatistics___3BJ(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_Statistics_disposeInternal(
JNIEnv* env, jobject jobj, jlong jhandle) {
if(jhandle > 0) {
void Java_org_rocksdb_Statistics_disposeInternal(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
if (jhandle > 0) {
auto* pSptr_statistics =
reinterpret_cast<std::shared_ptr<rocksdb::Statistics>*>(jhandle);
delete pSptr_statistics;
@ -113,12 +112,13 @@ void Java_org_rocksdb_Statistics_disposeInternal(
* Method: statsLevel
* Signature: (J)B
*/
jbyte Java_org_rocksdb_Statistics_statsLevel(
JNIEnv* env, jobject jobj, jlong jhandle) {
jbyte Java_org_rocksdb_Statistics_statsLevel(JNIEnv* /*env*/, jobject /*jobj*/,
jlong jhandle) {
auto* pSptr_statistics =
reinterpret_cast<std::shared_ptr<rocksdb::Statistics>*>(jhandle);
assert(pSptr_statistics != nullptr);
return rocksdb::StatsLevelJni::toJavaStatsLevel(pSptr_statistics->get()->stats_level_);
return rocksdb::StatsLevelJni::toJavaStatsLevel(
pSptr_statistics->get()->stats_level_);
}
/*
@ -126,8 +126,9 @@ jbyte Java_org_rocksdb_Statistics_statsLevel(
* Method: setStatsLevel
* Signature: (JB)V
*/
void Java_org_rocksdb_Statistics_setStatsLevel(
JNIEnv* env, jobject jobj, jlong jhandle, jbyte jstats_level) {
void Java_org_rocksdb_Statistics_setStatsLevel(JNIEnv* /*env*/,
jobject /*jobj*/, jlong jhandle,
jbyte jstats_level) {
auto* pSptr_statistics =
reinterpret_cast<std::shared_ptr<rocksdb::Statistics>*>(jhandle);
assert(pSptr_statistics != nullptr);
@ -140,8 +141,10 @@ void Java_org_rocksdb_Statistics_setStatsLevel(
* Method: getTickerCount
* Signature: (JB)J
*/
jlong Java_org_rocksdb_Statistics_getTickerCount(
JNIEnv* env, jobject jobj, jlong jhandle, jbyte jticker_type) {
jlong Java_org_rocksdb_Statistics_getTickerCount(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle,
jbyte jticker_type) {
auto* pSptr_statistics =
reinterpret_cast<std::shared_ptr<rocksdb::Statistics>*>(jhandle);
assert(pSptr_statistics != nullptr);
@ -154,8 +157,10 @@ jlong Java_org_rocksdb_Statistics_getTickerCount(
* Method: getAndResetTickerCount
* Signature: (JB)J
*/
jlong Java_org_rocksdb_Statistics_getAndResetTickerCount(
JNIEnv* env, jobject jobj, jlong jhandle, jbyte jticker_type) {
jlong Java_org_rocksdb_Statistics_getAndResetTickerCount(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle,
jbyte jticker_type) {
auto* pSptr_statistics =
reinterpret_cast<std::shared_ptr<rocksdb::Statistics>*>(jhandle);
assert(pSptr_statistics != nullptr);
@ -168,33 +173,35 @@ jlong Java_org_rocksdb_Statistics_getAndResetTickerCount(
* Method: getHistogramData
* Signature: (JB)Lorg/rocksdb/HistogramData;
*/
jobject Java_org_rocksdb_Statistics_getHistogramData(
JNIEnv* env, jobject jobj, jlong jhandle, jbyte jhistogram_type) {
jobject Java_org_rocksdb_Statistics_getHistogramData(JNIEnv* env,
jobject /*jobj*/,
jlong jhandle,
jbyte jhistogram_type) {
auto* pSptr_statistics =
reinterpret_cast<std::shared_ptr<rocksdb::Statistics>*>(jhandle);
assert(pSptr_statistics != nullptr);
rocksdb::HistogramData data; // TODO(AR) perhaps better to construct a Java Object Wrapper that uses ptr to C++ `new HistogramData`
rocksdb::HistogramData
data; // TODO(AR) perhaps better to construct a Java Object Wrapper that
// uses ptr to C++ `new HistogramData`
auto histogram = rocksdb::HistogramTypeJni::toCppHistograms(jhistogram_type);
pSptr_statistics->get()->histogramData(
static_cast<rocksdb::Histograms>(histogram), &data);
jclass jclazz = rocksdb::HistogramDataJni::getJClass(env);
if(jclazz == nullptr) {
if (jclazz == nullptr) {
// exception occurred accessing class
return nullptr;
}
jmethodID mid = rocksdb::HistogramDataJni::getConstructorMethodId(
env);
if(mid == nullptr) {
jmethodID mid = rocksdb::HistogramDataJni::getConstructorMethodId(env);
if (mid == nullptr) {
// exception occurred accessing method
return nullptr;
}
return env->NewObject(
jclazz,
mid, data.median, data.percentile95,data.percentile99, data.average,
return env->NewObject(jclazz, mid, data.median, data.percentile95,
data.percentile99, data.average,
data.standard_deviation);
}
@ -203,8 +210,10 @@ jobject Java_org_rocksdb_Statistics_getHistogramData(
* Method: getHistogramString
* Signature: (JB)Ljava/lang/String;
*/
jstring Java_org_rocksdb_Statistics_getHistogramString(
JNIEnv* env, jobject jobj, jlong jhandle, jbyte jhistogram_type) {
jstring Java_org_rocksdb_Statistics_getHistogramString(JNIEnv* env,
jobject /*jobj*/,
jlong jhandle,
jbyte jhistogram_type) {
auto* pSptr_statistics =
reinterpret_cast<std::shared_ptr<rocksdb::Statistics>*>(jhandle);
assert(pSptr_statistics != nullptr);
@ -218,8 +227,8 @@ jstring Java_org_rocksdb_Statistics_getHistogramString(
* Method: reset
* Signature: (J)V
*/
void Java_org_rocksdb_Statistics_reset(
JNIEnv* env, jobject jobj, jlong jhandle) {
void Java_org_rocksdb_Statistics_reset(JNIEnv* env, jobject /*jobj*/,
jlong jhandle) {
auto* pSptr_statistics =
reinterpret_cast<std::shared_ptr<rocksdb::Statistics>*>(jhandle);
assert(pSptr_statistics != nullptr);
@ -234,8 +243,8 @@ void Java_org_rocksdb_Statistics_reset(
* Method: toString
* Signature: (J)Ljava/lang/String;
*/
jstring Java_org_rocksdb_Statistics_toString(
JNIEnv* env, jobject jobj, jlong jhandle) {
jstring Java_org_rocksdb_Statistics_toString(JNIEnv* env, jobject /*jobj*/,
jlong jhandle) {
auto* pSptr_statistics =
reinterpret_cast<std::shared_ptr<rocksdb::Statistics>*>(jhandle);
assert(pSptr_statistics != nullptr);

@ -5,10 +5,10 @@
//
// This file implements the "bridge" between Java and C++ for rocksdb::Options.
#include "rocksdb/table.h"
#include <jni.h>
#include "include/org_rocksdb_PlainTableConfig.h"
#include "include/org_rocksdb_BlockBasedTableConfig.h"
#include "rocksdb/table.h"
#include "include/org_rocksdb_PlainTableConfig.h"
#include "rocksdb/cache.h"
#include "rocksdb/filter_policy.h"
@ -18,18 +18,17 @@
* Signature: (IIDIIBZZ)J
*/
jlong Java_org_rocksdb_PlainTableConfig_newTableFactoryHandle(
JNIEnv* env, jobject jobj, jint jkey_size, jint jbloom_bits_per_key,
jdouble jhash_table_ratio, jint jindex_sparseness,
jint jhuge_page_tlb_size, jbyte jencoding_type,
jboolean jfull_scan_mode, jboolean jstore_index_in_file) {
JNIEnv * /*env*/, jobject /*jobj*/, jint jkey_size,
jint jbloom_bits_per_key, jdouble jhash_table_ratio, jint jindex_sparseness,
jint jhuge_page_tlb_size, jbyte jencoding_type, jboolean jfull_scan_mode,
jboolean jstore_index_in_file) {
rocksdb::PlainTableOptions options = rocksdb::PlainTableOptions();
options.user_key_len = jkey_size;
options.bloom_bits_per_key = jbloom_bits_per_key;
options.hash_table_ratio = jhash_table_ratio;
options.index_sparseness = jindex_sparseness;
options.huge_page_tlb_size = jhuge_page_tlb_size;
options.encoding_type = static_cast<rocksdb::EncodingType>(
jencoding_type);
options.encoding_type = static_cast<rocksdb::EncodingType>(jencoding_type);
options.full_scan_mode = jfull_scan_mode;
options.store_index_in_file = jstore_index_in_file;
return reinterpret_cast<jlong>(rocksdb::NewPlainTableFactory(options));
@ -41,9 +40,9 @@ jlong Java_org_rocksdb_PlainTableConfig_newTableFactoryHandle(
* Signature: (ZJIJJIIZIZZZJIBBI)J
*/
jlong Java_org_rocksdb_BlockBasedTableConfig_newTableFactoryHandle(
JNIEnv *env, jobject jobj, jboolean no_block_cache, jlong block_cache_size,
jint block_cache_num_shardbits, jlong jblock_cache, jlong block_size,
jint block_size_deviation, jint block_restart_interval,
JNIEnv * /*env*/, jobject /*jobj*/, jboolean no_block_cache,
jlong block_cache_size, jint block_cache_num_shardbits, jlong jblock_cache,
jlong block_size, jint block_size_deviation, jint block_restart_interval,
jboolean whole_key_filtering, jlong jfilter_policy,
jboolean cache_index_and_filter_blocks,
jboolean pin_l0_filter_and_index_blocks_in_cache,
@ -83,16 +82,15 @@ jlong Java_org_rocksdb_BlockBasedTableConfig_newTableFactoryHandle(
options.hash_index_allow_collision = hash_index_allow_collision;
if (block_cache_compressed_size > 0) {
if (block_cache_compressd_num_shard_bits > 0) {
options.block_cache =
rocksdb::NewLRUCache(block_cache_compressed_size,
block_cache_compressd_num_shard_bits);
options.block_cache = rocksdb::NewLRUCache(
block_cache_compressed_size, block_cache_compressd_num_shard_bits);
} else {
options.block_cache = rocksdb::NewLRUCache(block_cache_compressed_size);
}
}
options.checksum = static_cast<rocksdb::ChecksumType>(jchecksum_type);
options.index_type = static_cast<
rocksdb::BlockBasedTableOptions::IndexType>(jindex_type);
options.index_type =
static_cast<rocksdb::BlockBasedTableOptions::IndexType>(jindex_type);
options.format_version = jformat_version;
return reinterpret_cast<jlong>(rocksdb::NewBlockBasedTableFactory(options));

File diff suppressed because it is too large Load Diff

@ -11,7 +11,6 @@
#include <memory>
#include <utility>
#include "include/org_rocksdb_TransactionDB.h"
#include "rocksdb/options.h"
@ -25,9 +24,9 @@
* Method: open
* Signature: (JJLjava/lang/String;)J
*/
jlong Java_org_rocksdb_TransactionDB_open__JJLjava_lang_String_2(JNIEnv* env,
jclass jcls, jlong joptions_handle, jlong jtxn_db_options_handle,
jstring jdb_path) {
jlong Java_org_rocksdb_TransactionDB_open__JJLjava_lang_String_2(
JNIEnv* env, jclass /*jcls*/, jlong joptions_handle,
jlong jtxn_db_options_handle, jstring jdb_path) {
auto* options = reinterpret_cast<rocksdb::Options*>(joptions_handle);
auto* txn_db_options =
reinterpret_cast<rocksdb::TransactionDBOptions*>(jtxn_db_options_handle);
@ -55,9 +54,8 @@ jlong Java_org_rocksdb_TransactionDB_open__JJLjava_lang_String_2(JNIEnv* env,
* Signature: (JJLjava/lang/String;[[B[J)[J
*/
jlongArray Java_org_rocksdb_TransactionDB_open__JJLjava_lang_String_2_3_3B_3J(
JNIEnv* env, jclass jcls, jlong jdb_options_handle,
jlong jtxn_db_options_handle, jstring jdb_path,
jobjectArray jcolumn_names,
JNIEnv* env, jclass /*jcls*/, 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) {
@ -106,7 +104,7 @@ jlongArray Java_org_rocksdb_TransactionDB_open__JJLjava_lang_String_2_3_3B_3J(
env->ReleaseStringUTFChars(jdb_path, db_path);
return nullptr;
}
const std::string cf_name(reinterpret_cast<char *>(jcf_name), jcf_name_len);
const std::string cf_name(reinterpret_cast<char*>(jcf_name), jcf_name_len);
const rocksdb::ColumnFamilyOptions* cf_options =
reinterpret_cast<rocksdb::ColumnFamilyOptions*>(jco[i]);
column_families.push_back(
@ -122,8 +120,8 @@ jlongArray Java_org_rocksdb_TransactionDB_open__JJLjava_lang_String_2_3_3B_3J(
reinterpret_cast<rocksdb::TransactionDBOptions*>(jtxn_db_options_handle);
std::vector<rocksdb::ColumnFamilyHandle*> handles;
rocksdb::TransactionDB* tdb = nullptr;
const rocksdb::Status s = rocksdb::TransactionDB::Open(*db_options, *txn_db_options,
db_path, column_families, &handles, &tdb);
const rocksdb::Status s = rocksdb::TransactionDB::Open(
*db_options, *txn_db_options, db_path, column_families, &handles, &tdb);
// check if open operation was successful
if (s.ok()) {
@ -158,8 +156,9 @@ jlongArray Java_org_rocksdb_TransactionDB_open__JJLjava_lang_String_2_3_3B_3J(
* Method: beginTransaction
* Signature: (JJ)J
*/
jlong Java_org_rocksdb_TransactionDB_beginTransaction__JJ(JNIEnv* env,
jobject jobj, jlong jhandle, jlong jwrite_options_handle) {
jlong Java_org_rocksdb_TransactionDB_beginTransaction__JJ(
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jlong jwrite_options_handle) {
auto* txn_db = reinterpret_cast<rocksdb::TransactionDB*>(jhandle);
auto* write_options =
reinterpret_cast<rocksdb::WriteOptions*>(jwrite_options_handle);
@ -172,9 +171,9 @@ jlong Java_org_rocksdb_TransactionDB_beginTransaction__JJ(JNIEnv* env,
* Method: beginTransaction
* Signature: (JJJ)J
*/
jlong Java_org_rocksdb_TransactionDB_beginTransaction__JJJ(JNIEnv* env,
jobject jobj, jlong jhandle, jlong jwrite_options_handle,
jlong jtxn_options_handle) {
jlong Java_org_rocksdb_TransactionDB_beginTransaction__JJJ(
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jlong jwrite_options_handle, jlong jtxn_options_handle) {
auto* txn_db = reinterpret_cast<rocksdb::TransactionDB*>(jhandle);
auto* write_options =
reinterpret_cast<rocksdb::WriteOptions*>(jwrite_options_handle);
@ -191,8 +190,8 @@ jlong Java_org_rocksdb_TransactionDB_beginTransaction__JJJ(JNIEnv* env,
* Signature: (JJJ)J
*/
jlong Java_org_rocksdb_TransactionDB_beginTransaction_1withOld__JJJ(
JNIEnv* env, jobject jobj, jlong jhandle, jlong jwrite_options_handle,
jlong jold_txn_handle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jlong jwrite_options_handle, jlong jold_txn_handle) {
auto* txn_db = reinterpret_cast<rocksdb::TransactionDB*>(jhandle);
auto* write_options =
reinterpret_cast<rocksdb::WriteOptions*>(jwrite_options_handle);
@ -215,16 +214,17 @@ jlong Java_org_rocksdb_TransactionDB_beginTransaction_1withOld__JJJ(
* Signature: (JJJJ)J
*/
jlong Java_org_rocksdb_TransactionDB_beginTransaction_1withOld__JJJJ(
JNIEnv* env, jobject jobj, jlong jhandle, jlong jwrite_options_handle,
jlong jtxn_options_handle, jlong jold_txn_handle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jlong jwrite_options_handle, jlong jtxn_options_handle,
jlong jold_txn_handle) {
auto* txn_db = reinterpret_cast<rocksdb::TransactionDB*>(jhandle);
auto* write_options =
reinterpret_cast<rocksdb::WriteOptions*>(jwrite_options_handle);
auto* txn_options =
reinterpret_cast<rocksdb::TransactionOptions*>(jtxn_options_handle);
auto* old_txn = reinterpret_cast<rocksdb::Transaction*>(jold_txn_handle);
rocksdb::Transaction* txn = txn_db->BeginTransaction(*write_options,
*txn_options, old_txn);
rocksdb::Transaction* txn =
txn_db->BeginTransaction(*write_options, *txn_options, old_txn);
// RocksJava relies on the assumption that
// we do not allocate a new Transaction object
@ -240,7 +240,9 @@ jlong Java_org_rocksdb_TransactionDB_beginTransaction_1withOld__JJJJ(
* Signature: (JLjava/lang/String;)J
*/
jlong Java_org_rocksdb_TransactionDB_getTransactionByName(JNIEnv* env,
jobject jobj, jlong jhandle, jstring jname) {
jobject /*jobj*/,
jlong jhandle,
jstring jname) {
auto* txn_db = reinterpret_cast<rocksdb::TransactionDB*>(jhandle);
const char* name = env->GetStringUTFChars(jname, nullptr);
if (name == nullptr) {
@ -258,7 +260,7 @@ jlong Java_org_rocksdb_TransactionDB_getTransactionByName(JNIEnv* env,
* Signature: (J)[J
*/
jlongArray Java_org_rocksdb_TransactionDB_getAllPreparedTransactions(
JNIEnv* env, jobject jobj, jlong jhandle) {
JNIEnv* env, jobject /*jobj*/, jlong jhandle) {
auto* txn_db = reinterpret_cast<rocksdb::TransactionDB*>(jhandle);
std::vector<rocksdb::Transaction*> txns;
txn_db->GetAllPreparedTransactions(&txns);
@ -292,20 +294,24 @@ jlongArray Java_org_rocksdb_TransactionDB_getAllPreparedTransactions(
* Method: getLockStatusData
* Signature: (J)Ljava/util/Map;
*/
jobject Java_org_rocksdb_TransactionDB_getLockStatusData(
JNIEnv* env, jobject jobj, jlong jhandle) {
jobject Java_org_rocksdb_TransactionDB_getLockStatusData(JNIEnv* env,
jobject /*jobj*/,
jlong jhandle) {
auto* txn_db = reinterpret_cast<rocksdb::TransactionDB*>(jhandle);
const std::unordered_multimap<uint32_t, rocksdb::KeyLockInfo> lock_status_data =
txn_db->GetLockStatusData();
const jobject jlock_status_data = rocksdb::HashMapJni::construct(env,
static_cast<uint32_t>(lock_status_data.size()));
const std::unordered_multimap<uint32_t, rocksdb::KeyLockInfo>
lock_status_data = txn_db->GetLockStatusData();
const jobject jlock_status_data = rocksdb::HashMapJni::construct(
env, static_cast<uint32_t>(lock_status_data.size()));
if (jlock_status_data == nullptr) {
// exception occurred
return nullptr;
}
const rocksdb::HashMapJni::FnMapKV<const int32_t, const rocksdb::KeyLockInfo> fn_map_kv =
[env, txn_db, &lock_status_data](const std::pair<const int32_t, const rocksdb::KeyLockInfo>& pair) {
const rocksdb::HashMapJni::FnMapKV<const int32_t, const rocksdb::KeyLockInfo>
fn_map_kv =
[env, txn_db, &lock_status_data](
const std::pair<const int32_t, const rocksdb::KeyLockInfo>&
pair) {
const jobject jlong_column_family_id =
rocksdb::LongJni::valueOf(env, pair.first);
if (jlong_column_family_id == nullptr) {
@ -318,12 +324,14 @@ jobject Java_org_rocksdb_TransactionDB_getLockStatusData(
// an error occurred
return std::unique_ptr<std::pair<jobject, jobject>>(nullptr);
}
return std::unique_ptr<std::pair<jobject, jobject>>(new std::pair<jobject, jobject>(jlong_column_family_id,
return std::unique_ptr<std::pair<jobject, jobject>>(
new std::pair<jobject, jobject>(jlong_column_family_id,
jkey_lock_info));
};
if(!rocksdb::HashMapJni::putAll(env, jlock_status_data,
lock_status_data.begin(), lock_status_data.end(), fn_map_kv)) {
if (!rocksdb::HashMapJni::putAll(env, jlock_status_data,
lock_status_data.begin(),
lock_status_data.end(), fn_map_kv)) {
// exception occcurred
return nullptr;
}
@ -332,10 +340,10 @@ jobject Java_org_rocksdb_TransactionDB_getLockStatusData(
}
/*
* Class: org_rocksdb_TransactionDB
* Method: getDeadlockInfoBuffer
* Signature: (J)[Lorg/rocksdb/TransactionDB/DeadlockPath;
*/
* Class: org_rocksdb_TransactionDB
* Method: getDeadlockInfoBuffer
* Signature: (J)[Lorg/rocksdb/TransactionDB/DeadlockPath;
*/
jobjectArray Java_org_rocksdb_TransactionDB_getDeadlockInfoBuffer(
JNIEnv* env, jobject jobj, jlong jhandle) {
auto* txn_db = reinterpret_cast<rocksdb::TransactionDB*>(jhandle);
@ -354,14 +362,15 @@ jobjectArray Java_org_rocksdb_TransactionDB_getDeadlockInfoBuffer(
jsize jdeadlock_info_buffer_offset = 0;
auto buf_end = deadlock_info_buffer.end();
for (auto buf_it = deadlock_info_buffer.begin(); buf_it != buf_end; ++buf_it) {
for (auto buf_it = deadlock_info_buffer.begin(); buf_it != buf_end;
++buf_it) {
const rocksdb::DeadlockPath deadlock_path = *buf_it;
const std::vector<rocksdb::DeadlockInfo> deadlock_infos
= deadlock_path.path;
const std::vector<rocksdb::DeadlockInfo> deadlock_infos =
deadlock_path.path;
const jsize deadlock_infos_len =
static_cast<jsize>(deadlock_info_buffer.size());
jobjectArray jdeadlock_infos = env->NewObjectArray(deadlock_infos_len,
rocksdb::DeadlockInfoJni::getJClass(env), nullptr);
jobjectArray jdeadlock_infos = env->NewObjectArray(
deadlock_infos_len, rocksdb::DeadlockInfoJni::getJClass(env), nullptr);
if (jdeadlock_infos == nullptr) {
// exception thrown: OutOfMemoryError
env->DeleteLocalRef(jdeadlock_info_buffer);
@ -370,7 +379,8 @@ jobjectArray Java_org_rocksdb_TransactionDB_getDeadlockInfoBuffer(
jsize jdeadlock_infos_offset = 0;
auto infos_end = deadlock_infos.end();
for (auto infos_it = deadlock_infos.begin(); infos_it != infos_end; ++infos_it) {
for (auto infos_it = deadlock_infos.begin(); infos_it != infos_end;
++infos_it) {
const rocksdb::DeadlockInfo deadlock_info = *infos_it;
const jobject jdeadlock_info = rocksdb::TransactionDBJni::newDeadlockInfo(
env, jobj, deadlock_info.m_txn_id, deadlock_info.m_cf_id,
@ -380,24 +390,26 @@ jobjectArray Java_org_rocksdb_TransactionDB_getDeadlockInfoBuffer(
env->DeleteLocalRef(jdeadlock_info_buffer);
return nullptr;
}
env->SetObjectArrayElement(jdeadlock_infos, jdeadlock_infos_offset++, jdeadlock_info);
env->SetObjectArrayElement(jdeadlock_infos, jdeadlock_infos_offset++,
jdeadlock_info);
if (env->ExceptionCheck()) {
// exception thrown: ArrayIndexOutOfBoundsException or ArrayStoreException
// exception thrown: ArrayIndexOutOfBoundsException or
// ArrayStoreException
env->DeleteLocalRef(jdeadlock_info);
env->DeleteLocalRef(jdeadlock_info_buffer);
return nullptr;
}
}
const jobject jdeadlock_path =
rocksdb::DeadlockPathJni::construct(env, jdeadlock_infos,
deadlock_path.limit_exceeded);
if(jdeadlock_path == nullptr) {
const jobject jdeadlock_path = rocksdb::DeadlockPathJni::construct(
env, jdeadlock_infos, deadlock_path.limit_exceeded);
if (jdeadlock_path == nullptr) {
// exception occcurred
env->DeleteLocalRef(jdeadlock_info_buffer);
return nullptr;
}
env->SetObjectArrayElement(jdeadlock_info_buffer, jdeadlock_info_buffer_offset++, jdeadlock_path);
env->SetObjectArrayElement(jdeadlock_info_buffer,
jdeadlock_info_buffer_offset++, jdeadlock_path);
if (env->ExceptionCheck()) {
// exception thrown: ArrayIndexOutOfBoundsException or ArrayStoreException
env->DeleteLocalRef(jdeadlock_path);
@ -410,12 +422,13 @@ jobjectArray Java_org_rocksdb_TransactionDB_getDeadlockInfoBuffer(
}
/*
* Class: org_rocksdb_TransactionDB
* Method: setDeadlockInfoBufferSize
* Signature: (JI)V
*/
* Class: org_rocksdb_TransactionDB
* Method: setDeadlockInfoBufferSize
* Signature: (JI)V
*/
void Java_org_rocksdb_TransactionDB_setDeadlockInfoBufferSize(
JNIEnv* env, jobject jobj, jlong jhandle, jint jdeadlock_info_buffer_size) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jint jdeadlock_info_buffer_size) {
auto* txn_db = reinterpret_cast<rocksdb::TransactionDB*>(jhandle);
txn_db->SetDeadlockInfoBufferSize(jdeadlock_info_buffer_size);
}
@ -425,7 +438,8 @@ void Java_org_rocksdb_TransactionDB_setDeadlockInfoBufferSize(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_TransactionDB_disposeInternal(JNIEnv* env, jobject jobj,
void Java_org_rocksdb_TransactionDB_disposeInternal(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
delete reinterpret_cast<rocksdb::TransactionDB*>(jhandle);
}

@ -20,7 +20,7 @@
* Signature: ()J
*/
jlong Java_org_rocksdb_TransactionDBOptions_newTransactionDBOptions(
JNIEnv* env, jclass jcls) {
JNIEnv* /*env*/, jclass /*jcls*/) {
rocksdb::TransactionDBOptions* opts = new rocksdb::TransactionDBOptions();
return reinterpret_cast<jlong>(opts);
}
@ -30,8 +30,9 @@ jlong Java_org_rocksdb_TransactionDBOptions_newTransactionDBOptions(
* Method: getMaxNumLocks
* Signature: (J)J
*/
jlong Java_org_rocksdb_TransactionDBOptions_getMaxNumLocks(JNIEnv* env,
jobject jobj, jlong jhandle) {
jlong Java_org_rocksdb_TransactionDBOptions_getMaxNumLocks(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* opts = reinterpret_cast<rocksdb::TransactionDBOptions*>(jhandle);
return opts->max_num_locks;
}
@ -41,8 +42,8 @@ jlong Java_org_rocksdb_TransactionDBOptions_getMaxNumLocks(JNIEnv* env,
* Method: setMaxNumLocks
* Signature: (JJ)V
*/
void Java_org_rocksdb_TransactionDBOptions_setMaxNumLocks(JNIEnv* env,
jobject jobj, jlong jhandle, jlong jmax_num_locks) {
void Java_org_rocksdb_TransactionDBOptions_setMaxNumLocks(
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jlong jmax_num_locks) {
auto* opts = reinterpret_cast<rocksdb::TransactionDBOptions*>(jhandle);
opts->max_num_locks = jmax_num_locks;
}
@ -52,8 +53,9 @@ void Java_org_rocksdb_TransactionDBOptions_setMaxNumLocks(JNIEnv* env,
* Method: getNumStripes
* Signature: (J)J
*/
jlong Java_org_rocksdb_TransactionDBOptions_getNumStripes(JNIEnv* env,
jobject jobj, jlong jhandle) {
jlong Java_org_rocksdb_TransactionDBOptions_getNumStripes(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* opts = reinterpret_cast<rocksdb::TransactionDBOptions*>(jhandle);
return opts->num_stripes;
}
@ -63,8 +65,10 @@ jlong Java_org_rocksdb_TransactionDBOptions_getNumStripes(JNIEnv* env,
* Method: setNumStripes
* Signature: (JJ)V
*/
void Java_org_rocksdb_TransactionDBOptions_setNumStripes(JNIEnv* env,
jobject jobj, jlong jhandle, jlong jnum_stripes) {
void Java_org_rocksdb_TransactionDBOptions_setNumStripes(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle,
jlong jnum_stripes) {
auto* opts = reinterpret_cast<rocksdb::TransactionDBOptions*>(jhandle);
opts->num_stripes = jnum_stripes;
}
@ -75,7 +79,7 @@ void Java_org_rocksdb_TransactionDBOptions_setNumStripes(JNIEnv* env,
* Signature: (J)J
*/
jlong Java_org_rocksdb_TransactionDBOptions_getTransactionLockTimeout(
JNIEnv* env, jobject jobj, jlong jhandle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
auto* opts = reinterpret_cast<rocksdb::TransactionDBOptions*>(jhandle);
return opts->transaction_lock_timeout;
}
@ -86,7 +90,8 @@ jlong Java_org_rocksdb_TransactionDBOptions_getTransactionLockTimeout(
* Signature: (JJ)V
*/
void Java_org_rocksdb_TransactionDBOptions_setTransactionLockTimeout(
JNIEnv* env, jobject jobj, jlong jhandle, jlong jtransaction_lock_timeout) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jlong jtransaction_lock_timeout) {
auto* opts = reinterpret_cast<rocksdb::TransactionDBOptions*>(jhandle);
opts->transaction_lock_timeout = jtransaction_lock_timeout;
}
@ -97,7 +102,7 @@ void Java_org_rocksdb_TransactionDBOptions_setTransactionLockTimeout(
* Signature: (J)J
*/
jlong Java_org_rocksdb_TransactionDBOptions_getDefaultLockTimeout(
JNIEnv* env, jobject jobj, jlong jhandle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
auto* opts = reinterpret_cast<rocksdb::TransactionDBOptions*>(jhandle);
return opts->default_lock_timeout;
}
@ -108,7 +113,8 @@ jlong Java_org_rocksdb_TransactionDBOptions_getDefaultLockTimeout(
* Signature: (JJ)V
*/
void Java_org_rocksdb_TransactionDBOptions_setDefaultLockTimeout(
JNIEnv* env, jobject jobj, jlong jhandle, jlong jdefault_lock_timeout) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jlong jdefault_lock_timeout) {
auto* opts = reinterpret_cast<rocksdb::TransactionDBOptions*>(jhandle);
opts->default_lock_timeout = jdefault_lock_timeout;
}
@ -118,19 +124,23 @@ void Java_org_rocksdb_TransactionDBOptions_setDefaultLockTimeout(
* Method: getWritePolicy
* Signature: (J)B
*/
jbyte Java_org_rocksdb_TransactionDBOptions_getWritePolicy(
JNIEnv* env, jobject jobj, jlong jhandle) {
jbyte Java_org_rocksdb_TransactionDBOptions_getWritePolicy(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* opts = reinterpret_cast<rocksdb::TransactionDBOptions*>(jhandle);
return rocksdb::TxnDBWritePolicyJni::toJavaTxnDBWritePolicy(opts->write_policy);
return rocksdb::TxnDBWritePolicyJni::toJavaTxnDBWritePolicy(
opts->write_policy);
}
/*
* Class: org_rocksdb_TransactionDBOptions
* Method: setWritePolicy
* Signature: (JB)V
*/
void Java_org_rocksdb_TransactionDBOptions_setWritePolicy(
JNIEnv* env, jobject jobj, jlong jhandle, jbyte jwrite_policy) {
* Class: org_rocksdb_TransactionDBOptions
* Method: setWritePolicy
* Signature: (JB)V
*/
void Java_org_rocksdb_TransactionDBOptions_setWritePolicy(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle,
jbyte jwrite_policy) {
auto* opts = reinterpret_cast<rocksdb::TransactionDBOptions*>(jhandle);
opts->write_policy =
rocksdb::TxnDBWritePolicyJni::toCppTxnDBWritePolicy(jwrite_policy);
@ -141,7 +151,8 @@ void Java_org_rocksdb_TransactionDBOptions_setWritePolicy(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_TransactionDBOptions_disposeInternal(JNIEnv* env,
jobject jobj, jlong jhandle) {
void Java_org_rocksdb_TransactionDBOptions_disposeInternal(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
delete reinterpret_cast<rocksdb::TransactionDBOptions*>(jhandle);
}

@ -19,8 +19,9 @@
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_TransactionLogIterator_disposeInternal(
JNIEnv* env, jobject jobj, jlong handle) {
void Java_org_rocksdb_TransactionLogIterator_disposeInternal(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong handle) {
delete reinterpret_cast<rocksdb::TransactionLogIterator*>(handle);
}
@ -29,8 +30,9 @@ void Java_org_rocksdb_TransactionLogIterator_disposeInternal(
* Method: isValid
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_TransactionLogIterator_isValid(
JNIEnv* env, jobject jobj, jlong handle) {
jboolean Java_org_rocksdb_TransactionLogIterator_isValid(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong handle) {
return reinterpret_cast<rocksdb::TransactionLogIterator*>(handle)->Valid();
}
@ -39,8 +41,9 @@ jboolean Java_org_rocksdb_TransactionLogIterator_isValid(
* Method: next
* Signature: (J)V
*/
void Java_org_rocksdb_TransactionLogIterator_next(
JNIEnv* env, jobject jobj, jlong handle) {
void Java_org_rocksdb_TransactionLogIterator_next(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong handle) {
reinterpret_cast<rocksdb::TransactionLogIterator*>(handle)->Next();
}
@ -49,10 +52,11 @@ void Java_org_rocksdb_TransactionLogIterator_next(
* Method: status
* Signature: (J)V
*/
void Java_org_rocksdb_TransactionLogIterator_status(
JNIEnv* env, jobject jobj, jlong handle) {
rocksdb::Status s = reinterpret_cast<
rocksdb::TransactionLogIterator*>(handle)->status();
void Java_org_rocksdb_TransactionLogIterator_status(JNIEnv* env,
jobject /*jobj*/,
jlong handle) {
rocksdb::Status s =
reinterpret_cast<rocksdb::TransactionLogIterator*>(handle)->status();
if (!s.ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, s);
}
@ -63,8 +67,9 @@ void Java_org_rocksdb_TransactionLogIterator_status(
* Method: getBatch
* Signature: (J)Lorg/rocksdb/TransactionLogIterator$BatchResult
*/
jobject Java_org_rocksdb_TransactionLogIterator_getBatch(
JNIEnv* env, jobject jobj, jlong handle) {
jobject Java_org_rocksdb_TransactionLogIterator_getBatch(JNIEnv* env,
jobject /*jobj*/,
jlong handle) {
rocksdb::BatchResult batch_result =
reinterpret_cast<rocksdb::TransactionLogIterator*>(handle)->GetBatch();
return rocksdb::BatchResultJni::construct(env, batch_result);

@ -31,12 +31,12 @@ jlong Java_org_rocksdb_AbstractTransactionNotifier_createNewTransactionNotifier(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_AbstractTransactionNotifier_disposeInternal(JNIEnv* env,
jobject jobj, jlong jhandle) {
void Java_org_rocksdb_AbstractTransactionNotifier_disposeInternal(
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
// TODO(AR) refactor to use JniCallback::JniCallback
// when https://github.com/facebook/rocksdb/pull/1241/ is merged
std::shared_ptr<rocksdb::TransactionNotifierJniCallback>* handle =
reinterpret_cast<std::shared_ptr<
rocksdb::TransactionNotifierJniCallback>*>(jhandle);
reinterpret_cast<
std::shared_ptr<rocksdb::TransactionNotifierJniCallback>*>(jhandle);
delete handle;
}

@ -17,8 +17,8 @@
* Method: newTransactionOptions
* Signature: ()J
*/
jlong Java_org_rocksdb_TransactionOptions_newTransactionOptions(JNIEnv* env,
jclass jcls) {
jlong Java_org_rocksdb_TransactionOptions_newTransactionOptions(
JNIEnv* /*env*/, jclass /*jcls*/) {
auto* opts = new rocksdb::TransactionOptions();
return reinterpret_cast<jlong>(opts);
}
@ -28,8 +28,9 @@ jlong Java_org_rocksdb_TransactionOptions_newTransactionOptions(JNIEnv* env,
* Method: isSetSnapshot
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_TransactionOptions_isSetSnapshot(JNIEnv* env,
jobject jobj, jlong jhandle) {
jboolean Java_org_rocksdb_TransactionOptions_isSetSnapshot(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* opts = reinterpret_cast<rocksdb::TransactionOptions*>(jhandle);
return opts->set_snapshot;
}
@ -39,8 +40,8 @@ jboolean Java_org_rocksdb_TransactionOptions_isSetSnapshot(JNIEnv* env,
* Method: setSetSnapshot
* Signature: (JZ)V
*/
void Java_org_rocksdb_TransactionOptions_setSetSnapshot(JNIEnv* env,
jobject jobj, jlong jhandle, jboolean jset_snapshot) {
void Java_org_rocksdb_TransactionOptions_setSetSnapshot(
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jboolean jset_snapshot) {
auto* opts = reinterpret_cast<rocksdb::TransactionOptions*>(jhandle);
opts->set_snapshot = jset_snapshot;
}
@ -50,19 +51,21 @@ void Java_org_rocksdb_TransactionOptions_setSetSnapshot(JNIEnv* env,
* Method: isDeadlockDetect
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_TransactionOptions_isDeadlockDetect(
JNIEnv* env, jobject jobj, jlong jhandle) {
jboolean Java_org_rocksdb_TransactionOptions_isDeadlockDetect(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* opts = reinterpret_cast<rocksdb::TransactionOptions*>(jhandle);
return opts->deadlock_detect;
}
/*
* Class: org_rocksdb_TransactionOptions
* Method: setDeadlockDetect
* Signature: (JZ)V
*/
* Class: org_rocksdb_TransactionOptions
* Method: setDeadlockDetect
* Signature: (JZ)V
*/
void Java_org_rocksdb_TransactionOptions_setDeadlockDetect(
JNIEnv* env, jobject jobj, jlong jhandle, jboolean jdeadlock_detect) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jboolean jdeadlock_detect) {
auto* opts = reinterpret_cast<rocksdb::TransactionOptions*>(jhandle);
opts->deadlock_detect = jdeadlock_detect;
}
@ -72,8 +75,9 @@ void Java_org_rocksdb_TransactionOptions_setDeadlockDetect(
* Method: getLockTimeout
* Signature: (J)J
*/
jlong Java_org_rocksdb_TransactionOptions_getLockTimeout(JNIEnv* env,
jobject jobj, jlong jhandle) {
jlong Java_org_rocksdb_TransactionOptions_getLockTimeout(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* opts = reinterpret_cast<rocksdb::TransactionOptions*>(jhandle);
return opts->lock_timeout;
}
@ -83,8 +87,10 @@ jlong Java_org_rocksdb_TransactionOptions_getLockTimeout(JNIEnv* env,
* Method: setLockTimeout
* Signature: (JJ)V
*/
void Java_org_rocksdb_TransactionOptions_setLockTimeout(JNIEnv* env,
jobject jobj, jlong jhandle, jlong jlock_timeout) {
void Java_org_rocksdb_TransactionOptions_setLockTimeout(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle,
jlong jlock_timeout) {
auto* opts = reinterpret_cast<rocksdb::TransactionOptions*>(jhandle);
opts->lock_timeout = jlock_timeout;
}
@ -94,8 +100,9 @@ void Java_org_rocksdb_TransactionOptions_setLockTimeout(JNIEnv* env,
* Method: getExpiration
* Signature: (J)J
*/
jlong Java_org_rocksdb_TransactionOptions_getExpiration(JNIEnv* env,
jobject jobj, jlong jhandle) {
jlong Java_org_rocksdb_TransactionOptions_getExpiration(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* opts = reinterpret_cast<rocksdb::TransactionOptions*>(jhandle);
return opts->expiration;
}
@ -105,8 +112,10 @@ jlong Java_org_rocksdb_TransactionOptions_getExpiration(JNIEnv* env,
* Method: setExpiration
* Signature: (JJ)V
*/
void Java_org_rocksdb_TransactionOptions_setExpiration(JNIEnv* env,
jobject jobj, jlong jhandle, jlong jexpiration) {
void Java_org_rocksdb_TransactionOptions_setExpiration(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle,
jlong jexpiration) {
auto* opts = reinterpret_cast<rocksdb::TransactionOptions*>(jhandle);
opts->expiration = jexpiration;
}
@ -117,40 +126,43 @@ void Java_org_rocksdb_TransactionOptions_setExpiration(JNIEnv* env,
* Signature: (J)J
*/
jlong Java_org_rocksdb_TransactionOptions_getDeadlockDetectDepth(
JNIEnv* env, jobject jobj, jlong jhandle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
auto* opts = reinterpret_cast<rocksdb::TransactionOptions*>(jhandle);
return opts->deadlock_detect_depth;
}
/*
* Class: org_rocksdb_TransactionOptions
* Method: setDeadlockDetectDepth
* Signature: (JJ)V
*/
* Class: org_rocksdb_TransactionOptions
* Method: setDeadlockDetectDepth
* Signature: (JJ)V
*/
void Java_org_rocksdb_TransactionOptions_setDeadlockDetectDepth(
JNIEnv* env, jobject jobj, jlong jhandle, jlong jdeadlock_detect_depth) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jlong jdeadlock_detect_depth) {
auto* opts = reinterpret_cast<rocksdb::TransactionOptions*>(jhandle);
opts->deadlock_detect_depth = jdeadlock_detect_depth;
}
/*
* Class: org_rocksdb_TransactionOptions
* Method: getMaxWriteBatchSize
* Signature: (J)J
*/
jlong Java_org_rocksdb_TransactionOptions_getMaxWriteBatchSize(
JNIEnv* env, jobject jobj, jlong jhandle) {
* Class: org_rocksdb_TransactionOptions
* Method: getMaxWriteBatchSize
* Signature: (J)J
*/
jlong Java_org_rocksdb_TransactionOptions_getMaxWriteBatchSize(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* opts = reinterpret_cast<rocksdb::TransactionOptions*>(jhandle);
return opts->max_write_batch_size;
}
/*
* Class: org_rocksdb_TransactionOptions
* Method: setMaxWriteBatchSize
* Signature: (JJ)V
*/
* Class: org_rocksdb_TransactionOptions
* Method: setMaxWriteBatchSize
* Signature: (JJ)V
*/
void Java_org_rocksdb_TransactionOptions_setMaxWriteBatchSize(
JNIEnv* env, jobject jobj, jlong jhandle, jlong jmax_write_batch_size) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jlong jmax_write_batch_size) {
auto* opts = reinterpret_cast<rocksdb::TransactionOptions*>(jhandle);
opts->max_write_batch_size = jmax_write_batch_size;
}
@ -160,7 +172,8 @@ void Java_org_rocksdb_TransactionOptions_setMaxWriteBatchSize(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_TransactionOptions_disposeInternal(JNIEnv* env,
jobject jobj, jlong jhandle) {
void Java_org_rocksdb_TransactionOptions_disposeInternal(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
delete reinterpret_cast<rocksdb::TransactionOptions*>(jhandle);
}

@ -10,9 +10,9 @@
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <memory>
#include <string>
#include <vector>
#include <memory>
#include "include/org_rocksdb_TtlDB.h"
#include "rocksdb/utilities/db_ttl.h"
@ -23,19 +23,19 @@
* Method: open
* Signature: (JLjava/lang/String;IZ)J
*/
jlong Java_org_rocksdb_TtlDB_open(JNIEnv* env,
jclass jcls, jlong joptions_handle, jstring jdb_path,
jlong Java_org_rocksdb_TtlDB_open(JNIEnv* env, jclass /*jcls*/,
jlong joptions_handle, jstring jdb_path,
jint jttl, jboolean jread_only) {
const char* db_path = env->GetStringUTFChars(jdb_path, nullptr);
if(db_path == nullptr) {
if (db_path == nullptr) {
// exception thrown: OutOfMemoryError
return 0;
}
auto* opt = reinterpret_cast<rocksdb::Options*>(joptions_handle);
rocksdb::DBWithTTL* db = nullptr;
rocksdb::Status s = rocksdb::DBWithTTL::Open(*opt, db_path, &db,
jttl, jread_only);
rocksdb::Status s =
rocksdb::DBWithTTL::Open(*opt, db_path, &db, jttl, jread_only);
env->ReleaseStringUTFChars(jdb_path, db_path);
// as TTLDB extends RocksDB on the java side, we can reuse
@ -53,20 +53,20 @@ jlong Java_org_rocksdb_TtlDB_open(JNIEnv* env,
* Method: openCF
* Signature: (JLjava/lang/String;[[B[J[IZ)[J
*/
jlongArray
Java_org_rocksdb_TtlDB_openCF(
JNIEnv* env, jclass jcls, jlong jopt_handle, jstring jdb_path,
jobjectArray jcolumn_names, jlongArray jcolumn_options,
jlongArray Java_org_rocksdb_TtlDB_openCF(JNIEnv* env, jclass /*jcls*/,
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) {
if (db_path == nullptr) {
// exception thrown: OutOfMemoryError
return 0;
}
const jsize len_cols = env->GetArrayLength(jcolumn_names);
jlong* jco = env->GetLongArrayElements(jcolumn_options, nullptr);
if(jco == nullptr) {
if (jco == nullptr) {
// exception thrown: OutOfMemoryError
env->ReleaseStringUTFChars(jdb_path, db_path);
return nullptr;
@ -75,8 +75,7 @@ jlongArray
std::vector<rocksdb::ColumnFamilyDescriptor> column_families;
jboolean has_exception = JNI_FALSE;
rocksdb::JniUtil::byteStrings<std::string>(
env,
jcolumn_names,
env, jcolumn_names,
[](const char* str_data, const size_t str_len) {
return std::string(str_data, str_len);
},
@ -90,7 +89,7 @@ jlongArray
env->ReleaseLongArrayElements(jcolumn_options, jco, JNI_ABORT);
if(has_exception == JNI_TRUE) {
if (has_exception == JNI_TRUE) {
// exception occurred
env->ReleaseStringUTFChars(jdb_path, db_path);
return nullptr;
@ -98,13 +97,13 @@ jlongArray
std::vector<int32_t> ttl_values;
jint* jttlv = env->GetIntArrayElements(jttls, nullptr);
if(jttlv == nullptr) {
if (jttlv == nullptr) {
// exception thrown: OutOfMemoryError
env->ReleaseStringUTFChars(jdb_path, db_path);
return nullptr;
}
const jsize len_ttls = env->GetArrayLength(jttls);
for(jsize i = 0; i < len_ttls; i++) {
for (jsize i = 0; i < len_ttls; i++) {
ttl_values.push_back(jttlv[i]);
}
env->ReleaseIntArrayElements(jttls, jttlv, JNI_ABORT);
@ -112,30 +111,30 @@ jlongArray
auto* opt = reinterpret_cast<rocksdb::DBOptions*>(jopt_handle);
std::vector<rocksdb::ColumnFamilyHandle*> handles;
rocksdb::DBWithTTL* db = nullptr;
rocksdb::Status s = rocksdb::DBWithTTL::Open(*opt, db_path, column_families,
&handles, &db, ttl_values, jread_only);
rocksdb::Status s = rocksdb::DBWithTTL::Open(
*opt, db_path, column_families, &handles, &db, ttl_values, jread_only);
// we have now finished with db_path
env->ReleaseStringUTFChars(jdb_path, db_path);
// check if open operation was successful
if (s.ok()) {
const jsize resultsLen = 1 + len_cols; //db handle + column family handles
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);
for(int i = 1; i <= len_cols; i++) {
for (int i = 1; i <= len_cols; i++) {
results[i] = reinterpret_cast<jlong>(handles[i - 1]);
}
jlongArray jresults = env->NewLongArray(resultsLen);
if(jresults == nullptr) {
if (jresults == nullptr) {
// exception thrown: OutOfMemoryError
return nullptr;
}
env->SetLongArrayRegion(jresults, 0, resultsLen, results.get());
if(env->ExceptionCheck()) {
if (env->ExceptionCheck()) {
// exception thrown: ArrayIndexOutOfBoundsException
env->DeleteLocalRef(jresults);
return nullptr;
@ -154,11 +153,10 @@ jlongArray
* Signature: (JLorg/rocksdb/ColumnFamilyDescriptor;[BJI)J;
*/
jlong Java_org_rocksdb_TtlDB_createColumnFamilyWithTtl(
JNIEnv* env, jobject jobj, jlong jdb_handle,
jbyteArray jcolumn_name, jlong jcolumn_options, jint jttl) {
JNIEnv* env, jobject /*jobj*/, jlong jdb_handle, jbyteArray jcolumn_name,
jlong jcolumn_options, jint jttl) {
jbyte* cfname = env->GetByteArrayElements(jcolumn_name, nullptr);
if(cfname == nullptr) {
if (cfname == nullptr) {
// exception thrown: OutOfMemoryError
return 0;
}
@ -170,8 +168,8 @@ jlong Java_org_rocksdb_TtlDB_createColumnFamilyWithTtl(
auto* db_handle = reinterpret_cast<rocksdb::DBWithTTL*>(jdb_handle);
rocksdb::ColumnFamilyHandle* handle;
rocksdb::Status s = db_handle->CreateColumnFamilyWithTtl(
*cfOptions, std::string(reinterpret_cast<char *>(cfname),
len), &handle, jttl);
*cfOptions, std::string(reinterpret_cast<char*>(cfname), len), &handle,
jttl);
env->ReleaseByteArrayElements(jcolumn_name, cfname, 0);

@ -27,8 +27,9 @@
* Method: newWriteBatch
* Signature: (I)J
*/
jlong Java_org_rocksdb_WriteBatch_newWriteBatch__I(
JNIEnv* env, jclass jcls, jint jreserved_bytes) {
jlong Java_org_rocksdb_WriteBatch_newWriteBatch__I(JNIEnv* /*env*/,
jclass /*jcls*/,
jint jreserved_bytes) {
auto* wb = new rocksdb::WriteBatch(static_cast<size_t>(jreserved_bytes));
return reinterpret_cast<jlong>(wb);
}
@ -38,15 +39,16 @@ jlong Java_org_rocksdb_WriteBatch_newWriteBatch__I(
* Method: newWriteBatch
* Signature: ([BI)J
*/
jlong Java_org_rocksdb_WriteBatch_newWriteBatch___3BI(
JNIEnv* env, jclass jcls, jbyteArray jserialized,
jlong Java_org_rocksdb_WriteBatch_newWriteBatch___3BI(JNIEnv* env,
jclass /*jcls*/,
jbyteArray jserialized,
jint jserialized_length) {
jboolean has_exception = JNI_FALSE;
std::string serialized = rocksdb::JniUtil::byteString<std::string>(env,
jserialized, jserialized_length,
std::string serialized = rocksdb::JniUtil::byteString<std::string>(
env, jserialized, jserialized_length,
[](const char* str, const size_t len) { return std::string(str, len); },
&has_exception);
if(has_exception == JNI_TRUE) {
if (has_exception == JNI_TRUE) {
// exception occurred
return 0;
}
@ -60,7 +62,7 @@ jlong Java_org_rocksdb_WriteBatch_newWriteBatch___3BI(
* Method: count0
* Signature: (J)I
*/
jint Java_org_rocksdb_WriteBatch_count0(JNIEnv* env, jobject jobj,
jint Java_org_rocksdb_WriteBatch_count0(JNIEnv* /*env*/, jobject /*jobj*/,
jlong jwb_handle) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
@ -73,7 +75,7 @@ jint Java_org_rocksdb_WriteBatch_count0(JNIEnv* env, jobject jobj,
* Method: clear0
* Signature: (J)V
*/
void Java_org_rocksdb_WriteBatch_clear0(JNIEnv* env, jobject jobj,
void Java_org_rocksdb_WriteBatch_clear0(JNIEnv* /*env*/, jobject /*jobj*/,
jlong jwb_handle) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
@ -86,8 +88,9 @@ void Java_org_rocksdb_WriteBatch_clear0(JNIEnv* env, jobject jobj,
* Method: setSavePoint0
* Signature: (J)V
*/
void Java_org_rocksdb_WriteBatch_setSavePoint0(
JNIEnv* env, jobject jobj, jlong jwb_handle) {
void Java_org_rocksdb_WriteBatch_setSavePoint0(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jwb_handle) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
@ -99,8 +102,9 @@ void Java_org_rocksdb_WriteBatch_setSavePoint0(
* Method: rollbackToSavePoint0
* Signature: (J)V
*/
void Java_org_rocksdb_WriteBatch_rollbackToSavePoint0(
JNIEnv* env, jobject jobj, jlong jwb_handle) {
void Java_org_rocksdb_WriteBatch_rollbackToSavePoint0(JNIEnv* env,
jobject /*jobj*/,
jlong jwb_handle) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
@ -117,8 +121,8 @@ void Java_org_rocksdb_WriteBatch_rollbackToSavePoint0(
* Method: popSavePoint
* Signature: (J)V
*/
void Java_org_rocksdb_WriteBatch_popSavePoint(
JNIEnv* env, jobject jobj, jlong jwb_handle) {
void Java_org_rocksdb_WriteBatch_popSavePoint(JNIEnv* env, jobject /*jobj*/,
jlong jwb_handle) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
@ -135,8 +139,9 @@ void Java_org_rocksdb_WriteBatch_popSavePoint(
* Method: setMaxBytes
* Signature: (JJ)V
*/
void Java_org_rocksdb_WriteBatch_setMaxBytes(
JNIEnv* env, jobject jobj, jlong jwb_handle, jlong jmax_bytes) {
void Java_org_rocksdb_WriteBatch_setMaxBytes(JNIEnv* /*env*/, jobject /*jobj*/,
jlong jwb_handle,
jlong jmax_bytes) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
@ -148,17 +153,18 @@ void Java_org_rocksdb_WriteBatch_setMaxBytes(
* Method: put
* Signature: (J[BI[BI)V
*/
void Java_org_rocksdb_WriteBatch_put__J_3BI_3BI(
JNIEnv* env, jobject jobj, jlong jwb_handle,
void Java_org_rocksdb_WriteBatch_put__J_3BI_3BI(JNIEnv* env, jobject jobj,
jlong jwb_handle,
jbyteArray jkey, jint jkey_len,
jbyteArray jentry_value, jint jentry_value_len) {
jbyteArray jentry_value,
jint jentry_value_len) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
auto put = [&wb] (rocksdb::Slice key, rocksdb::Slice value) {
auto put = [&wb](rocksdb::Slice key, rocksdb::Slice value) {
return wb->Put(key, value);
};
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::kv_op(put, env,
jobj, jkey, jkey_len, jentry_value, jentry_value_len);
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::kv_op(
put, env, jobj, jkey, jkey_len, jentry_value, jentry_value_len);
if (status != nullptr && !status->ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, status);
}
@ -170,18 +176,17 @@ void Java_org_rocksdb_WriteBatch_put__J_3BI_3BI(
* Signature: (J[BI[BIJ)V
*/
void Java_org_rocksdb_WriteBatch_put__J_3BI_3BIJ(
JNIEnv* env, jobject jobj, jlong jwb_handle,
jbyteArray jkey, jint jkey_len,
JNIEnv* env, jobject jobj, jlong jwb_handle, jbyteArray jkey, jint jkey_len,
jbyteArray jentry_value, jint jentry_value_len, jlong jcf_handle) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
auto* cf_handle = reinterpret_cast<rocksdb::ColumnFamilyHandle*>(jcf_handle);
assert(cf_handle != nullptr);
auto put = [&wb, &cf_handle] (rocksdb::Slice key, rocksdb::Slice value) {
auto put = [&wb, &cf_handle](rocksdb::Slice key, rocksdb::Slice value) {
return wb->Put(cf_handle, key, value);
};
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::kv_op(put, env,
jobj, jkey, jkey_len, jentry_value, jentry_value_len);
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::kv_op(
put, env, jobj, jkey, jkey_len, jentry_value, jentry_value_len);
if (status != nullptr && !status->ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, status);
}
@ -193,16 +198,15 @@ void Java_org_rocksdb_WriteBatch_put__J_3BI_3BIJ(
* Signature: (J[BI[BI)V
*/
void Java_org_rocksdb_WriteBatch_merge__J_3BI_3BI(
JNIEnv* env, jobject jobj, jlong jwb_handle,
jbyteArray jkey, jint jkey_len,
JNIEnv* env, jobject jobj, jlong jwb_handle, jbyteArray jkey, jint jkey_len,
jbyteArray jentry_value, jint jentry_value_len) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
auto merge = [&wb] (rocksdb::Slice key, rocksdb::Slice value) {
auto merge = [&wb](rocksdb::Slice key, rocksdb::Slice value) {
return wb->Merge(key, value);
};
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::kv_op(merge, env,
jobj, jkey, jkey_len, jentry_value, jentry_value_len);
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::kv_op(
merge, env, jobj, jkey, jkey_len, jentry_value, jentry_value_len);
if (status != nullptr && !status->ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, status);
}
@ -214,18 +218,17 @@ void Java_org_rocksdb_WriteBatch_merge__J_3BI_3BI(
* Signature: (J[BI[BIJ)V
*/
void Java_org_rocksdb_WriteBatch_merge__J_3BI_3BIJ(
JNIEnv* env, jobject jobj, jlong jwb_handle,
jbyteArray jkey, jint jkey_len,
JNIEnv* env, jobject jobj, jlong jwb_handle, jbyteArray jkey, jint jkey_len,
jbyteArray jentry_value, jint jentry_value_len, jlong jcf_handle) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
auto* cf_handle = reinterpret_cast<rocksdb::ColumnFamilyHandle*>(jcf_handle);
assert(cf_handle != nullptr);
auto merge = [&wb, &cf_handle] (rocksdb::Slice key, rocksdb::Slice value) {
auto merge = [&wb, &cf_handle](rocksdb::Slice key, rocksdb::Slice value) {
return wb->Merge(cf_handle, key, value);
};
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::kv_op(merge, env,
jobj, jkey, jkey_len, jentry_value, jentry_value_len);
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::kv_op(
merge, env, jobj, jkey, jkey_len, jentry_value, jentry_value_len);
if (status != nullptr && !status->ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, status);
}
@ -236,16 +239,14 @@ void Java_org_rocksdb_WriteBatch_merge__J_3BI_3BIJ(
* Method: delete
* Signature: (J[BI)V
*/
void Java_org_rocksdb_WriteBatch_delete__J_3BI(
JNIEnv* env, jobject jobj, jlong jwb_handle,
void Java_org_rocksdb_WriteBatch_delete__J_3BI(JNIEnv* env, jobject jobj,
jlong jwb_handle,
jbyteArray jkey, jint jkey_len) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
auto remove = [&wb] (rocksdb::Slice key) {
return wb->Delete(key);
};
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::k_op(remove, env,
jobj, jkey, jkey_len);
auto remove = [&wb](rocksdb::Slice key) { return wb->Delete(key); };
std::unique_ptr<rocksdb::Status> status =
rocksdb::JniUtil::k_op(remove, env, jobj, jkey, jkey_len);
if (status != nullptr && !status->ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, status);
}
@ -256,18 +257,19 @@ void Java_org_rocksdb_WriteBatch_delete__J_3BI(
* Method: delete
* Signature: (J[BIJ)V
*/
void Java_org_rocksdb_WriteBatch_delete__J_3BIJ(
JNIEnv* env, jobject jobj, jlong jwb_handle,
jbyteArray jkey, jint jkey_len, jlong jcf_handle) {
void Java_org_rocksdb_WriteBatch_delete__J_3BIJ(JNIEnv* env, jobject jobj,
jlong jwb_handle,
jbyteArray jkey, jint jkey_len,
jlong jcf_handle) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
auto* cf_handle = reinterpret_cast<rocksdb::ColumnFamilyHandle*>(jcf_handle);
assert(cf_handle != nullptr);
auto remove = [&wb, &cf_handle] (rocksdb::Slice key) {
auto remove = [&wb, &cf_handle](rocksdb::Slice key) {
return wb->Delete(cf_handle, key);
};
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::k_op(remove, env,
jobj, jkey, jkey_len);
std::unique_ptr<rocksdb::Status> status =
rocksdb::JniUtil::k_op(remove, env, jobj, jkey, jkey_len);
if (status != nullptr && !status->ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, status);
}
@ -278,16 +280,17 @@ void Java_org_rocksdb_WriteBatch_delete__J_3BIJ(
* Method: singleDelete
* Signature: (J[BI)V
*/
void Java_org_rocksdb_WriteBatch_singleDelete__J_3BI(
JNIEnv* env, jobject jobj, jlong jwb_handle, jbyteArray jkey,
void Java_org_rocksdb_WriteBatch_singleDelete__J_3BI(JNIEnv* env, jobject jobj,
jlong jwb_handle,
jbyteArray jkey,
jint jkey_len) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
auto single_delete = [&wb] (rocksdb::Slice key) {
auto single_delete = [&wb](rocksdb::Slice key) {
return wb->SingleDelete(key);
};
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::k_op(single_delete,
env, jobj, jkey, jkey_len);
std::unique_ptr<rocksdb::Status> status =
rocksdb::JniUtil::k_op(single_delete, env, jobj, jkey, jkey_len);
if (status != nullptr && !status->ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, status);
}
@ -298,18 +301,20 @@ void Java_org_rocksdb_WriteBatch_singleDelete__J_3BI(
* Method: singleDelete
* Signature: (J[BIJ)V
*/
void Java_org_rocksdb_WriteBatch_singleDelete__J_3BIJ(
JNIEnv* env, jobject jobj, jlong jwb_handle, jbyteArray jkey,
jint jkey_len, jlong jcf_handle) {
void Java_org_rocksdb_WriteBatch_singleDelete__J_3BIJ(JNIEnv* env, jobject jobj,
jlong jwb_handle,
jbyteArray jkey,
jint jkey_len,
jlong jcf_handle) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
auto* cf_handle = reinterpret_cast<rocksdb::ColumnFamilyHandle*>(jcf_handle);
assert(cf_handle != nullptr);
auto single_delete = [&wb, &cf_handle] (rocksdb::Slice key) {
auto single_delete = [&wb, &cf_handle](rocksdb::Slice key) {
return wb->SingleDelete(cf_handle, key);
};
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::k_op(single_delete,
env, jobj, jkey, jkey_len);
std::unique_ptr<rocksdb::Status> status =
rocksdb::JniUtil::k_op(single_delete, env, jobj, jkey, jkey_len);
if (status != nullptr && !status->ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, status);
}
@ -328,9 +333,9 @@ void Java_org_rocksdb_WriteBatch_deleteRange__J_3BI_3BI(
auto deleteRange = [&wb](rocksdb::Slice beginKey, rocksdb::Slice endKey) {
return wb->DeleteRange(beginKey, endKey);
};
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::kv_op(
deleteRange, env, jobj, jbegin_key, jbegin_key_len, jend_key,
jend_key_len);
std::unique_ptr<rocksdb::Status> status =
rocksdb::JniUtil::kv_op(deleteRange, env, jobj, jbegin_key,
jbegin_key_len, jend_key, jend_key_len);
if (status != nullptr && !status->ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, status);
}
@ -353,9 +358,9 @@ void Java_org_rocksdb_WriteBatch_deleteRange__J_3BI_3BIJ(
rocksdb::Slice endKey) {
return wb->DeleteRange(cf_handle, beginKey, endKey);
};
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::kv_op(
deleteRange, env, jobj, jbegin_key, jbegin_key_len, jend_key,
jend_key_len);
std::unique_ptr<rocksdb::Status> status =
rocksdb::JniUtil::kv_op(deleteRange, env, jobj, jbegin_key,
jbegin_key_len, jend_key, jend_key_len);
if (status != nullptr && !status->ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, status);
}
@ -366,16 +371,14 @@ void Java_org_rocksdb_WriteBatch_deleteRange__J_3BI_3BIJ(
* Method: putLogData
* Signature: (J[BI)V
*/
void Java_org_rocksdb_WriteBatch_putLogData(
JNIEnv* env, jobject jobj, jlong jwb_handle, jbyteArray jblob,
void Java_org_rocksdb_WriteBatch_putLogData(JNIEnv* env, jobject jobj,
jlong jwb_handle, jbyteArray jblob,
jint jblob_len) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
auto putLogData = [&wb] (rocksdb::Slice blob) {
return wb->PutLogData(blob);
};
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::k_op(putLogData,
env, jobj, jblob, jblob_len);
auto putLogData = [&wb](rocksdb::Slice blob) { return wb->PutLogData(blob); };
std::unique_ptr<rocksdb::Status> status =
rocksdb::JniUtil::k_op(putLogData, env, jobj, jblob, jblob_len);
if (status != nullptr && !status->ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, status);
}
@ -386,8 +389,9 @@ void Java_org_rocksdb_WriteBatch_putLogData(
* Method: iterate
* Signature: (JJ)V
*/
void Java_org_rocksdb_WriteBatch_iterate(
JNIEnv* env, jobject jobj, jlong jwb_handle, jlong handlerHandle) {
void Java_org_rocksdb_WriteBatch_iterate(JNIEnv* env, jobject /*jobj*/,
jlong jwb_handle,
jlong handlerHandle) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
@ -405,8 +409,8 @@ void Java_org_rocksdb_WriteBatch_iterate(
* Method: data
* Signature: (J)[B
*/
jbyteArray Java_org_rocksdb_WriteBatch_data(
JNIEnv* env, jobject jobj, jlong jwb_handle) {
jbyteArray Java_org_rocksdb_WriteBatch_data(JNIEnv* env, jobject /*jobj*/,
jlong jwb_handle) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
@ -419,8 +423,8 @@ jbyteArray Java_org_rocksdb_WriteBatch_data(
* Method: getDataSize
* Signature: (J)J
*/
jlong Java_org_rocksdb_WriteBatch_getDataSize(
JNIEnv* env, jobject jobj, jlong jwb_handle) {
jlong Java_org_rocksdb_WriteBatch_getDataSize(JNIEnv* /*env*/, jobject /*jobj*/,
jlong jwb_handle) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
@ -433,8 +437,8 @@ jlong Java_org_rocksdb_WriteBatch_getDataSize(
* Method: hasPut
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_WriteBatch_hasPut(
JNIEnv* env, jobject jobj, jlong jwb_handle) {
jboolean Java_org_rocksdb_WriteBatch_hasPut(JNIEnv* /*env*/, jobject /*jobj*/,
jlong jwb_handle) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
@ -446,8 +450,9 @@ jboolean Java_org_rocksdb_WriteBatch_hasPut(
* Method: hasDelete
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_WriteBatch_hasDelete(
JNIEnv* env, jobject jobj, jlong jwb_handle) {
jboolean Java_org_rocksdb_WriteBatch_hasDelete(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jwb_handle) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
@ -460,7 +465,7 @@ jboolean Java_org_rocksdb_WriteBatch_hasDelete(
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_org_rocksdb_WriteBatch_hasSingleDelete(
JNIEnv* env , jobject jobj, jlong jwb_handle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jwb_handle) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
@ -473,7 +478,7 @@ JNIEXPORT jboolean JNICALL Java_org_rocksdb_WriteBatch_hasSingleDelete(
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_org_rocksdb_WriteBatch_hasDeleteRange(
JNIEnv* env , jobject jobj, jlong jwb_handle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jwb_handle) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
@ -486,7 +491,7 @@ JNIEXPORT jboolean JNICALL Java_org_rocksdb_WriteBatch_hasDeleteRange(
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_org_rocksdb_WriteBatch_hasMerge(
JNIEnv* env , jobject jobj, jlong jwb_handle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jwb_handle) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
@ -499,7 +504,7 @@ JNIEXPORT jboolean JNICALL Java_org_rocksdb_WriteBatch_hasMerge(
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_org_rocksdb_WriteBatch_hasBeginPrepare(
JNIEnv* env , jobject jobj, jlong jwb_handle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jwb_handle) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
@ -512,7 +517,7 @@ JNIEXPORT jboolean JNICALL Java_org_rocksdb_WriteBatch_hasBeginPrepare(
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_org_rocksdb_WriteBatch_hasEndPrepare(
JNIEnv* env , jobject jobj, jlong jwb_handle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jwb_handle) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
@ -525,7 +530,7 @@ JNIEXPORT jboolean JNICALL Java_org_rocksdb_WriteBatch_hasEndPrepare(
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_org_rocksdb_WriteBatch_hasCommit(
JNIEnv* env , jobject jobj, jlong jwb_handle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jwb_handle) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
@ -538,7 +543,7 @@ JNIEXPORT jboolean JNICALL Java_org_rocksdb_WriteBatch_hasCommit(
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_org_rocksdb_WriteBatch_hasRollback(
JNIEnv* env , jobject jobj, jlong jwb_handle) {
JNIEnv* /*env*/, jobject /*jobj*/, jlong jwb_handle) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
@ -550,8 +555,9 @@ JNIEXPORT jboolean JNICALL Java_org_rocksdb_WriteBatch_hasRollback(
* Method: markWalTerminationPoint
* Signature: (J)V
*/
void Java_org_rocksdb_WriteBatch_markWalTerminationPoint(
JNIEnv* env, jobject jobj, jlong jwb_handle) {
void Java_org_rocksdb_WriteBatch_markWalTerminationPoint(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jwb_handle) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
@ -563,8 +569,9 @@ void Java_org_rocksdb_WriteBatch_markWalTerminationPoint(
* Method: getWalTerminationPoint
* Signature: (J)Lorg/rocksdb/WriteBatch/SavePoint;
*/
jobject Java_org_rocksdb_WriteBatch_getWalTerminationPoint(
JNIEnv* env, jobject jobj, jlong jwb_handle) {
jobject Java_org_rocksdb_WriteBatch_getWalTerminationPoint(JNIEnv* env,
jobject /*jobj*/,
jlong jwb_handle) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
@ -577,8 +584,9 @@ jobject Java_org_rocksdb_WriteBatch_getWalTerminationPoint(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_WriteBatch_disposeInternal(
JNIEnv* env, jobject jobj, jlong handle) {
void Java_org_rocksdb_WriteBatch_disposeInternal(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong handle) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(handle);
assert(wb != nullptr);
delete wb;
@ -589,8 +597,8 @@ void Java_org_rocksdb_WriteBatch_disposeInternal(
* Method: createNewHandler0
* Signature: ()J
*/
jlong Java_org_rocksdb_WriteBatch_00024Handler_createNewHandler0(
JNIEnv* env, jobject jobj) {
jlong Java_org_rocksdb_WriteBatch_00024Handler_createNewHandler0(JNIEnv* env,
jobject jobj) {
auto* wbjnic = new rocksdb::WriteBatchHandlerJniCallback(env, jobj);
return reinterpret_cast<jlong>(wbjnic);
}

@ -30,8 +30,9 @@
* Method: getContents
* Signature: (J)[B
*/
jbyteArray Java_org_rocksdb_WriteBatchTest_getContents(
JNIEnv* env, jclass jclazz, jlong jwb_handle) {
jbyteArray Java_org_rocksdb_WriteBatchTest_getContents(JNIEnv* env,
jclass /*jclazz*/,
jlong jwb_handle) {
auto* b = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(b != nullptr);
@ -55,8 +56,8 @@ jbyteArray Java_org_rocksdb_WriteBatchTest_getContents(
rocksdb::WriteBatchInternal::InsertInto(b, &cf_mems_default, nullptr);
int count = 0;
rocksdb::Arena arena;
rocksdb::ScopedArenaIterator iter(mem->NewIterator(
rocksdb::ReadOptions(), &arena));
rocksdb::ScopedArenaIterator iter(
mem->NewIterator(rocksdb::ReadOptions(), &arena));
for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
rocksdb::ParsedInternalKey ikey;
ikey.clear();
@ -130,14 +131,15 @@ jbyteArray Java_org_rocksdb_WriteBatchTest_getContents(
delete mem->Unref();
jbyteArray jstate = env->NewByteArray(static_cast<jsize>(state.size()));
if(jstate == nullptr) {
if (jstate == nullptr) {
// exception thrown: OutOfMemoryError
return nullptr;
}
env->SetByteArrayRegion(jstate, 0, static_cast<jsize>(state.size()),
env->SetByteArrayRegion(
jstate, 0, static_cast<jsize>(state.size()),
const_cast<jbyte*>(reinterpret_cast<const jbyte*>(state.c_str())));
if(env->ExceptionCheck()) {
if (env->ExceptionCheck()) {
// exception thrown: ArrayIndexOutOfBoundsException
env->DeleteLocalRef(jstate);
return nullptr;
@ -152,7 +154,7 @@ jbyteArray Java_org_rocksdb_WriteBatchTest_getContents(
* Signature: (JJ)V
*/
void Java_org_rocksdb_WriteBatchTestInternalHelper_setSequence(
JNIEnv* env, jclass jclazz, jlong jwb_handle, jlong jsn) {
JNIEnv* /*env*/, jclass /*jclazz*/, jlong jwb_handle, jlong jsn) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
@ -165,8 +167,9 @@ void Java_org_rocksdb_WriteBatchTestInternalHelper_setSequence(
* Method: sequence
* Signature: (J)J
*/
jlong Java_org_rocksdb_WriteBatchTestInternalHelper_sequence(
JNIEnv* env, jclass jclazz, jlong jwb_handle) {
jlong Java_org_rocksdb_WriteBatchTestInternalHelper_sequence(JNIEnv* /*env*/,
jclass /*jclazz*/,
jlong jwb_handle) {
auto* wb = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle);
assert(wb != nullptr);
@ -178,8 +181,10 @@ jlong Java_org_rocksdb_WriteBatchTestInternalHelper_sequence(
* Method: append
* Signature: (JJ)V
*/
void Java_org_rocksdb_WriteBatchTestInternalHelper_append(
JNIEnv* env, jclass jclazz, jlong jwb_handle_1, jlong jwb_handle_2) {
void Java_org_rocksdb_WriteBatchTestInternalHelper_append(JNIEnv* /*env*/,
jclass /*jclazz*/,
jlong jwb_handle_1,
jlong jwb_handle_2) {
auto* wb1 = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle_1);
assert(wb1 != nullptr);
auto* wb2 = reinterpret_cast<rocksdb::WriteBatch*>(jwb_handle_2);

@ -6,10 +6,10 @@
// This file implements the "bridge" between Java and C++ and enables
// calling c++ rocksdb::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 "rocksdb/utilities/write_batch_with_index.h"
#include "rocksjni/portal.h"
/*
@ -18,7 +18,7 @@
* Signature: ()J
*/
jlong Java_org_rocksdb_WriteBatchWithIndex_newWriteBatchWithIndex__(
JNIEnv* env, jclass jcls) {
JNIEnv* /*env*/, jclass /*jcls*/) {
auto* wbwi = new rocksdb::WriteBatchWithIndex();
return reinterpret_cast<jlong>(wbwi);
}
@ -29,10 +29,9 @@ jlong Java_org_rocksdb_WriteBatchWithIndex_newWriteBatchWithIndex__(
* Signature: (Z)J
*/
jlong Java_org_rocksdb_WriteBatchWithIndex_newWriteBatchWithIndex__Z(
JNIEnv* env, jclass jcls, jboolean joverwrite_key) {
auto* wbwi =
new rocksdb::WriteBatchWithIndex(rocksdb::BytewiseComparator(), 0,
static_cast<bool>(joverwrite_key));
JNIEnv* /*env*/, jclass /*jcls*/, jboolean joverwrite_key) {
auto* wbwi = new rocksdb::WriteBatchWithIndex(
rocksdb::BytewiseComparator(), 0, static_cast<bool>(joverwrite_key));
return reinterpret_cast<jlong>(wbwi);
}
@ -42,32 +41,32 @@ jlong Java_org_rocksdb_WriteBatchWithIndex_newWriteBatchWithIndex__Z(
* Signature: (JBIZ)J
*/
jlong Java_org_rocksdb_WriteBatchWithIndex_newWriteBatchWithIndex__JBIZ(
JNIEnv* env, jclass jcls, jlong jfallback_index_comparator_handle,
JNIEnv* /*env*/, jclass /*jcls*/, jlong jfallback_index_comparator_handle,
jbyte jcomparator_type, jint jreserved_bytes, jboolean joverwrite_key) {
rocksdb::Comparator *fallback_comparator = nullptr;
switch(jcomparator_type) {
rocksdb::Comparator* fallback_comparator = nullptr;
switch (jcomparator_type) {
// JAVA_COMPARATOR
case 0x0:
fallback_comparator =
reinterpret_cast<rocksdb::ComparatorJniCallback*>(jfallback_index_comparator_handle);
fallback_comparator = reinterpret_cast<rocksdb::ComparatorJniCallback*>(
jfallback_index_comparator_handle);
break;
// JAVA_DIRECT_COMPARATOR
case 0x1:
fallback_comparator =
reinterpret_cast<rocksdb::DirectComparatorJniCallback*>(jfallback_index_comparator_handle);
reinterpret_cast<rocksdb::DirectComparatorJniCallback*>(
jfallback_index_comparator_handle);
break;
// JAVA_NATIVE_COMPARATOR_WRAPPER
case 0x2:
fallback_comparator =
reinterpret_cast<rocksdb::Comparator*>(jfallback_index_comparator_handle);
fallback_comparator = reinterpret_cast<rocksdb::Comparator*>(
jfallback_index_comparator_handle);
break;
}
auto* wbwi =
new rocksdb::WriteBatchWithIndex(
fallback_comparator,
static_cast<size_t>(jreserved_bytes), static_cast<bool>(joverwrite_key));
auto* wbwi = new rocksdb::WriteBatchWithIndex(
fallback_comparator, static_cast<size_t>(jreserved_bytes),
static_cast<bool>(joverwrite_key));
return reinterpret_cast<jlong>(wbwi);
}
@ -76,8 +75,9 @@ jlong Java_org_rocksdb_WriteBatchWithIndex_newWriteBatchWithIndex__JBIZ(
* Method: count0
* Signature: (J)I
*/
jint Java_org_rocksdb_WriteBatchWithIndex_count0(
JNIEnv* env, jobject jobj, jlong jwbwi_handle) {
jint Java_org_rocksdb_WriteBatchWithIndex_count0(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jwbwi_handle) {
auto* wbwi = reinterpret_cast<rocksdb::WriteBatchWithIndex*>(jwbwi_handle);
assert(wbwi != nullptr);
@ -94,11 +94,11 @@ void Java_org_rocksdb_WriteBatchWithIndex_put__J_3BI_3BI(
jint jkey_len, jbyteArray jentry_value, jint jentry_value_len) {
auto* wbwi = reinterpret_cast<rocksdb::WriteBatchWithIndex*>(jwbwi_handle);
assert(wbwi != nullptr);
auto put = [&wbwi] (rocksdb::Slice key, rocksdb::Slice value) {
auto put = [&wbwi](rocksdb::Slice key, rocksdb::Slice value) {
return wbwi->Put(key, value);
};
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::kv_op(put, env,
jobj, jkey, jkey_len, jentry_value, jentry_value_len);
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::kv_op(
put, env, jobj, jkey, jkey_len, jentry_value, jentry_value_len);
if (status != nullptr && !status->ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, status);
}
@ -117,11 +117,11 @@ void Java_org_rocksdb_WriteBatchWithIndex_put__J_3BI_3BIJ(
assert(wbwi != nullptr);
auto* cf_handle = reinterpret_cast<rocksdb::ColumnFamilyHandle*>(jcf_handle);
assert(cf_handle != nullptr);
auto put = [&wbwi, &cf_handle] (rocksdb::Slice key, rocksdb::Slice value) {
auto put = [&wbwi, &cf_handle](rocksdb::Slice key, rocksdb::Slice value) {
return wbwi->Put(cf_handle, key, value);
};
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::kv_op(put, env,
jobj, jkey, jkey_len, jentry_value, jentry_value_len);
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::kv_op(
put, env, jobj, jkey, jkey_len, jentry_value, jentry_value_len);
if (status != nullptr && !status->ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, status);
}
@ -137,11 +137,11 @@ void Java_org_rocksdb_WriteBatchWithIndex_merge__J_3BI_3BI(
jint jkey_len, jbyteArray jentry_value, jint jentry_value_len) {
auto* wbwi = reinterpret_cast<rocksdb::WriteBatchWithIndex*>(jwbwi_handle);
assert(wbwi != nullptr);
auto merge = [&wbwi] (rocksdb::Slice key, rocksdb::Slice value) {
auto merge = [&wbwi](rocksdb::Slice key, rocksdb::Slice value) {
return wbwi->Merge(key, value);
};
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::kv_op(merge, env,
jobj, jkey, jkey_len, jentry_value, jentry_value_len);
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::kv_op(
merge, env, jobj, jkey, jkey_len, jentry_value, jentry_value_len);
if (status != nullptr && !status->ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, status);
}
@ -160,11 +160,11 @@ void Java_org_rocksdb_WriteBatchWithIndex_merge__J_3BI_3BIJ(
assert(wbwi != nullptr);
auto* cf_handle = reinterpret_cast<rocksdb::ColumnFamilyHandle*>(jcf_handle);
assert(cf_handle != nullptr);
auto merge = [&wbwi, &cf_handle] (rocksdb::Slice key, rocksdb::Slice value) {
auto merge = [&wbwi, &cf_handle](rocksdb::Slice key, rocksdb::Slice value) {
return wbwi->Merge(cf_handle, key, value);
};
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::kv_op(merge, env,
jobj, jkey, jkey_len, jentry_value, jentry_value_len);
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::kv_op(
merge, env, jobj, jkey, jkey_len, jentry_value, jentry_value_len);
if (status != nullptr && !status->ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, status);
}
@ -175,16 +175,16 @@ void Java_org_rocksdb_WriteBatchWithIndex_merge__J_3BI_3BIJ(
* Method: delete
* Signature: (J[BI)V
*/
void Java_org_rocksdb_WriteBatchWithIndex_delete__J_3BI(
JNIEnv* env, jobject jobj, jlong jwbwi_handle, jbyteArray jkey,
void Java_org_rocksdb_WriteBatchWithIndex_delete__J_3BI(JNIEnv* env,
jobject jobj,
jlong jwbwi_handle,
jbyteArray jkey,
jint jkey_len) {
auto* wbwi = reinterpret_cast<rocksdb::WriteBatchWithIndex*>(jwbwi_handle);
assert(wbwi != nullptr);
auto remove = [&wbwi] (rocksdb::Slice key) {
return wbwi->Delete(key);
};
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::k_op(remove, env,
jobj, jkey, jkey_len);
auto remove = [&wbwi](rocksdb::Slice key) { return wbwi->Delete(key); };
std::unique_ptr<rocksdb::Status> status =
rocksdb::JniUtil::k_op(remove, env, jobj, jkey, jkey_len);
if (status != nullptr && !status->ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, status);
}
@ -202,11 +202,11 @@ void Java_org_rocksdb_WriteBatchWithIndex_delete__J_3BIJ(
assert(wbwi != nullptr);
auto* cf_handle = reinterpret_cast<rocksdb::ColumnFamilyHandle*>(jcf_handle);
assert(cf_handle != nullptr);
auto remove = [&wbwi, &cf_handle] (rocksdb::Slice key) {
auto remove = [&wbwi, &cf_handle](rocksdb::Slice key) {
return wbwi->Delete(cf_handle, key);
};
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::k_op(remove, env,
jobj, jkey, jkey_len);
std::unique_ptr<rocksdb::Status> status =
rocksdb::JniUtil::k_op(remove, env, jobj, jkey, jkey_len);
if (status != nullptr && !status->ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, status);
}
@ -222,11 +222,11 @@ void Java_org_rocksdb_WriteBatchWithIndex_singleDelete__J_3BI(
jint jkey_len) {
auto* wbwi = reinterpret_cast<rocksdb::WriteBatchWithIndex*>(jwbwi_handle);
assert(wbwi != nullptr);
auto single_delete = [&wbwi] (rocksdb::Slice key) {
auto single_delete = [&wbwi](rocksdb::Slice key) {
return wbwi->SingleDelete(key);
};
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::k_op(single_delete,
env, jobj, jkey, jkey_len);
std::unique_ptr<rocksdb::Status> status =
rocksdb::JniUtil::k_op(single_delete, env, jobj, jkey, jkey_len);
if (status != nullptr && !status->ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, status);
}
@ -244,11 +244,11 @@ void Java_org_rocksdb_WriteBatchWithIndex_singleDelete__J_3BIJ(
assert(wbwi != nullptr);
auto* cf_handle = reinterpret_cast<rocksdb::ColumnFamilyHandle*>(jcf_handle);
assert(cf_handle != nullptr);
auto single_delete = [&wbwi, &cf_handle] (rocksdb::Slice key) {
auto single_delete = [&wbwi, &cf_handle](rocksdb::Slice key) {
return wbwi->SingleDelete(cf_handle, key);
};
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::k_op(single_delete,
env, jobj, jkey, jkey_len);
std::unique_ptr<rocksdb::Status> status =
rocksdb::JniUtil::k_op(single_delete, env, jobj, jkey, jkey_len);
if (status != nullptr && !status->ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, status);
}
@ -267,9 +267,9 @@ void Java_org_rocksdb_WriteBatchWithIndex_deleteRange__J_3BI_3BI(
auto deleteRange = [&wbwi](rocksdb::Slice beginKey, rocksdb::Slice endKey) {
return wbwi->DeleteRange(beginKey, endKey);
};
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::kv_op(
deleteRange, env, jobj, jbegin_key, jbegin_key_len, jend_key,
jend_key_len);
std::unique_ptr<rocksdb::Status> status =
rocksdb::JniUtil::kv_op(deleteRange, env, jobj, jbegin_key,
jbegin_key_len, jend_key, jend_key_len);
if (status != nullptr && !status->ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, status);
}
@ -292,9 +292,9 @@ void Java_org_rocksdb_WriteBatchWithIndex_deleteRange__J_3BI_3BIJ(
rocksdb::Slice endKey) {
return wbwi->DeleteRange(cf_handle, beginKey, endKey);
};
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::kv_op(
deleteRange, env, jobj, jbegin_key, jbegin_key_len, jend_key,
jend_key_len);
std::unique_ptr<rocksdb::Status> status =
rocksdb::JniUtil::kv_op(deleteRange, env, jobj, jbegin_key,
jbegin_key_len, jend_key, jend_key_len);
if (status != nullptr && !status->ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, status);
}
@ -305,16 +305,17 @@ void Java_org_rocksdb_WriteBatchWithIndex_deleteRange__J_3BI_3BIJ(
* Method: putLogData
* Signature: (J[BI)V
*/
void Java_org_rocksdb_WriteBatchWithIndex_putLogData(
JNIEnv* env, jobject jobj, jlong jwbwi_handle, jbyteArray jblob,
void Java_org_rocksdb_WriteBatchWithIndex_putLogData(JNIEnv* env, jobject jobj,
jlong jwbwi_handle,
jbyteArray jblob,
jint jblob_len) {
auto* wbwi = reinterpret_cast<rocksdb::WriteBatchWithIndex*>(jwbwi_handle);
assert(wbwi != nullptr);
auto putLogData = [&wbwi] (rocksdb::Slice blob) {
auto putLogData = [&wbwi](rocksdb::Slice blob) {
return wbwi->PutLogData(blob);
};
std::unique_ptr<rocksdb::Status> status = rocksdb::JniUtil::k_op(putLogData,
env, jobj, jblob, jblob_len);
std::unique_ptr<rocksdb::Status> status =
rocksdb::JniUtil::k_op(putLogData, env, jobj, jblob, jblob_len);
if (status != nullptr && !status->ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, status);
}
@ -325,8 +326,9 @@ void Java_org_rocksdb_WriteBatchWithIndex_putLogData(
* Method: clear
* Signature: (J)V
*/
void Java_org_rocksdb_WriteBatchWithIndex_clear0(
JNIEnv* env, jobject jobj, jlong jwbwi_handle) {
void Java_org_rocksdb_WriteBatchWithIndex_clear0(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jwbwi_handle) {
auto* wbwi = reinterpret_cast<rocksdb::WriteBatchWithIndex*>(jwbwi_handle);
assert(wbwi != nullptr);
@ -338,8 +340,9 @@ void Java_org_rocksdb_WriteBatchWithIndex_clear0(
* Method: setSavePoint0
* Signature: (J)V
*/
void Java_org_rocksdb_WriteBatchWithIndex_setSavePoint0(
JNIEnv* env, jobject jobj, jlong jwbwi_handle) {
void Java_org_rocksdb_WriteBatchWithIndex_setSavePoint0(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jwbwi_handle) {
auto* wbwi = reinterpret_cast<rocksdb::WriteBatchWithIndex*>(jwbwi_handle);
assert(wbwi != nullptr);
@ -352,7 +355,7 @@ void Java_org_rocksdb_WriteBatchWithIndex_setSavePoint0(
* Signature: (J)V
*/
void Java_org_rocksdb_WriteBatchWithIndex_rollbackToSavePoint0(
JNIEnv* env, jobject jobj, jlong jwbwi_handle) {
JNIEnv* env, jobject /*jobj*/, jlong jwbwi_handle) {
auto* wbwi = reinterpret_cast<rocksdb::WriteBatchWithIndex*>(jwbwi_handle);
assert(wbwi != nullptr);
@ -370,8 +373,9 @@ void Java_org_rocksdb_WriteBatchWithIndex_rollbackToSavePoint0(
* Method: popSavePoint
* Signature: (J)V
*/
void Java_org_rocksdb_WriteBatchWithIndex_popSavePoint(
JNIEnv* env, jobject jobj, jlong jwbwi_handle) {
void Java_org_rocksdb_WriteBatchWithIndex_popSavePoint(JNIEnv* env,
jobject /*jobj*/,
jlong jwbwi_handle) {
auto* wbwi = reinterpret_cast<rocksdb::WriteBatchWithIndex*>(jwbwi_handle);
assert(wbwi != nullptr);
@ -389,8 +393,10 @@ void Java_org_rocksdb_WriteBatchWithIndex_popSavePoint(
* Method: setMaxBytes
* Signature: (JJ)V
*/
void Java_org_rocksdb_WriteBatchWithIndex_setMaxBytes(
JNIEnv* env, jobject jobj, jlong jwbwi_handle, jlong jmax_bytes) {
void Java_org_rocksdb_WriteBatchWithIndex_setMaxBytes(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jwbwi_handle,
jlong jmax_bytes) {
auto* wbwi = reinterpret_cast<rocksdb::WriteBatchWithIndex*>(jwbwi_handle);
assert(wbwi != nullptr);
@ -402,8 +408,9 @@ void Java_org_rocksdb_WriteBatchWithIndex_setMaxBytes(
* Method: getWriteBatch
* Signature: (J)Lorg/rocksdb/WriteBatch;
*/
jobject Java_org_rocksdb_WriteBatchWithIndex_getWriteBatch(
JNIEnv* env, jobject jobj, jlong jwbwi_handle) {
jobject Java_org_rocksdb_WriteBatchWithIndex_getWriteBatch(JNIEnv* env,
jobject /*jobj*/,
jlong jwbwi_handle) {
auto* wbwi = reinterpret_cast<rocksdb::WriteBatchWithIndex*>(jwbwi_handle);
assert(wbwi != nullptr);
@ -418,8 +425,9 @@ jobject Java_org_rocksdb_WriteBatchWithIndex_getWriteBatch(
* Method: iterator0
* Signature: (J)J
*/
jlong Java_org_rocksdb_WriteBatchWithIndex_iterator0(
JNIEnv* env, jobject jobj, jlong jwbwi_handle) {
jlong Java_org_rocksdb_WriteBatchWithIndex_iterator0(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jwbwi_handle) {
auto* wbwi = reinterpret_cast<rocksdb::WriteBatchWithIndex*>(jwbwi_handle);
auto* wbwi_iterator = wbwi->NewIterator();
return reinterpret_cast<jlong>(wbwi_iterator);
@ -430,8 +438,10 @@ jlong Java_org_rocksdb_WriteBatchWithIndex_iterator0(
* Method: iterator1
* Signature: (JJ)J
*/
jlong Java_org_rocksdb_WriteBatchWithIndex_iterator1(
JNIEnv* env, jobject jobj, jlong jwbwi_handle, jlong jcf_handle) {
jlong Java_org_rocksdb_WriteBatchWithIndex_iterator1(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jwbwi_handle,
jlong jcf_handle) {
auto* wbwi = reinterpret_cast<rocksdb::WriteBatchWithIndex*>(jwbwi_handle);
auto* cf_handle = reinterpret_cast<rocksdb::ColumnFamilyHandle*>(jcf_handle);
auto* wbwi_iterator = wbwi->NewIterator(cf_handle);
@ -443,8 +453,10 @@ jlong Java_org_rocksdb_WriteBatchWithIndex_iterator1(
* Method: iteratorWithBase
* Signature: (JJJ)J
*/
jlong Java_org_rocksdb_WriteBatchWithIndex_iteratorWithBase(
JNIEnv* env, jobject jobj, jlong jwbwi_handle, jlong jcf_handle,
jlong Java_org_rocksdb_WriteBatchWithIndex_iteratorWithBase(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jwbwi_handle,
jlong jcf_handle,
jlong jbi_handle) {
auto* wbwi = reinterpret_cast<rocksdb::WriteBatchWithIndex*>(jwbwi_handle);
auto* cf_handle = reinterpret_cast<rocksdb::ColumnFamilyHandle*>(jcf_handle);
@ -459,7 +471,7 @@ jlong Java_org_rocksdb_WriteBatchWithIndex_iteratorWithBase(
* Signature: (JJ[BI)[B
*/
jbyteArray JNICALL Java_org_rocksdb_WriteBatchWithIndex_getFromBatch__JJ_3BI(
JNIEnv* env, jobject jobj, jlong jwbwi_handle, jlong jdbopt_handle,
JNIEnv* env, jobject /*jobj*/, jlong jwbwi_handle, jlong jdbopt_handle,
jbyteArray jkey, jint jkey_len) {
auto* wbwi = reinterpret_cast<rocksdb::WriteBatchWithIndex*>(jwbwi_handle);
auto* dbopt = reinterpret_cast<rocksdb::DBOptions*>(jdbopt_handle);
@ -477,14 +489,13 @@ jbyteArray JNICALL Java_org_rocksdb_WriteBatchWithIndex_getFromBatch__JJ_3BI(
* Signature: (JJ[BIJ)[B
*/
jbyteArray Java_org_rocksdb_WriteBatchWithIndex_getFromBatch__JJ_3BIJ(
JNIEnv* env, jobject jobj, jlong jwbwi_handle, jlong jdbopt_handle,
JNIEnv* env, jobject /*jobj*/, jlong jwbwi_handle, jlong jdbopt_handle,
jbyteArray jkey, jint jkey_len, jlong jcf_handle) {
auto* wbwi = reinterpret_cast<rocksdb::WriteBatchWithIndex*>(jwbwi_handle);
auto* dbopt = reinterpret_cast<rocksdb::DBOptions*>(jdbopt_handle);
auto* cf_handle = reinterpret_cast<rocksdb::ColumnFamilyHandle*>(jcf_handle);
auto getter =
[&wbwi, &cf_handle, &dbopt](const rocksdb::Slice& key,
auto getter = [&wbwi, &cf_handle, &dbopt](const rocksdb::Slice& key,
std::string* value) {
return wbwi->GetFromBatch(cf_handle, *dbopt, key, value);
};
@ -498,14 +509,14 @@ jbyteArray Java_org_rocksdb_WriteBatchWithIndex_getFromBatch__JJ_3BIJ(
* Signature: (JJJ[BI)[B
*/
jbyteArray Java_org_rocksdb_WriteBatchWithIndex_getFromBatchAndDB__JJJ_3BI(
JNIEnv* env, jobject jobj, jlong jwbwi_handle, jlong jdb_handle,
JNIEnv* env, jobject /*jobj*/, jlong jwbwi_handle, jlong jdb_handle,
jlong jreadopt_handle, jbyteArray jkey, jint jkey_len) {
auto* wbwi = reinterpret_cast<rocksdb::WriteBatchWithIndex*>(jwbwi_handle);
auto* db = reinterpret_cast<rocksdb::DB*>(jdb_handle);
auto* readopt = reinterpret_cast<rocksdb::ReadOptions*>(jreadopt_handle);
auto getter =
[&wbwi, &db, &readopt](const rocksdb::Slice& key, std::string* value) {
auto getter = [&wbwi, &db, &readopt](const rocksdb::Slice& key,
std::string* value) {
return wbwi->GetFromBatchAndDB(db, *readopt, key, value);
};
@ -518,15 +529,14 @@ jbyteArray Java_org_rocksdb_WriteBatchWithIndex_getFromBatchAndDB__JJJ_3BI(
* Signature: (JJJ[BIJ)[B
*/
jbyteArray Java_org_rocksdb_WriteBatchWithIndex_getFromBatchAndDB__JJJ_3BIJ(
JNIEnv* env, jobject jobj, jlong jwbwi_handle, jlong jdb_handle,
JNIEnv* env, jobject /*jobj*/, jlong jwbwi_handle, jlong jdb_handle,
jlong jreadopt_handle, jbyteArray jkey, jint jkey_len, jlong jcf_handle) {
auto* wbwi = reinterpret_cast<rocksdb::WriteBatchWithIndex*>(jwbwi_handle);
auto* db = reinterpret_cast<rocksdb::DB*>(jdb_handle);
auto* readopt = reinterpret_cast<rocksdb::ReadOptions*>(jreadopt_handle);
auto* cf_handle = reinterpret_cast<rocksdb::ColumnFamilyHandle*>(jcf_handle);
auto getter =
[&wbwi, &db, &cf_handle, &readopt](const rocksdb::Slice& key,
auto getter = [&wbwi, &db, &cf_handle, &readopt](const rocksdb::Slice& key,
std::string* value) {
return wbwi->GetFromBatchAndDB(db, *readopt, cf_handle, key, value);
};
@ -539,8 +549,9 @@ jbyteArray Java_org_rocksdb_WriteBatchWithIndex_getFromBatchAndDB__JJJ_3BIJ(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_WriteBatchWithIndex_disposeInternal(
JNIEnv* env, jobject jobj, jlong handle) {
void Java_org_rocksdb_WriteBatchWithIndex_disposeInternal(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong handle) {
auto* wbwi = reinterpret_cast<rocksdb::WriteBatchWithIndex*>(handle);
assert(wbwi != nullptr);
delete wbwi;
@ -553,8 +564,9 @@ void Java_org_rocksdb_WriteBatchWithIndex_disposeInternal(
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_WBWIRocksIterator_disposeInternal(
JNIEnv* env, jobject jobj, jlong handle) {
void Java_org_rocksdb_WBWIRocksIterator_disposeInternal(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong handle) {
auto* it = reinterpret_cast<rocksdb::WBWIIterator*>(handle);
assert(it != nullptr);
delete it;
@ -565,8 +577,9 @@ void Java_org_rocksdb_WBWIRocksIterator_disposeInternal(
* Method: isValid0
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_WBWIRocksIterator_isValid0(
JNIEnv* env, jobject jobj, jlong handle) {
jboolean Java_org_rocksdb_WBWIRocksIterator_isValid0(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong handle) {
return reinterpret_cast<rocksdb::WBWIIterator*>(handle)->Valid();
}
@ -575,8 +588,9 @@ jboolean Java_org_rocksdb_WBWIRocksIterator_isValid0(
* Method: seekToFirst0
* Signature: (J)V
*/
void Java_org_rocksdb_WBWIRocksIterator_seekToFirst0(
JNIEnv* env, jobject jobj, jlong handle) {
void Java_org_rocksdb_WBWIRocksIterator_seekToFirst0(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong handle) {
reinterpret_cast<rocksdb::WBWIIterator*>(handle)->SeekToFirst();
}
@ -585,8 +599,9 @@ void Java_org_rocksdb_WBWIRocksIterator_seekToFirst0(
* Method: seekToLast0
* Signature: (J)V
*/
void Java_org_rocksdb_WBWIRocksIterator_seekToLast0(
JNIEnv* env, jobject jobj, jlong handle) {
void Java_org_rocksdb_WBWIRocksIterator_seekToLast0(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong handle) {
reinterpret_cast<rocksdb::WBWIIterator*>(handle)->SeekToLast();
}
@ -595,8 +610,8 @@ void Java_org_rocksdb_WBWIRocksIterator_seekToLast0(
* Method: next0
* Signature: (J)V
*/
void Java_org_rocksdb_WBWIRocksIterator_next0(
JNIEnv* env, jobject jobj, jlong handle) {
void Java_org_rocksdb_WBWIRocksIterator_next0(JNIEnv* /*env*/, jobject /*jobj*/,
jlong handle) {
reinterpret_cast<rocksdb::WBWIIterator*>(handle)->Next();
}
@ -605,8 +620,8 @@ void Java_org_rocksdb_WBWIRocksIterator_next0(
* Method: prev0
* Signature: (J)V
*/
void Java_org_rocksdb_WBWIRocksIterator_prev0(
JNIEnv* env, jobject jobj, jlong handle) {
void Java_org_rocksdb_WBWIRocksIterator_prev0(JNIEnv* /*env*/, jobject /*jobj*/,
jlong handle) {
reinterpret_cast<rocksdb::WBWIIterator*>(handle)->Prev();
}
@ -615,18 +630,17 @@ void Java_org_rocksdb_WBWIRocksIterator_prev0(
* Method: seek0
* Signature: (J[BI)V
*/
void Java_org_rocksdb_WBWIRocksIterator_seek0(
JNIEnv* env, jobject jobj, jlong handle, jbyteArray jtarget,
void Java_org_rocksdb_WBWIRocksIterator_seek0(JNIEnv* env, jobject /*jobj*/,
jlong handle, jbyteArray jtarget,
jint jtarget_len) {
auto* it = reinterpret_cast<rocksdb::WBWIIterator*>(handle);
jbyte* target = env->GetByteArrayElements(jtarget, nullptr);
if(target == nullptr) {
if (target == nullptr) {
// exception thrown: OutOfMemoryError
return;
}
rocksdb::Slice target_slice(
reinterpret_cast<char*>(target), jtarget_len);
rocksdb::Slice target_slice(reinterpret_cast<char*>(target), jtarget_len);
it->Seek(target_slice);
@ -638,18 +652,19 @@ void Java_org_rocksdb_WBWIRocksIterator_seek0(
* Method: seekForPrev0
* Signature: (J[BI)V
*/
void Java_org_rocksdb_WBWIRocksIterator_seekForPrev0(
JNIEnv* env, jobject jobj, jlong handle, jbyteArray jtarget,
void Java_org_rocksdb_WBWIRocksIterator_seekForPrev0(JNIEnv* env,
jobject /*jobj*/,
jlong handle,
jbyteArray jtarget,
jint jtarget_len) {
auto* it = reinterpret_cast<rocksdb::WBWIIterator*>(handle);
jbyte* target = env->GetByteArrayElements(jtarget, nullptr);
if(target == nullptr) {
if (target == nullptr) {
// exception thrown: OutOfMemoryError
return;
}
rocksdb::Slice target_slice(
reinterpret_cast<char*>(target), jtarget_len);
rocksdb::Slice target_slice(reinterpret_cast<char*>(target), jtarget_len);
it->SeekForPrev(target_slice);
@ -661,8 +676,8 @@ void Java_org_rocksdb_WBWIRocksIterator_seekForPrev0(
* Method: status0
* Signature: (J)V
*/
void Java_org_rocksdb_WBWIRocksIterator_status0(
JNIEnv* env, jobject jobj, jlong handle) {
void Java_org_rocksdb_WBWIRocksIterator_status0(JNIEnv* env, jobject /*jobj*/,
jlong handle) {
auto* it = reinterpret_cast<rocksdb::WBWIIterator*>(handle);
rocksdb::Status s = it->status();
@ -678,8 +693,9 @@ void Java_org_rocksdb_WBWIRocksIterator_status0(
* Method: entry1
* Signature: (J)[J
*/
jlongArray Java_org_rocksdb_WBWIRocksIterator_entry1(
JNIEnv* env, jobject jobj, jlong handle) {
jlongArray Java_org_rocksdb_WBWIRocksIterator_entry1(JNIEnv* env,
jobject /*jobj*/,
jlong handle) {
auto* it = reinterpret_cast<rocksdb::WBWIIterator*>(handle);
const rocksdb::WriteEntry& we = it->Entry();
@ -688,13 +704,14 @@ jlongArray Java_org_rocksdb_WBWIRocksIterator_entry1(
// set the type of the write entry
results[0] = rocksdb::WriteTypeJni::toJavaWriteType(we.type);
// NOTE: key_slice and value_slice will be freed by org.rocksdb.DirectSlice#close
// NOTE: key_slice and value_slice will be freed by
// org.rocksdb.DirectSlice#close
auto* key_slice = new rocksdb::Slice(we.key.data(), we.key.size());
results[1] = reinterpret_cast<jlong>(key_slice);
if (we.type == rocksdb::kDeleteRecord
|| we.type == rocksdb::kSingleDeleteRecord
|| we.type == rocksdb::kLogDataRecord) {
if (we.type == rocksdb::kDeleteRecord ||
we.type == rocksdb::kSingleDeleteRecord ||
we.type == rocksdb::kLogDataRecord) {
// set native handle of value slice to null if no value available
results[2] = 0;
} else {
@ -703,9 +720,9 @@ jlongArray Java_org_rocksdb_WBWIRocksIterator_entry1(
}
jlongArray jresults = env->NewLongArray(3);
if(jresults == nullptr) {
if (jresults == nullptr) {
// exception thrown: OutOfMemoryError
if(results[2] != 0) {
if (results[2] != 0) {
auto* value_slice = reinterpret_cast<rocksdb::Slice*>(results[2]);
delete value_slice;
}
@ -714,10 +731,10 @@ jlongArray Java_org_rocksdb_WBWIRocksIterator_entry1(
}
env->SetLongArrayRegion(jresults, 0, 3, results);
if(env->ExceptionCheck()) {
if (env->ExceptionCheck()) {
// exception thrown: ArrayIndexOutOfBoundsException
env->DeleteLocalRef(jresults);
if(results[2] != 0) {
if (results[2] != 0) {
auto* value_slice = reinterpret_cast<rocksdb::Slice*>(results[2]);
delete value_slice;
}

@ -479,8 +479,8 @@ class FillBenchmark : public Benchmark {
num_write_ops_per_thread_ = FLAGS_num_operations;
}
void RunThreads(std::vector<port::Thread>* threads, uint64_t* bytes_written,
uint64_t* bytes_read, bool write,
void RunThreads(std::vector<port::Thread>* /*threads*/, uint64_t* bytes_written,
uint64_t* bytes_read, bool /*write*/,
uint64_t* read_hits) override {
FillBenchmarkThread(table_, key_gen_, bytes_written, bytes_read, sequence_,
num_write_ops_per_thread_, read_hits)();
@ -496,7 +496,7 @@ class ReadBenchmark : public Benchmark {
}
void RunThreads(std::vector<port::Thread>* threads, uint64_t* bytes_written,
uint64_t* bytes_read, bool write,
uint64_t* bytes_read, bool /*write*/,
uint64_t* read_hits) override {
for (int i = 0; i < FLAGS_num_threads; ++i) {
threads->emplace_back(
@ -520,7 +520,7 @@ class SeqReadBenchmark : public Benchmark {
}
void RunThreads(std::vector<port::Thread>* threads, uint64_t* bytes_written,
uint64_t* bytes_read, bool write,
uint64_t* bytes_read, bool /*write*/,
uint64_t* read_hits) override {
for (int i = 0; i < FLAGS_num_threads; ++i) {
threads->emplace_back(SeqReadBenchmarkThread(
@ -547,7 +547,7 @@ class ReadWriteBenchmark : public Benchmark {
}
void RunThreads(std::vector<port::Thread>* threads, uint64_t* bytes_written,
uint64_t* bytes_read, bool write,
uint64_t* bytes_read, bool /*write*/,
uint64_t* read_hits) override {
std::atomic_int threads_done;
threads_done.store(0);

@ -60,6 +60,8 @@ WriteBufferManager::WriteBufferManager(size_t _buffer_size,
// Construct the cache key using the pointer to this.
cache_rep_.reset(new CacheRep(cache));
}
#else
(void)cache;
#endif // ROCKSDB_LITE
}
@ -92,6 +94,8 @@ void WriteBufferManager::ReserveMemWithCache(size_t mem) {
cache_rep_->dummy_handles_.push_back(handle);
cache_rep_->cache_allocated_size_ += kSizeDummyEntry;
}
#else
(void)mem;
#endif // ROCKSDB_LITE
}
@ -119,6 +123,8 @@ void WriteBufferManager::FreeMemWithCache(size_t mem) {
cache_rep_->dummy_handles_.pop_back();
cache_rep_->cache_allocated_size_ -= kSizeDummyEntry;
}
#else
(void)mem;
#endif // ROCKSDB_LITE
}
} // namespace rocksdb

@ -84,10 +84,8 @@ const std::string& ThreadStatus::GetOperationPropertyName(
}
}
std::map<std::string, uint64_t>
ThreadStatus::InterpretOperationProperties(
ThreadStatus::OperationType op_type,
const uint64_t* op_properties) {
std::map<std::string, uint64_t> ThreadStatus::InterpretOperationProperties(
ThreadStatus::OperationType op_type, const uint64_t* op_properties) {
int num_properties;
switch (op_type) {
case OP_COMPACTION:
@ -102,20 +100,14 @@ std::map<std::string, uint64_t>
std::map<std::string, uint64_t> property_map;
for (int i = 0; i < num_properties; ++i) {
if (op_type == OP_COMPACTION &&
i == COMPACTION_INPUT_OUTPUT_LEVEL) {
property_map.insert(
{"BaseInputLevel", op_properties[i] >> 32});
if (op_type == OP_COMPACTION && i == COMPACTION_INPUT_OUTPUT_LEVEL) {
property_map.insert({"BaseInputLevel", op_properties[i] >> 32});
property_map.insert(
{"OutputLevel", op_properties[i] % (uint64_t(1) << 32U)});
} else if (op_type == OP_COMPACTION &&
i == COMPACTION_PROP_FLAGS) {
property_map.insert(
{"IsManual", ((op_properties[i] & 2) >> 1)});
property_map.insert(
{"IsDeletion", ((op_properties[i] & 4) >> 2)});
property_map.insert(
{"IsTrivialMove", ((op_properties[i] & 8) >> 3)});
} else if (op_type == OP_COMPACTION && i == COMPACTION_PROP_FLAGS) {
property_map.insert({"IsManual", ((op_properties[i] & 2) >> 1)});
property_map.insert({"IsDeletion", ((op_properties[i] & 4) >> 2)});
property_map.insert({"IsTrivialMove", ((op_properties[i] & 8) >> 3)});
} else {
property_map.insert(
{GetOperationPropertyName(op_type, i), op_properties[i]});
@ -124,49 +116,46 @@ std::map<std::string, uint64_t>
return property_map;
}
#else
std::string ThreadStatus::GetThreadTypeName(
ThreadStatus::ThreadType thread_type) {
ThreadStatus::ThreadType /*thread_type*/) {
static std::string dummy_str = "";
return dummy_str;
}
const std::string& ThreadStatus::GetOperationName(
ThreadStatus::OperationType op_type) {
ThreadStatus::OperationType /*op_type*/) {
static std::string dummy_str = "";
return dummy_str;
}
const std::string& ThreadStatus::GetOperationStageName(
ThreadStatus::OperationStage stage) {
ThreadStatus::OperationStage /*stage*/) {
static std::string dummy_str = "";
return dummy_str;
}
const std::string& ThreadStatus::GetStateName(
ThreadStatus::StateType state_type) {
ThreadStatus::StateType /*state_type*/) {
static std::string dummy_str = "";
return dummy_str;
}
const std::string ThreadStatus::MicrosToString(
uint64_t op_elapsed_time) {
const std::string ThreadStatus::MicrosToString(uint64_t /*op_elapsed_time*/) {
static std::string dummy_str = "";
return dummy_str;
}
const std::string& ThreadStatus::GetOperationPropertyName(
ThreadStatus::OperationType op_type, int i) {
ThreadStatus::OperationType /*op_type*/, int /*i*/) {
static std::string dummy_str = "";
return dummy_str;
}
std::map<std::string, uint64_t>
ThreadStatus::InterpretOperationProperties(
ThreadStatus::OperationType op_type,
const uint64_t* op_properties) {
std::map<std::string, uint64_t> ThreadStatus::InterpretOperationProperties(
ThreadStatus::OperationType /*op_type*/,
const uint64_t* /*op_properties*/) {
return std::map<std::string, uint64_t>();
}

@ -15,8 +15,8 @@ namespace rocksdb {
__thread ThreadStatusData* ThreadStatusUpdater::thread_status_data_ = nullptr;
void ThreadStatusUpdater::RegisterThread(
ThreadStatus::ThreadType ttype, uint64_t thread_id) {
void ThreadStatusUpdater::RegisterThread(ThreadStatus::ThreadType ttype,
uint64_t thread_id) {
if (UNLIKELY(thread_status_data_ == nullptr)) {
thread_status_data_ = new ThreadStatusData();
thread_status_data_->thread_type = ttype;
@ -43,8 +43,7 @@ void ThreadStatusUpdater::ResetThreadStatus() {
SetColumnFamilyInfoKey(nullptr);
}
void ThreadStatusUpdater::SetColumnFamilyInfoKey(
const void* cf_key) {
void ThreadStatusUpdater::SetColumnFamilyInfoKey(const void* cf_key) {
auto* data = Get();
if (data == nullptr) {
return;
@ -83,8 +82,7 @@ void ThreadStatusUpdater::SetThreadOperation(
}
}
void ThreadStatusUpdater::SetThreadOperationProperty(
int i, uint64_t value) {
void ThreadStatusUpdater::SetThreadOperationProperty(int i, uint64_t value) {
auto* data = GetLocalThreadStatus();
if (data == nullptr) {
return;
@ -92,8 +90,8 @@ void ThreadStatusUpdater::SetThreadOperationProperty(
data->op_properties[i].store(value, std::memory_order_relaxed);
}
void ThreadStatusUpdater::IncreaseThreadOperationProperty(
int i, uint64_t delta) {
void ThreadStatusUpdater::IncreaseThreadOperationProperty(int i,
uint64_t delta) {
auto* data = GetLocalThreadStatus();
if (data == nullptr) {
return;
@ -116,8 +114,8 @@ void ThreadStatusUpdater::ClearThreadOperation() {
}
data->operation_stage.store(ThreadStatus::STAGE_UNKNOWN,
std::memory_order_relaxed);
data->operation_type.store(
ThreadStatus::OP_UNKNOWN, std::memory_order_relaxed);
data->operation_type.store(ThreadStatus::OP_UNKNOWN,
std::memory_order_relaxed);
ClearThreadOperationProperties();
}
@ -137,12 +135,10 @@ ThreadStatus::OperationStage ThreadStatusUpdater::SetThreadOperationStage(
if (data == nullptr) {
return ThreadStatus::STAGE_UNKNOWN;
}
return data->operation_stage.exchange(
stage, std::memory_order_relaxed);
return data->operation_stage.exchange(stage, std::memory_order_relaxed);
}
void ThreadStatusUpdater::SetThreadState(
const ThreadStatus::StateType type) {
void ThreadStatusUpdater::SetThreadState(const ThreadStatus::StateType type) {
auto* data = GetLocalThreadStatus();
if (data == nullptr) {
return;
@ -155,8 +151,8 @@ void ThreadStatusUpdater::ClearThreadState() {
if (data == nullptr) {
return;
}
data->state_type.store(
ThreadStatus::STATE_UNKNOWN, std::memory_order_relaxed);
data->state_type.store(ThreadStatus::STATE_UNKNOWN,
std::memory_order_relaxed);
}
Status ThreadStatusUpdater::GetThreadList(
@ -168,15 +164,12 @@ Status ThreadStatusUpdater::GetThreadList(
std::lock_guard<std::mutex> lck(thread_list_mutex_);
for (auto* thread_data : thread_data_set_) {
assert(thread_data);
auto thread_id = thread_data->thread_id.load(
std::memory_order_relaxed);
auto thread_type = thread_data->thread_type.load(
std::memory_order_relaxed);
auto thread_id = thread_data->thread_id.load(std::memory_order_relaxed);
auto thread_type = thread_data->thread_type.load(std::memory_order_relaxed);
// Since any change to cf_info_map requires thread_list_mutex,
// which is currently held by GetThreadList(), here we can safely
// use "memory_order_relaxed" to load the cf_key.
auto cf_key = thread_data->cf_key.load(
std::memory_order_relaxed);
auto cf_key = thread_data->cf_key.load(std::memory_order_relaxed);
ThreadStatus::OperationType op_type = ThreadStatus::OP_UNKNOWN;
ThreadStatus::OperationStage op_stage = ThreadStatus::STAGE_UNKNOWN;
@ -186,19 +179,16 @@ Status ThreadStatusUpdater::GetThreadList(
auto iter = cf_info_map_.find(cf_key);
if (iter != cf_info_map_.end()) {
op_type = thread_data->operation_type.load(
std::memory_order_acquire);
op_type = thread_data->operation_type.load(std::memory_order_acquire);
// display lower-level info only when higher-level info is available.
if (op_type != ThreadStatus::OP_UNKNOWN) {
op_elapsed_micros = now_micros - thread_data->op_start_time.load(
std::memory_order_relaxed);
op_stage = thread_data->operation_stage.load(
std::memory_order_relaxed);
state_type = thread_data->state_type.load(
std::memory_order_relaxed);
op_stage = thread_data->operation_stage.load(std::memory_order_relaxed);
state_type = thread_data->state_type.load(std::memory_order_relaxed);
for (int i = 0; i < ThreadStatus::kNumOperationProperties; ++i) {
op_props[i] = thread_data->op_properties[i].load(
std::memory_order_relaxed);
op_props[i] =
thread_data->op_properties[i].load(std::memory_order_relaxed);
}
}
}
@ -206,9 +196,8 @@ Status ThreadStatusUpdater::GetThreadList(
thread_list->emplace_back(
thread_id, thread_type,
iter != cf_info_map_.end() ? iter->second.db_name : "",
iter != cf_info_map_.end() ? iter->second.cf_name : "",
op_type, op_elapsed_micros, op_stage, op_props,
state_type);
iter != cf_info_map_.end() ? iter->second.cf_name : "", op_type,
op_elapsed_micros, op_stage, op_props, state_type);
}
return Status::OK();
@ -219,22 +208,22 @@ ThreadStatusData* ThreadStatusUpdater::GetLocalThreadStatus() {
return nullptr;
}
if (!thread_status_data_->enable_tracking) {
assert(thread_status_data_->cf_key.load(
std::memory_order_relaxed) == nullptr);
assert(thread_status_data_->cf_key.load(std::memory_order_relaxed) ==
nullptr);
return nullptr;
}
return thread_status_data_;
}
void ThreadStatusUpdater::NewColumnFamilyInfo(
const void* db_key, const std::string& db_name,
const void* cf_key, const std::string& cf_name) {
void ThreadStatusUpdater::NewColumnFamilyInfo(const void* db_key,
const std::string& db_name,
const void* cf_key,
const std::string& cf_name) {
// Acquiring same lock as GetThreadList() to guarantee
// a consistent view of global column family table (cf_info_map).
std::lock_guard<std::mutex> lck(thread_list_mutex_);
cf_info_map_.emplace(std::piecewise_construct,
std::make_tuple(cf_key),
cf_info_map_.emplace(std::piecewise_construct, std::make_tuple(cf_key),
std::make_tuple(db_key, db_name, cf_name));
db_key_map_[db_key].insert(cf_key);
}
@ -281,58 +270,45 @@ void ThreadStatusUpdater::EraseDatabaseInfo(const void* db_key) {
#else
void ThreadStatusUpdater::RegisterThread(
ThreadStatus::ThreadType ttype, uint64_t thread_id) {
}
void ThreadStatusUpdater::RegisterThread(ThreadStatus::ThreadType /*ttype*/,
uint64_t /*thread_id*/) {}
void ThreadStatusUpdater::UnregisterThread() {
}
void ThreadStatusUpdater::UnregisterThread() {}
void ThreadStatusUpdater::ResetThreadStatus() {
}
void ThreadStatusUpdater::ResetThreadStatus() {}
void ThreadStatusUpdater::SetColumnFamilyInfoKey(
const void* cf_key) {
}
void ThreadStatusUpdater::SetColumnFamilyInfoKey(const void* /*cf_key*/) {}
void ThreadStatusUpdater::SetThreadOperation(
const ThreadStatus::OperationType type) {
}
const ThreadStatus::OperationType /*type*/) {}
void ThreadStatusUpdater::ClearThreadOperation() {
}
void ThreadStatusUpdater::ClearThreadOperation() {}
void ThreadStatusUpdater::SetThreadState(
const ThreadStatus::StateType type) {
}
const ThreadStatus::StateType /*type*/) {}
void ThreadStatusUpdater::ClearThreadState() {
}
void ThreadStatusUpdater::ClearThreadState() {}
Status ThreadStatusUpdater::GetThreadList(
std::vector<ThreadStatus>* thread_list) {
std::vector<ThreadStatus>* /*thread_list*/) {
return Status::NotSupported(
"GetThreadList is not supported in the current running environment.");
}
void ThreadStatusUpdater::NewColumnFamilyInfo(
const void* db_key, const std::string& db_name,
const void* cf_key, const std::string& cf_name) {
}
void ThreadStatusUpdater::NewColumnFamilyInfo(const void* /*db_key*/,
const std::string& /*db_name*/,
const void* /*cf_key*/,
const std::string& /*cf_name*/) {}
void ThreadStatusUpdater::EraseColumnFamilyInfo(const void* cf_key) {
}
void ThreadStatusUpdater::EraseColumnFamilyInfo(const void* /*cf_key*/) {}
void ThreadStatusUpdater::EraseDatabaseInfo(const void* db_key) {
}
void ThreadStatusUpdater::EraseDatabaseInfo(const void* /*db_key*/) {}
void ThreadStatusUpdater::SetThreadOperationProperty(
int i, uint64_t value) {
}
void ThreadStatusUpdater::SetThreadOperationProperty(int /*i*/,
uint64_t /*value*/) {}
void ThreadStatusUpdater::IncreaseThreadOperationProperty(
int i, uint64_t delta) {
}
void ThreadStatusUpdater::IncreaseThreadOperationProperty(int /*i*/,
uint64_t /*delta*/) {}
#endif // ROCKSDB_USING_THREAD_STATUS
} // namespace rocksdb

@ -13,8 +13,7 @@ namespace rocksdb {
#ifndef NDEBUG
#ifdef ROCKSDB_USING_THREAD_STATUS
void ThreadStatusUpdater::TEST_VerifyColumnFamilyInfoMap(
const std::vector<ColumnFamilyHandle*>& handles,
bool check_exist) {
const std::vector<ColumnFamilyHandle*>& handles, bool check_exist) {
std::unique_lock<std::mutex> lock(thread_list_mutex_);
if (check_exist) {
assert(cf_info_map_.size() == handles.size());
@ -34,12 +33,10 @@ void ThreadStatusUpdater::TEST_VerifyColumnFamilyInfoMap(
#else
void ThreadStatusUpdater::TEST_VerifyColumnFamilyInfoMap(
const std::vector<ColumnFamilyHandle*>& handles,
bool check_exist) {
const std::vector<ColumnFamilyHandle*>& /*handles*/, bool /*check_exist*/) {
}
#endif // ROCKSDB_USING_THREAD_STATUS
#endif // !NDEBUG
} // namespace rocksdb

@ -10,20 +10,18 @@
namespace rocksdb {
#ifdef ROCKSDB_USING_THREAD_STATUS
__thread ThreadStatusUpdater*
ThreadStatusUtil::thread_updater_local_cache_ = nullptr;
__thread ThreadStatusUpdater* ThreadStatusUtil::thread_updater_local_cache_ =
nullptr;
__thread bool ThreadStatusUtil::thread_updater_initialized_ = false;
void ThreadStatusUtil::RegisterThread(
const Env* env, ThreadStatus::ThreadType thread_type) {
void ThreadStatusUtil::RegisterThread(const Env* env,
ThreadStatus::ThreadType thread_type) {
if (!MaybeInitThreadLocalUpdater(env)) {
return;
}
assert(thread_updater_local_cache_);
thread_updater_local_cache_->RegisterThread(
thread_type, env->GetThreadID());
thread_updater_local_cache_->RegisterThread(thread_type, env->GetThreadID());
}
void ThreadStatusUtil::UnregisterThread() {
@ -80,28 +78,25 @@ ThreadStatus::OperationStage ThreadStatusUtil::SetThreadOperationStage(
return thread_updater_local_cache_->SetThreadOperationStage(stage);
}
void ThreadStatusUtil::SetThreadOperationProperty(
int code, uint64_t value) {
void ThreadStatusUtil::SetThreadOperationProperty(int code, uint64_t value) {
if (thread_updater_local_cache_ == nullptr) {
// thread_updater_local_cache_ must be set in SetColumnFamily
// or other ThreadStatusUtil functions.
return;
}
thread_updater_local_cache_->SetThreadOperationProperty(
code, value);
thread_updater_local_cache_->SetThreadOperationProperty(code, value);
}
void ThreadStatusUtil::IncreaseThreadOperationProperty(
int code, uint64_t delta) {
void ThreadStatusUtil::IncreaseThreadOperationProperty(int code,
uint64_t delta) {
if (thread_updater_local_cache_ == nullptr) {
// thread_updater_local_cache_ must be set in SetColumnFamily
// or other ThreadStatusUtil functions.
return;
}
thread_updater_local_cache_->IncreaseThreadOperationProperty(
code, delta);
thread_updater_local_cache_->IncreaseThreadOperationProperty(code, delta);
}
void ThreadStatusUtil::SetThreadState(ThreadStatus::StateType state) {
@ -135,8 +130,7 @@ void ThreadStatusUtil::NewColumnFamilyInfo(const DB* db,
}
}
void ThreadStatusUtil::EraseColumnFamilyInfo(
const ColumnFamilyData* cfd) {
void ThreadStatusUtil::EraseColumnFamilyInfo(const ColumnFamilyData* cfd) {
if (thread_updater_local_cache_ == nullptr) {
return;
}
@ -173,49 +167,39 @@ AutoThreadOperationStageUpdater::~AutoThreadOperationStageUpdater() {
ThreadStatusUpdater* ThreadStatusUtil::thread_updater_local_cache_ = nullptr;
bool ThreadStatusUtil::thread_updater_initialized_ = false;
bool ThreadStatusUtil::MaybeInitThreadLocalUpdater(const Env* env) {
bool ThreadStatusUtil::MaybeInitThreadLocalUpdater(const Env* /*env*/) {
return false;
}
void ThreadStatusUtil::SetColumnFamily(const ColumnFamilyData* cfd,
const Env* env,
bool enable_thread_tracking) {}
void ThreadStatusUtil::SetColumnFamily(const ColumnFamilyData* /*cfd*/,
const Env* /*env*/,
bool /*enable_thread_tracking*/) {}
void ThreadStatusUtil::SetThreadOperation(ThreadStatus::OperationType op) {
}
void ThreadStatusUtil::SetThreadOperation(ThreadStatus::OperationType /*op*/) {}
void ThreadStatusUtil::SetThreadOperationProperty(
int code, uint64_t value) {
}
void ThreadStatusUtil::SetThreadOperationProperty(int /*code*/,
uint64_t /*value*/) {}
void ThreadStatusUtil::IncreaseThreadOperationProperty(
int code, uint64_t delta) {
}
void ThreadStatusUtil::IncreaseThreadOperationProperty(int /*code*/,
uint64_t /*delta*/) {}
void ThreadStatusUtil::SetThreadState(ThreadStatus::StateType state) {
}
void ThreadStatusUtil::SetThreadState(ThreadStatus::StateType /*state*/) {}
void ThreadStatusUtil::NewColumnFamilyInfo(const DB* db,
const ColumnFamilyData* cfd,
const std::string& cf_name,
const Env* env) {}
void ThreadStatusUtil::NewColumnFamilyInfo(const DB* /*db*/,
const ColumnFamilyData* /*cfd*/,
const std::string& /*cf_name*/,
const Env* /*env*/) {}
void ThreadStatusUtil::EraseColumnFamilyInfo(
const ColumnFamilyData* cfd) {
}
void ThreadStatusUtil::EraseColumnFamilyInfo(const ColumnFamilyData* /*cfd*/) {}
void ThreadStatusUtil::EraseDatabaseInfo(const DB* db) {
}
void ThreadStatusUtil::EraseDatabaseInfo(const DB* /*db*/) {}
void ThreadStatusUtil::ResetThreadStatus() {
}
void ThreadStatusUtil::ResetThreadStatus() {}
AutoThreadOperationStageUpdater::AutoThreadOperationStageUpdater(
ThreadStatus::OperationStage stage) {
}
ThreadStatus::OperationStage /*stage*/) {}
AutoThreadOperationStageUpdater::~AutoThreadOperationStageUpdater() {
}
AutoThreadOperationStageUpdater::~AutoThreadOperationStageUpdater() {}
#endif // ROCKSDB_USING_THREAD_STATUS

@ -95,12 +95,14 @@ Status BlockBasedTableFactory::SanitizeOptions(
const DBOptions& /*db_opts*/, const ColumnFamilyOptions& cf_opts) const {
if (table_options_.index_type == BlockBasedTableOptions::kHashSearch &&
cf_opts.prefix_extractor == nullptr) {
return Status::InvalidArgument("Hash index is specified for block-based "
return Status::InvalidArgument(
"Hash index is specified for block-based "
"table, but prefix_extractor is not given");
}
if (table_options_.cache_index_and_filter_blocks &&
table_options_.no_block_cache) {
return Status::InvalidArgument("Enable cache_index_and_filter_blocks, "
return Status::InvalidArgument(
"Enable cache_index_and_filter_blocks, "
", but block cache is disabled");
}
if (table_options_.pin_l0_filter_and_index_blocks_in_cache &&
@ -115,7 +117,8 @@ Status BlockBasedTableFactory::SanitizeOptions(
"include/rocksdb/table.h for more info");
}
if (table_options_.block_align && (cf_opts.compression != kNoCompression)) {
return Status::InvalidArgument("Enable block_align, but compression "
return Status::InvalidArgument(
"Enable block_align, but compression "
"enabled");
}
if (table_options_.block_align &&
@ -153,8 +156,7 @@ std::string BlockBasedTableFactory::GetPrintableTableOptions() const {
snprintf(buffer, kBufferSize, " hash_index_allow_collision: %d\n",
table_options_.hash_index_allow_collision);
ret.append(buffer);
snprintf(buffer, kBufferSize, " checksum: %d\n",
table_options_.checksum);
snprintf(buffer, kBufferSize, " checksum: %d\n", table_options_.checksum);
ret.append(buffer);
snprintf(buffer, kBufferSize, " no_block_cache: %d\n",
table_options_.no_block_cache);
@ -216,8 +218,9 @@ std::string BlockBasedTableFactory::GetPrintableTableOptions() const {
table_options_.use_delta_encoding);
ret.append(buffer);
snprintf(buffer, kBufferSize, " filter_policy: %s\n",
table_options_.filter_policy == nullptr ?
"nullptr" : table_options_.filter_policy->Name());
table_options_.filter_policy == nullptr
? "nullptr"
: table_options_.filter_policy->Name());
ret.append(buffer);
snprintf(buffer, kBufferSize, " whole_key_filtering: %d\n",
table_options_.whole_key_filtering);
@ -284,7 +287,7 @@ Status BlockBasedTableFactory::GetOptionString(
}
#else
Status BlockBasedTableFactory::GetOptionString(
std::string* opt_string, const std::string& delimiter) const {
std::string* /*opt_string*/, const std::string& /*delimiter*/) const {
return Status::OK();
}
#endif // !ROCKSDB_LITE
@ -318,7 +321,7 @@ std::string ParseBlockBasedTableOption(const std::string& name,
cache = NewLRUCache(ParseSizeT(value));
} else {
LRUCacheOptions cache_opts;
if(!ParseOptionHelper(reinterpret_cast<char*>(&cache_opts),
if (!ParseOptionHelper(reinterpret_cast<char*>(&cache_opts),
OptionType::kLRUCacheOptions, value)) {
return "Invalid cache options";
}

@ -24,6 +24,8 @@ static inline uint64_t CuckooHash(
if (get_slice_hash != nullptr) {
return get_slice_hash(user_key, hash_cnt, table_size_);
}
#else
(void)get_slice_hash;
#endif
uint64_t value = 0;

@ -8,11 +8,11 @@
// found in the LICENSE file. See the AUTHORS file for names of contributors.
#pragma once
#include <string>
#include <stdint.h>
#include <string>
#include "rocksdb/options.h"
#include "rocksdb/slice.h"
#include "rocksdb/status.h"
#include "rocksdb/options.h"
#include "rocksdb/table.h"
#include "options/cf_options.h"
@ -53,13 +53,9 @@ class BlockHandle {
// if the block handle's offset and size are both "0", we will view it
// as a null block handle that points to no where.
bool IsNull() const {
return offset_ == 0 && size_ == 0;
}
bool IsNull() const { return offset_ == 0 && size_ == 0; }
static const BlockHandle& NullBlockHandle() {
return kNullBlockHandle;
}
static const BlockHandle& NullBlockHandle() { return kNullBlockHandle; }
// Maximum encoding length of a BlockHandle
enum { kMaxEncodedLength = 10 + 10 };
@ -71,8 +67,11 @@ class BlockHandle {
static const BlockHandle kNullBlockHandle;
};
inline uint32_t GetCompressFormatForVersion(CompressionType compression_type,
uint32_t version) {
inline uint32_t GetCompressFormatForVersion(
CompressionType compression_type, uint32_t version) {
#ifdef NDEBUG
(void)compression_type;
#endif
// snappy is not versioned
assert(compression_type != kSnappyCompression &&
compression_type != kXpressCompression &&
@ -200,7 +199,9 @@ struct BlockContents {
compression_type(_compression_type),
allocation(std::move(_data)) {}
BlockContents(BlockContents&& other) ROCKSDB_NOEXCEPT { *this = std::move(other); }
BlockContents(BlockContents&& other) ROCKSDB_NOEXCEPT {
*this = std::move(other);
}
BlockContents& operator=(BlockContents&& other) {
data = std::move(other.data);
@ -231,7 +232,7 @@ extern Status UncompressBlockContents(const char* data, size_t n,
BlockContents* contents,
uint32_t compress_format_version,
const Slice& compression_dict,
const ImmutableCFOptions &ioptions);
const ImmutableCFOptions& ioptions);
// This is an extension to UncompressBlockContents that accepts
// a specific compression type. This is used by un-wrapped blocks
@ -239,7 +240,7 @@ extern Status UncompressBlockContents(const char* data, size_t n,
extern Status UncompressBlockContentsForCompressionType(
const char* data, size_t n, BlockContents* contents,
uint32_t compress_format_version, const Slice& compression_dict,
CompressionType compression_type, const ImmutableCFOptions &ioptions);
CompressionType compression_type, const ImmutableCFOptions& ioptions);
// Implementation details follow. Clients should ignore,
@ -247,9 +248,7 @@ extern Status UncompressBlockContentsForCompressionType(
// BlockHandle. Currently we use zeros for null and use negation-of-zeros for
// uninitialized.
inline BlockHandle::BlockHandle()
: BlockHandle(~static_cast<uint64_t>(0),
~static_cast<uint64_t>(0)) {
}
: BlockHandle(~static_cast<uint64_t>(0), ~static_cast<uint64_t>(0)) {}
inline BlockHandle::BlockHandle(uint64_t _offset, uint64_t _size)
: offset_(_offset), size_(_size) {}

@ -77,6 +77,9 @@ FullFilterBlockReader::FullFilterBlockReader(
bool FullFilterBlockReader::KeyMayMatch(const Slice& key, uint64_t block_offset,
const bool /*no_io*/,
const Slice* const /*const_ikey_ptr*/) {
#ifdef NDEBUG
(void)block_offset;
#endif
assert(block_offset == kNotValid);
if (!whole_key_filtering_) {
return true;
@ -87,6 +90,9 @@ bool FullFilterBlockReader::KeyMayMatch(const Slice& key, uint64_t block_offset,
bool FullFilterBlockReader::PrefixMayMatch(
const Slice& prefix, uint64_t block_offset, const bool /*no_io*/,
const Slice* const /*const_ikey_ptr*/) {
#ifdef NDEBUG
(void)block_offset;
#endif
assert(block_offset == kNotValid);
if (!prefix_extractor_) {
return true;

@ -29,6 +29,10 @@ void appendToReplayLog(std::string* replay_log, ValueType type, Slice value) {
replay_log->push_back(type);
PutLengthPrefixedSlice(replay_log, value);
}
#else
(void)replay_log;
(void)type;
(void)value;
#endif // ROCKSDB_LITE
}
@ -242,6 +246,10 @@ void replayGetContextLog(const Slice& replay_log, const Slice& user_key,
&dont_care, value_pinner);
}
#else // ROCKSDB_LITE
(void)replay_log;
(void)user_key;
(void)get_context;
(void)value_pinner;
assert(false);
#endif // ROCKSDB_LITE
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save