@nxtedition/rocksdb 7.1.33 → 7.1.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/deps/rocksdb/rocksdb/cache/clock_cache.cc +402 -345
  2. package/deps/rocksdb/rocksdb/cache/clock_cache.h +121 -64
  3. package/deps/rocksdb/rocksdb/cache/lru_cache_test.cc +28 -18
  4. package/deps/rocksdb/rocksdb/db/arena_wrapped_db_iter.cc +1 -0
  5. package/deps/rocksdb/rocksdb/db/arena_wrapped_db_iter.h +2 -0
  6. package/deps/rocksdb/rocksdb/db/builder.cc +2 -1
  7. package/deps/rocksdb/rocksdb/db/c.cc +563 -673
  8. package/deps/rocksdb/rocksdb/db/c_test.c +168 -169
  9. package/deps/rocksdb/rocksdb/db/column_family.cc +16 -15
  10. package/deps/rocksdb/rocksdb/db/column_family.h +7 -7
  11. package/deps/rocksdb/rocksdb/db/column_family_test.cc +17 -28
  12. package/deps/rocksdb/rocksdb/db/compact_files_test.cc +4 -9
  13. package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator.cc +8 -3
  14. package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator_test.cc +114 -0
  15. package/deps/rocksdb/rocksdb/db/comparator_db_test.cc +2 -3
  16. package/deps/rocksdb/rocksdb/db/convenience.cc +3 -5
  17. package/deps/rocksdb/rocksdb/db/corruption_test.cc +10 -14
  18. package/deps/rocksdb/rocksdb/db/cuckoo_table_db_test.cc +9 -13
  19. package/deps/rocksdb/rocksdb/db/db_basic_test.cc +2 -2
  20. package/deps/rocksdb/rocksdb/db/db_block_cache_test.cc +2 -2
  21. package/deps/rocksdb/rocksdb/db/db_bloom_filter_test.cc +14 -16
  22. package/deps/rocksdb/rocksdb/db/db_compaction_test.cc +52 -72
  23. package/deps/rocksdb/rocksdb/db/db_dynamic_level_test.cc +2 -2
  24. package/deps/rocksdb/rocksdb/db/db_encryption_test.cc +12 -12
  25. package/deps/rocksdb/rocksdb/db/db_filesnapshot.cc +1 -2
  26. package/deps/rocksdb/rocksdb/db/db_flush_test.cc +3 -3
  27. package/deps/rocksdb/rocksdb/db/db_impl/db_impl.cc +1 -12
  28. package/deps/rocksdb/rocksdb/db/db_impl/db_impl.h +3 -0
  29. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_write.cc +26 -0
  30. package/deps/rocksdb/rocksdb/db/db_info_dumper.cc +1 -0
  31. package/deps/rocksdb/rocksdb/db/db_iter.cc +12 -6
  32. package/deps/rocksdb/rocksdb/db/db_iter.h +1 -0
  33. package/deps/rocksdb/rocksdb/db/db_iter_stress_test.cc +6 -7
  34. package/deps/rocksdb/rocksdb/db/db_iter_test.cc +10 -8
  35. package/deps/rocksdb/rocksdb/db/db_iterator_test.cc +15 -13
  36. package/deps/rocksdb/rocksdb/db/db_log_iter_test.cc +7 -9
  37. package/deps/rocksdb/rocksdb/db/db_logical_block_size_cache_test.cc +4 -4
  38. package/deps/rocksdb/rocksdb/db/db_merge_operand_test.cc +1 -1
  39. package/deps/rocksdb/rocksdb/db/db_merge_operator_test.cc +2 -4
  40. package/deps/rocksdb/rocksdb/db/db_options_test.cc +4 -4
  41. package/deps/rocksdb/rocksdb/db/db_properties_test.cc +7 -4
  42. package/deps/rocksdb/rocksdb/db/db_range_del_test.cc +7 -5
  43. package/deps/rocksdb/rocksdb/db/db_secondary_test.cc +1 -1
  44. package/deps/rocksdb/rocksdb/db/db_statistics_test.cc +8 -6
  45. package/deps/rocksdb/rocksdb/db/db_table_properties_test.cc +18 -23
  46. package/deps/rocksdb/rocksdb/db/db_tailing_iter_test.cc +3 -5
  47. package/deps/rocksdb/rocksdb/db/db_test.cc +10 -5
  48. package/deps/rocksdb/rocksdb/db/db_test2.cc +172 -169
  49. package/deps/rocksdb/rocksdb/db/db_test_util.cc +68 -66
  50. package/deps/rocksdb/rocksdb/db/db_test_util.h +1 -3
  51. package/deps/rocksdb/rocksdb/db/db_universal_compaction_test.cc +31 -39
  52. package/deps/rocksdb/rocksdb/db/db_with_timestamp_basic_test.cc +182 -2
  53. package/deps/rocksdb/rocksdb/db/db_write_test.cc +43 -40
  54. package/deps/rocksdb/rocksdb/db/dbformat.h +15 -0
  55. package/deps/rocksdb/rocksdb/db/dbformat_test.cc +35 -34
  56. package/deps/rocksdb/rocksdb/db/deletefile_test.cc +10 -11
  57. package/deps/rocksdb/rocksdb/db/error_handler.cc +6 -6
  58. package/deps/rocksdb/rocksdb/db/error_handler.h +93 -94
  59. package/deps/rocksdb/rocksdb/db/event_helpers.cc +1 -1
  60. package/deps/rocksdb/rocksdb/db/event_helpers.h +3 -3
  61. package/deps/rocksdb/rocksdb/db/external_sst_file_ingestion_job.cc +16 -17
  62. package/deps/rocksdb/rocksdb/db/external_sst_file_test.cc +2 -2
  63. package/deps/rocksdb/rocksdb/db/fault_injection_test.cc +1 -2
  64. package/deps/rocksdb/rocksdb/db/file_indexer.cc +2 -0
  65. package/deps/rocksdb/rocksdb/db/file_indexer.h +2 -1
  66. package/deps/rocksdb/rocksdb/db/file_indexer_test.cc +4 -2
  67. package/deps/rocksdb/rocksdb/db/filename_test.cc +27 -29
  68. package/deps/rocksdb/rocksdb/db/flush_job.cc +7 -13
  69. package/deps/rocksdb/rocksdb/db/flush_job_test.cc +2 -2
  70. package/deps/rocksdb/rocksdb/db/forward_iterator.cc +15 -21
  71. package/deps/rocksdb/rocksdb/db/forward_iterator.h +7 -6
  72. package/deps/rocksdb/rocksdb/db/forward_iterator_bench.cc +4 -2
  73. package/deps/rocksdb/rocksdb/db/import_column_family_job.cc +2 -2
  74. package/deps/rocksdb/rocksdb/db/internal_stats.cc +59 -14
  75. package/deps/rocksdb/rocksdb/db/internal_stats.h +27 -11
  76. package/deps/rocksdb/rocksdb/db/job_context.h +5 -6
  77. package/deps/rocksdb/rocksdb/db/listener_test.cc +21 -23
  78. package/deps/rocksdb/rocksdb/db/log_reader.cc +7 -11
  79. package/deps/rocksdb/rocksdb/db/log_reader.h +4 -6
  80. package/deps/rocksdb/rocksdb/db/log_test.cc +6 -12
  81. package/deps/rocksdb/rocksdb/db/log_writer.h +1 -1
  82. package/deps/rocksdb/rocksdb/db/logs_with_prep_tracker.h +0 -1
  83. package/deps/rocksdb/rocksdb/db/lookup_key.h +4 -1
  84. package/deps/rocksdb/rocksdb/db/malloc_stats.cc +2 -1
  85. package/deps/rocksdb/rocksdb/db/manual_compaction_test.cc +3 -5
  86. package/deps/rocksdb/rocksdb/db/memtable.cc +34 -22
  87. package/deps/rocksdb/rocksdb/db/memtable.h +4 -6
  88. package/deps/rocksdb/rocksdb/db/memtable_list.cc +7 -0
  89. package/deps/rocksdb/rocksdb/db/memtable_list_test.cc +37 -13
  90. package/deps/rocksdb/rocksdb/db/merge_context.h +1 -0
  91. package/deps/rocksdb/rocksdb/db/merge_helper.cc +128 -14
  92. package/deps/rocksdb/rocksdb/db/merge_helper.h +15 -7
  93. package/deps/rocksdb/rocksdb/db/merge_helper_test.cc +2 -1
  94. package/deps/rocksdb/rocksdb/db/merge_operator.cc +5 -6
  95. package/deps/rocksdb/rocksdb/db/obsolete_files_test.cc +4 -3
  96. package/deps/rocksdb/rocksdb/db/options_file_test.cc +1 -1
  97. package/deps/rocksdb/rocksdb/db/perf_context_test.cc +55 -43
  98. package/deps/rocksdb/rocksdb/db/plain_table_db_test.cc +288 -299
  99. package/deps/rocksdb/rocksdb/db/prefix_test.cc +22 -27
  100. package/deps/rocksdb/rocksdb/db/range_del_aggregator.cc +1 -1
  101. package/deps/rocksdb/rocksdb/db/range_del_aggregator_test.cc +1 -1
  102. package/deps/rocksdb/rocksdb/db/repair.cc +7 -8
  103. package/deps/rocksdb/rocksdb/db/repair_test.cc +3 -4
  104. package/deps/rocksdb/rocksdb/db/snapshot_impl.cc +4 -5
  105. package/deps/rocksdb/rocksdb/db/snapshot_impl.h +10 -4
  106. package/deps/rocksdb/rocksdb/db/table_cache.cc +3 -4
  107. package/deps/rocksdb/rocksdb/db/table_properties_collector.cc +6 -7
  108. package/deps/rocksdb/rocksdb/db/table_properties_collector_test.cc +22 -22
  109. package/deps/rocksdb/rocksdb/db/transaction_log_impl.cc +12 -12
  110. package/deps/rocksdb/rocksdb/db/transaction_log_impl.h +6 -8
  111. package/deps/rocksdb/rocksdb/db/trim_history_scheduler.h +2 -0
  112. package/deps/rocksdb/rocksdb/db/version_builder_test.cc +3 -3
  113. package/deps/rocksdb/rocksdb/db/version_edit.cc +2 -5
  114. package/deps/rocksdb/rocksdb/db/version_edit.h +8 -12
  115. package/deps/rocksdb/rocksdb/db/version_set.cc +74 -102
  116. package/deps/rocksdb/rocksdb/db/version_set.h +8 -10
  117. package/deps/rocksdb/rocksdb/db/version_set_sync_and_async.h +0 -5
  118. package/deps/rocksdb/rocksdb/db/version_set_test.cc +47 -45
  119. package/deps/rocksdb/rocksdb/db/wal_manager.cc +6 -5
  120. package/deps/rocksdb/rocksdb/db/wal_manager.h +2 -2
  121. package/deps/rocksdb/rocksdb/db/wal_manager_test.cc +4 -3
  122. package/deps/rocksdb/rocksdb/db/wide/db_wide_basic_test.cc +144 -61
  123. package/deps/rocksdb/rocksdb/db/write_batch.cc +41 -24
  124. package/deps/rocksdb/rocksdb/db/write_batch_internal.h +2 -7
  125. package/deps/rocksdb/rocksdb/db/write_batch_test.cc +105 -104
  126. package/deps/rocksdb/rocksdb/db/write_callback_test.cc +5 -4
  127. package/deps/rocksdb/rocksdb/db/write_controller.h +1 -0
  128. package/deps/rocksdb/rocksdb/db/write_controller_test.cc +1 -1
  129. package/deps/rocksdb/rocksdb/db/write_thread.cc +8 -6
  130. package/deps/rocksdb/rocksdb/env/io_posix.h +6 -0
  131. package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.cc +134 -65
  132. package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.h +29 -0
  133. package/deps/rocksdb/rocksdb/include/rocksdb/compaction_filter.h +1 -0
  134. package/deps/rocksdb/rocksdb/include/rocksdb/db.h +1 -4
  135. package/deps/rocksdb/rocksdb/include/rocksdb/merge_operator.h +1 -0
  136. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/stackable_db.h +4 -0
  137. package/deps/rocksdb/rocksdb/include/rocksdb/write_batch.h +14 -4
  138. package/deps/rocksdb/rocksdb/table/get_context.cc +52 -7
  139. package/deps/rocksdb/rocksdb/table/get_context.h +1 -2
  140. package/deps/rocksdb/rocksdb/tools/db_bench_tool.cc +13 -0
  141. package/deps/rocksdb/rocksdb/util/crc32c_arm64.cc +36 -4
  142. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_test.cc +6 -6
  143. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_test.h +23 -28
  144. package/deps/rocksdb/rocksdb/utilities/transactions/write_committed_transaction_ts_test.cc +11 -1
  145. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_transaction_test.cc +19 -17
  146. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.cc +10 -7
  147. package/index.js +7 -7
  148. package/package.json +1 -1
  149. package/prebuilds/darwin-arm64/node.napi.node +0 -0
  150. package/prebuilds/linux-x64/node.napi.node +0 -0
@@ -69,7 +69,7 @@ struct TestKey {
69
69
  };
70
70
 
71
71
  // return a slice backed by test_key
72
- inline Slice TestKeyToSlice(std::string &s, const TestKey& test_key) {
72
+ inline Slice TestKeyToSlice(std::string& s, const TestKey& test_key) {
73
73
  s.clear();
74
74
  PutFixed64(&s, test_key.prefix);
75
75
  PutFixed64(&s, test_key.sorted);
@@ -77,20 +77,18 @@ inline Slice TestKeyToSlice(std::string &s, const TestKey& test_key) {
77
77
  }
78
78
 
79
79
  inline const TestKey SliceToTestKey(const Slice& slice) {
80
- return TestKey(DecodeFixed64(slice.data()),
81
- DecodeFixed64(slice.data() + 8));
80
+ return TestKey(DecodeFixed64(slice.data()), DecodeFixed64(slice.data() + 8));
82
81
  }
83
82
 
84
83
  class TestKeyComparator : public Comparator {
85
84
  public:
86
-
87
85
  // Compare needs to be aware of the possibility of a and/or b is
88
86
  // prefix only
89
87
  int Compare(const Slice& a, const Slice& b) const override {
90
88
  const TestKey kkey_a = SliceToTestKey(a);
91
89
  const TestKey kkey_b = SliceToTestKey(b);
92
- const TestKey *key_a = &kkey_a;
93
- const TestKey *key_b = &kkey_b;
90
+ const TestKey* key_a = &kkey_a;
91
+ const TestKey* key_b = &kkey_b;
94
92
  if (key_a->prefix != key_b->prefix) {
95
93
  if (key_a->prefix < key_b->prefix) return -1;
96
94
  if (key_a->prefix > key_b->prefix) return 1;
@@ -215,7 +213,7 @@ class SamePrefixTransform : public SliceTransform {
215
213
  bool FullLengthEnabled(size_t* /*len*/) const override { return false; }
216
214
  };
217
215
 
218
- } // namespace
216
+ } // anonymous namespace
219
217
 
220
218
  class PrefixTest : public testing::Test {
221
219
  public:
@@ -226,7 +224,7 @@ class PrefixTest : public testing::Test {
226
224
  options.write_buffer_size = FLAGS_write_buffer_size;
227
225
  options.max_write_buffer_number = FLAGS_max_write_buffer_number;
228
226
  options.min_write_buffer_number_to_merge =
229
- FLAGS_min_write_buffer_number_to_merge;
227
+ FLAGS_min_write_buffer_number_to_merge;
230
228
 
231
229
  options.memtable_prefix_bloom_size_ratio =
232
230
  FLAGS_memtable_prefix_bloom_size_ratio;
@@ -239,21 +237,19 @@ class PrefixTest : public testing::Test {
239
237
  options.table_factory.reset(NewBlockBasedTableFactory(bbto));
240
238
  options.allow_concurrent_memtable_write = false;
241
239
 
242
- Status s = DB::Open(options, kDbName, &db);
240
+ Status s = DB::Open(options, kDbName, &db);
243
241
  EXPECT_OK(s);
244
242
  return std::shared_ptr<DB>(db);
245
243
  }
246
244
 
247
- void FirstOption() {
248
- option_config_ = kBegin;
249
- }
245
+ void FirstOption() { option_config_ = kBegin; }
250
246
 
251
247
  bool NextOptions(int bucket_count) {
252
248
  // skip some options
253
249
  option_config_++;
254
250
  if (option_config_ < kEnd) {
255
251
  options.prefix_extractor.reset(NewFixedPrefixTransform(8));
256
- switch(option_config_) {
252
+ switch (option_config_) {
257
253
  case kHashSkipList:
258
254
  options.memtable_factory.reset(
259
255
  NewHashSkipListRepFactory(bucket_count, FLAGS_skiplist_height));
@@ -350,8 +346,7 @@ TEST_F(PrefixTest, TestResult) {
350
346
  FirstOption();
351
347
  while (NextOptions(num_buckets)) {
352
348
  std::cout << "*** Mem table: " << options.memtable_factory->Name()
353
- << " number of buckets: " << num_buckets
354
- << std::endl;
349
+ << " number of buckets: " << num_buckets << std::endl;
355
350
  ASSERT_OK(DestroyDB(kDbName, Options()));
356
351
  auto db = OpenDb();
357
352
  WriteOptions write_options;
@@ -581,7 +576,7 @@ TEST_F(PrefixTest, PrefixValid) {
581
576
  TEST_F(PrefixTest, DynamicPrefixIterator) {
582
577
  while (NextOptions(FLAGS_bucket_count)) {
583
578
  std::cout << "*** Mem table: " << options.memtable_factory->Name()
584
- << std::endl;
579
+ << std::endl;
585
580
  ASSERT_OK(DestroyDB(kDbName, Options()));
586
581
  auto db = OpenDb();
587
582
  WriteOptions write_options;
@@ -600,7 +595,7 @@ TEST_F(PrefixTest, DynamicPrefixIterator) {
600
595
  HistogramImpl hist_put_comparison;
601
596
  // insert x random prefix, each with y continuous element.
602
597
  for (auto prefix : prefixes) {
603
- for (uint64_t sorted = 0; sorted < FLAGS_items_per_prefix; sorted++) {
598
+ for (uint64_t sorted = 0; sorted < FLAGS_items_per_prefix; sorted++) {
604
599
  TestKey test_key(prefix, sorted);
605
600
 
606
601
  std::string s;
@@ -615,8 +610,9 @@ TEST_F(PrefixTest, DynamicPrefixIterator) {
615
610
  }
616
611
  }
617
612
 
618
- std::cout << "Put key comparison: \n" << hist_put_comparison.ToString()
619
- << "Put time: \n" << hist_put_time.ToString();
613
+ std::cout << "Put key comparison: \n"
614
+ << hist_put_comparison.ToString() << "Put time: \n"
615
+ << hist_put_time.ToString();
620
616
 
621
617
  // test seek existing keys
622
618
  HistogramImpl hist_seek_time;
@@ -635,8 +631,7 @@ TEST_F(PrefixTest, DynamicPrefixIterator) {
635
631
  auto key_prefix = options.prefix_extractor->Transform(key);
636
632
  uint64_t total_keys = 0;
637
633
  for (iter->Seek(key);
638
- iter->Valid() && iter->key().starts_with(key_prefix);
639
- iter->Next()) {
634
+ iter->Valid() && iter->key().starts_with(key_prefix); iter->Next()) {
640
635
  if (FLAGS_trigger_deadlock) {
641
636
  std::cout << "Behold the deadlock!\n";
642
637
  db->Delete(write_options, iter->key());
@@ -645,12 +640,12 @@ TEST_F(PrefixTest, DynamicPrefixIterator) {
645
640
  }
646
641
  hist_seek_time.Add(timer.ElapsedNanos());
647
642
  hist_seek_comparison.Add(get_perf_context()->user_key_comparison_count);
648
- ASSERT_EQ(total_keys, FLAGS_items_per_prefix - FLAGS_items_per_prefix/2);
643
+ ASSERT_EQ(total_keys,
644
+ FLAGS_items_per_prefix - FLAGS_items_per_prefix / 2);
649
645
  }
650
646
 
651
647
  std::cout << "Seek key comparison: \n"
652
- << hist_seek_comparison.ToString()
653
- << "Seek time: \n"
648
+ << hist_seek_comparison.ToString() << "Seek time: \n"
654
649
  << hist_seek_time.ToString();
655
650
 
656
651
  // test non-existing keys
@@ -658,8 +653,7 @@ TEST_F(PrefixTest, DynamicPrefixIterator) {
658
653
  HistogramImpl hist_no_seek_comparison;
659
654
 
660
655
  for (auto prefix = FLAGS_total_prefixes;
661
- prefix < FLAGS_total_prefixes + 10000;
662
- prefix++) {
656
+ prefix < FLAGS_total_prefixes + 10000; prefix++) {
663
657
  TestKey test_key(prefix, 0);
664
658
  std::string s;
665
659
  Slice key = TestKeyToSlice(s, test_key);
@@ -668,7 +662,8 @@ TEST_F(PrefixTest, DynamicPrefixIterator) {
668
662
  StopWatchNano timer(SystemClock::Default().get(), true);
669
663
  iter->Seek(key);
670
664
  hist_no_seek_time.Add(timer.ElapsedNanos());
671
- hist_no_seek_comparison.Add(get_perf_context()->user_key_comparison_count);
665
+ hist_no_seek_comparison.Add(
666
+ get_perf_context()->user_key_comparison_count);
672
667
  ASSERT_TRUE(!iter->Valid());
673
668
  ASSERT_OK(iter->status());
674
669
  }
@@ -502,7 +502,7 @@ class TruncatedRangeDelMergingIter : public InternalIterator {
502
502
  size_t ts_sz_;
503
503
  };
504
504
 
505
- } // namespace
505
+ } // anonymous namespace
506
506
 
507
507
  std::unique_ptr<FragmentedRangeTombstoneIterator>
508
508
  CompactionRangeDelAggregator::NewIterator(const Slice* lower_bound,
@@ -192,7 +192,7 @@ void VerifyFragmentedRangeDels(
192
192
  EXPECT_FALSE(iter->Valid());
193
193
  }
194
194
 
195
- } // namespace
195
+ } // anonymous namespace
196
196
 
197
197
  TEST_F(RangeDelAggregatorTest, EmptyTruncatedIter) {
198
198
  auto range_del_iter = MakeRangeDelIter({});
@@ -281,7 +281,7 @@ class Repairer {
281
281
  std::vector<std::string> to_search_paths;
282
282
 
283
283
  for (size_t path_id = 0; path_id < db_options_.db_paths.size(); path_id++) {
284
- to_search_paths.push_back(db_options_.db_paths[path_id].path);
284
+ to_search_paths.push_back(db_options_.db_paths[path_id].path);
285
285
  }
286
286
 
287
287
  // search wal_dir if user uses a customize wal_dir
@@ -332,7 +332,8 @@ class Repairer {
332
332
  void ConvertLogFilesToTables() {
333
333
  const auto& wal_dir = immutable_db_options_.GetWalDir();
334
334
  for (size_t i = 0; i < logs_.size(); i++) {
335
- // we should use LogFileName(wal_dir, logs_[i]) here. user might uses wal_dir option.
335
+ // we should use LogFileName(wal_dir, logs_[i]) here. user might uses
336
+ // wal_dir option.
336
337
  std::string logname = LogFileName(wal_dir, logs_[i]);
337
338
  Status status = ConvertLogToTable(wal_dir, logs_[i]);
338
339
  if (!status.ok()) {
@@ -393,8 +394,8 @@ class Repairer {
393
394
  int counter = 0;
394
395
  while (reader.ReadRecord(&record, &scratch)) {
395
396
  if (record.size() < WriteBatchInternal::kHeader) {
396
- reporter.Corruption(
397
- record.size(), Status::Corruption("log record too small"));
397
+ reporter.Corruption(record.size(),
398
+ Status::Corruption("log record too small"));
398
399
  continue;
399
400
  }
400
401
  Status record_status = WriteBatchInternal::SetContents(&batch, record);
@@ -715,8 +716,7 @@ Status GetDefaultCFOptions(
715
716
  } // anonymous namespace
716
717
 
717
718
  Status RepairDB(const std::string& dbname, const DBOptions& db_options,
718
- const std::vector<ColumnFamilyDescriptor>& column_families
719
- ) {
719
+ const std::vector<ColumnFamilyDescriptor>& column_families) {
720
720
  ColumnFamilyOptions default_cf_opts;
721
721
  Status status = GetDefaultCFOptions(column_families, &default_cf_opts);
722
722
  if (!status.ok()) {
@@ -756,8 +756,7 @@ Status RepairDB(const std::string& dbname, const Options& options) {
756
756
  DBOptions db_options(opts);
757
757
  ColumnFamilyOptions cf_options(opts);
758
758
 
759
- Repairer repairer(dbname, db_options,
760
- {}, cf_options /* default_cf_opts */,
759
+ Repairer repairer(dbname, db_options, {}, cf_options /* default_cf_opts */,
761
760
  cf_options /* unknown_cf_opts */,
762
761
  true /* create_unknown_cfs */);
763
762
  Status status = repairer.Run();
@@ -279,7 +279,7 @@ TEST_F(RepairTest, SeparateWalDir) {
279
279
  ASSERT_EQ(total_ssts_size, 0);
280
280
  }
281
281
  std::string manifest_path =
282
- DescriptorFileName(dbname_, dbfull()->TEST_Current_Manifest_FileNo());
282
+ DescriptorFileName(dbname_, dbfull()->TEST_Current_Manifest_FileNo());
283
283
 
284
284
  Close();
285
285
  ASSERT_OK(env_->FileExists(manifest_path));
@@ -301,7 +301,7 @@ TEST_F(RepairTest, SeparateWalDir) {
301
301
  ASSERT_EQ(Get("key"), "val");
302
302
  ASSERT_EQ(Get("foo"), "bar");
303
303
 
304
- } while(ChangeWalOptions());
304
+ } while (ChangeWalOptions());
305
305
  }
306
306
 
307
307
  TEST_F(RepairTest, RepairMultipleColumnFamilies) {
@@ -387,8 +387,7 @@ TEST_F(RepairTest, RepairColumnFamilyOptions) {
387
387
  ASSERT_EQ(fname_to_props.size(), 2U);
388
388
  for (const auto& fname_and_props : fname_to_props) {
389
389
  std::string comparator_name(rev_opts.comparator->Name());
390
- ASSERT_EQ(comparator_name,
391
- fname_and_props.second->comparator_name);
390
+ ASSERT_EQ(comparator_name, fname_and_props.second->comparator_name);
392
391
  }
393
392
  Close();
394
393
 
@@ -3,14 +3,13 @@
3
3
  // COPYING file in the root directory) and Apache 2.0 License
4
4
  // (found in the LICENSE.Apache file in the root directory).
5
5
 
6
- #include "rocksdb/snapshot.h"
7
-
8
6
  #include "rocksdb/db.h"
7
+ #include "rocksdb/snapshot.h"
9
8
 
10
9
  namespace ROCKSDB_NAMESPACE {
11
10
 
12
- ManagedSnapshot::ManagedSnapshot(DB* db) : db_(db),
13
- snapshot_(db->GetSnapshot()) {}
11
+ ManagedSnapshot::ManagedSnapshot(DB* db)
12
+ : db_(db), snapshot_(db->GetSnapshot()) {}
14
13
 
15
14
  ManagedSnapshot::ManagedSnapshot(DB* db, const Snapshot* _snapshot)
16
15
  : db_(db), snapshot_(_snapshot) {}
@@ -21,6 +20,6 @@ ManagedSnapshot::~ManagedSnapshot() {
21
20
  }
22
21
  }
23
22
 
24
- const Snapshot* ManagedSnapshot::snapshot() { return snapshot_;}
23
+ const Snapshot* ManagedSnapshot::snapshot() { return snapshot_; }
25
24
 
26
25
  } // namespace ROCKSDB_NAMESPACE
@@ -41,7 +41,7 @@ class SnapshotImpl : public Snapshot {
41
41
  SnapshotImpl* prev_;
42
42
  SnapshotImpl* next_;
43
43
 
44
- SnapshotList* list_; // just for sanity checks
44
+ SnapshotList* list_; // just for sanity checks
45
45
 
46
46
  int64_t unix_time_;
47
47
 
@@ -56,7 +56,7 @@ class SnapshotList {
56
56
  SnapshotList() {
57
57
  list_.prev_ = &list_;
58
58
  list_.next_ = &list_;
59
- list_.number_ = 0xFFFFFFFFL; // placeholder marker, for debugging
59
+ list_.number_ = 0xFFFFFFFFL; // placeholder marker, for debugging
60
60
  // Set all the variables to make UBSAN happy.
61
61
  list_.list_ = nullptr;
62
62
  list_.unix_time_ = 0;
@@ -72,8 +72,14 @@ class SnapshotList {
72
72
  assert(list_.next_ != &list_ || 0 == count_);
73
73
  return list_.next_ == &list_;
74
74
  }
75
- SnapshotImpl* oldest() const { assert(!empty()); return list_.next_; }
76
- SnapshotImpl* newest() const { assert(!empty()); return list_.prev_; }
75
+ SnapshotImpl* oldest() const {
76
+ assert(!empty());
77
+ return list_.next_;
78
+ }
79
+ SnapshotImpl* newest() const {
80
+ assert(!empty());
81
+ return list_.prev_;
82
+ }
77
83
 
78
84
  SnapshotImpl* New(SnapshotImpl* s, SequenceNumber seq, uint64_t unix_time,
79
85
  bool is_write_conflict_boundary,
@@ -38,7 +38,7 @@ static void DeleteEntry(const Slice& /*key*/, void* value) {
38
38
  T* typed_value = reinterpret_cast<T*>(value);
39
39
  delete typed_value;
40
40
  }
41
- } // namespace
41
+ } // anonymous namespace
42
42
  } // namespace ROCKSDB_NAMESPACE
43
43
 
44
44
  // Generate the regular and coroutine versions of some methods by
@@ -79,7 +79,7 @@ void AppendVarint64(IterKey* key, uint64_t v) {
79
79
 
80
80
  #endif // ROCKSDB_LITE
81
81
 
82
- } // namespace
82
+ } // anonymous namespace
83
83
 
84
84
  const int kLoadConcurency = 128;
85
85
 
@@ -103,8 +103,7 @@ TableCache::TableCache(const ImmutableOptions& ioptions,
103
103
  }
104
104
  }
105
105
 
106
- TableCache::~TableCache() {
107
- }
106
+ TableCache::~TableCache() {}
108
107
 
109
108
  TableReader* TableCache::GetTableReaderFromHandle(Cache::Handle* handle) {
110
109
  return reinterpret_cast<TableReader*>(cache_->Value(handle));
@@ -27,7 +27,7 @@ uint64_t GetUint64Property(const UserCollectedProperties& props,
27
27
  return GetVarint64(&raw, &val) ? val : 0;
28
28
  }
29
29
 
30
- } // namespace
30
+ } // anonymous namespace
31
31
 
32
32
  Status UserKeyTablePropertiesCollector::InternalAdd(const Slice& key,
33
33
  const Slice& value,
@@ -54,13 +54,12 @@ Status UserKeyTablePropertiesCollector::Finish(
54
54
  return collector_->Finish(properties);
55
55
  }
56
56
 
57
- UserCollectedProperties
58
- UserKeyTablePropertiesCollector::GetReadableProperties() const {
57
+ UserCollectedProperties UserKeyTablePropertiesCollector::GetReadableProperties()
58
+ const {
59
59
  return collector_->GetReadableProperties();
60
60
  }
61
61
 
62
- uint64_t GetDeletedKeys(
63
- const UserCollectedProperties& props) {
62
+ uint64_t GetDeletedKeys(const UserCollectedProperties& props) {
64
63
  bool property_present_ignored;
65
64
  return GetUint64Property(props, TablePropertiesNames::kDeletedKeys,
66
65
  &property_present_ignored);
@@ -68,8 +67,8 @@ uint64_t GetDeletedKeys(
68
67
 
69
68
  uint64_t GetMergeOperands(const UserCollectedProperties& props,
70
69
  bool* property_present) {
71
- return GetUint64Property(
72
- props, TablePropertiesNames::kMergeOperands, property_present);
70
+ return GetUint64Property(props, TablePropertiesNames::kMergeOperands,
71
+ property_present);
73
72
  }
74
73
 
75
74
  } // namespace ROCKSDB_NAMESPACE
@@ -61,30 +61,30 @@ void MakeBuilder(
61
61
  } // namespace
62
62
 
63
63
  // Collects keys that starts with "A" in a table.
64
- class RegularKeysStartWithA: public TablePropertiesCollector {
64
+ class RegularKeysStartWithA : public TablePropertiesCollector {
65
65
  public:
66
66
  const char* Name() const override { return "RegularKeysStartWithA"; }
67
67
 
68
68
  Status Finish(UserCollectedProperties* properties) override {
69
- std::string encoded;
70
- std::string encoded_num_puts;
71
- std::string encoded_num_deletes;
72
- std::string encoded_num_single_deletes;
73
- std::string encoded_num_size_changes;
74
- PutVarint32(&encoded, count_);
75
- PutVarint32(&encoded_num_puts, num_puts_);
76
- PutVarint32(&encoded_num_deletes, num_deletes_);
77
- PutVarint32(&encoded_num_single_deletes, num_single_deletes_);
78
- PutVarint32(&encoded_num_size_changes, num_size_changes_);
79
- *properties = UserCollectedProperties{
80
- {"TablePropertiesTest", message_},
81
- {"Count", encoded},
82
- {"NumPuts", encoded_num_puts},
83
- {"NumDeletes", encoded_num_deletes},
84
- {"NumSingleDeletes", encoded_num_single_deletes},
85
- {"NumSizeChanges", encoded_num_size_changes},
86
- };
87
- return Status::OK();
69
+ std::string encoded;
70
+ std::string encoded_num_puts;
71
+ std::string encoded_num_deletes;
72
+ std::string encoded_num_single_deletes;
73
+ std::string encoded_num_size_changes;
74
+ PutVarint32(&encoded, count_);
75
+ PutVarint32(&encoded_num_puts, num_puts_);
76
+ PutVarint32(&encoded_num_deletes, num_deletes_);
77
+ PutVarint32(&encoded_num_single_deletes, num_single_deletes_);
78
+ PutVarint32(&encoded_num_size_changes, num_size_changes_);
79
+ *properties = UserCollectedProperties{
80
+ {"TablePropertiesTest", message_},
81
+ {"Count", encoded},
82
+ {"NumPuts", encoded_num_puts},
83
+ {"NumDeletes", encoded_num_deletes},
84
+ {"NumSingleDeletes", encoded_num_single_deletes},
85
+ {"NumSizeChanges", encoded_num_size_changes},
86
+ };
87
+ return Status::OK();
88
88
  }
89
89
 
90
90
  Status AddUserKey(const Slice& user_key, const Slice& /*value*/,
@@ -338,7 +338,7 @@ void TestCustomizedTablePropertiesCollector(
338
338
  TEST_P(TablePropertiesTest, CustomizedTablePropertiesCollector) {
339
339
  // Test properties collectors with internal keys or regular keys
340
340
  // for block based table
341
- for (bool encode_as_internal : { true, false }) {
341
+ for (bool encode_as_internal : {true, false}) {
342
342
  Options options;
343
343
  BlockBasedTableOptions table_options;
344
344
  table_options.flush_block_policy_factory =
@@ -404,7 +404,7 @@ void TestInternalKeyPropertiesCollector(
404
404
  // HACK: Set options.info_log to avoid writing log in
405
405
  // SanitizeOptions().
406
406
  options.info_log = std::make_shared<test::NullLogger>();
407
- options = SanitizeOptions("db", // just a place holder
407
+ options = SanitizeOptions("db", // just a place holder
408
408
  options);
409
409
  ImmutableOptions ioptions(options);
410
410
  GetIntTblPropCollectorFactory(ioptions, &int_tbl_prop_collector_factories);
@@ -41,7 +41,7 @@ TransactionLogIteratorImpl::TransactionLogIteratorImpl(
41
41
  current_status_.PermitUncheckedError(); // Clear on start
42
42
  reporter_.env = options_->env;
43
43
  reporter_.info_log = options_->info_log.get();
44
- SeekToStartSequence(); // Seek till starting sequence
44
+ SeekToStartSequence(); // Seek till starting sequence
45
45
  }
46
46
 
47
47
  Status TransactionLogIteratorImpl::OpenLogFile(
@@ -62,8 +62,7 @@ Status TransactionLogIteratorImpl::OpenLogFile(
62
62
  // If cannot open file in DB directory.
63
63
  // Try the archive dir, as it could have moved in the meanwhile.
64
64
  fname = ArchivedLogFileName(dir_, log_file->LogNumber());
65
- s = fs->NewSequentialFile(fname, optimized_env_options,
66
- &file, nullptr);
65
+ s = fs->NewSequentialFile(fname, optimized_env_options, &file, nullptr);
67
66
  }
68
67
  }
69
68
  if (s.ok()) {
@@ -74,7 +73,7 @@ Status TransactionLogIteratorImpl::OpenLogFile(
74
73
  return s;
75
74
  }
76
75
 
77
- BatchResult TransactionLogIteratorImpl::GetBatch() {
76
+ BatchResult TransactionLogIteratorImpl::GetBatch() {
78
77
  assert(is_valid_); // cannot call in a non valid state.
79
78
  BatchResult result;
80
79
  result.sequence = current_batch_seq_;
@@ -124,8 +123,8 @@ void TransactionLogIteratorImpl::SeekToStartSequence(uint64_t start_file_index,
124
123
  }
125
124
  while (RestrictedRead(&record)) {
126
125
  if (record.size() < WriteBatchInternal::kHeader) {
127
- reporter_.Corruption(
128
- record.size(), Status::Corruption("very small log record"));
126
+ reporter_.Corruption(record.size(),
127
+ Status::Corruption("very small log record"));
129
128
  continue;
130
129
  }
131
130
  UpdateCurrentWriteBatch(record);
@@ -137,11 +136,12 @@ void TransactionLogIteratorImpl::SeekToStartSequence(uint64_t start_file_index,
137
136
  reporter_.Info(current_status_.ToString().c_str());
138
137
  return;
139
138
  } else if (strict) {
140
- reporter_.Info("Could seek required sequence number. Iterator will "
141
- "continue.");
139
+ reporter_.Info(
140
+ "Could seek required sequence number. Iterator will "
141
+ "continue.");
142
142
  }
143
143
  is_valid_ = true;
144
- started_ = true; // set started_ as we could seek till starting sequence
144
+ started_ = true; // set started_ as we could seek till starting sequence
145
145
  return;
146
146
  } else {
147
147
  is_valid_ = false;
@@ -182,15 +182,15 @@ void TransactionLogIteratorImpl::NextImpl(bool internal) {
182
182
  // Runs every time until we can seek to the start sequence
183
183
  SeekToStartSequence();
184
184
  }
185
- while(true) {
185
+ while (true) {
186
186
  assert(current_log_reader_);
187
187
  if (current_log_reader_->IsEOF()) {
188
188
  current_log_reader_->UnmarkEOF();
189
189
  }
190
190
  while (RestrictedRead(&record)) {
191
191
  if (record.size() < WriteBatchInternal::kHeader) {
192
- reporter_.Corruption(
193
- record.size(), Status::Corruption("very small log record"));
192
+ reporter_.Corruption(record.size(),
193
+ Status::Corruption("very small log record"));
194
194
  continue;
195
195
  } else {
196
196
  // started_ should be true if called by application
@@ -23,12 +23,11 @@ namespace ROCKSDB_NAMESPACE {
23
23
  class LogFileImpl : public LogFile {
24
24
  public:
25
25
  LogFileImpl(uint64_t logNum, WalFileType logType, SequenceNumber startSeq,
26
- uint64_t sizeBytes) :
27
- logNumber_(logNum),
28
- type_(logType),
29
- startSequence_(startSeq),
30
- sizeFileBytes_(sizeBytes) {
31
- }
26
+ uint64_t sizeBytes)
27
+ : logNumber_(logNum),
28
+ type_(logType),
29
+ startSequence_(startSeq),
30
+ sizeFileBytes_(sizeBytes) {}
32
31
 
33
32
  std::string PathName() const override {
34
33
  if (type_ == kArchivedLogFile) {
@@ -45,7 +44,7 @@ class LogFileImpl : public LogFile {
45
44
 
46
45
  uint64_t SizeFileBytes() const override { return sizeFileBytes_; }
47
46
 
48
- bool operator < (const LogFile& that) const {
47
+ bool operator<(const LogFile& that) const {
49
48
  return LogNumber() < that.LogNumber();
50
49
  }
51
50
 
@@ -54,7 +53,6 @@ class LogFileImpl : public LogFile {
54
53
  WalFileType type_;
55
54
  SequenceNumber startSequence_;
56
55
  uint64_t sizeFileBytes_;
57
-
58
56
  };
59
57
 
60
58
  class TransactionLogIteratorImpl : public TransactionLogIterator {
@@ -6,8 +6,10 @@
6
6
  #pragma once
7
7
 
8
8
  #include <stdint.h>
9
+
9
10
  #include <atomic>
10
11
  #include <mutex>
12
+
11
13
  #include "util/autovector.h"
12
14
 
13
15
  namespace ROCKSDB_NAMESPACE {
@@ -1656,10 +1656,10 @@ TEST_F(VersionBuilderTest, CheckConsistencyForFileDeletedTwice) {
1656
1656
  UpdateVersionStorageInfo(&new_vstorage);
1657
1657
 
1658
1658
  VersionBuilder version_builder2(env_options, &ioptions_, table_cache,
1659
- &new_vstorage, version_set);
1659
+ &new_vstorage, version_set);
1660
1660
  VersionStorageInfo new_vstorage2(&icmp_, ucmp_, options_.num_levels,
1661
- kCompactionStyleLevel, nullptr,
1662
- true /* force_consistency_checks */);
1661
+ kCompactionStyleLevel, nullptr,
1662
+ true /* force_consistency_checks */);
1663
1663
  ASSERT_NOK(version_builder2.Apply(&version_edit));
1664
1664
 
1665
1665
  UnrefFilesInVersion(&new_vstorage);
@@ -20,9 +20,7 @@
20
20
 
21
21
  namespace ROCKSDB_NAMESPACE {
22
22
 
23
- namespace {
24
-
25
- } // anonymous namespace
23
+ namespace {} // anonymous namespace
26
24
 
27
25
  uint64_t PackFileNumberAndPathId(uint64_t number, uint64_t path_id) {
28
26
  assert(number <= kFileNumberMask);
@@ -501,8 +499,7 @@ Status VersionEdit::DecodeFrom(const Slice& src) {
501
499
  break;
502
500
 
503
501
  case kCompactCursor:
504
- if (GetLevel(&input, &level, &msg) &&
505
- GetInternalKey(&input, &key)) {
502
+ if (GetLevel(&input, &level, &msg) && GetInternalKey(&input, &key)) {
506
503
  // Here we re-use the output format of compact pointer in LevelDB
507
504
  // to persist compact_cursors_
508
505
  compact_cursors_.push_back(std::make_pair(level, key));
@@ -114,7 +114,7 @@ struct FileDescriptor {
114
114
  // Table reader in table_reader_handle
115
115
  TableReader* table_reader;
116
116
  uint64_t packed_number_and_path_id;
117
- uint64_t file_size; // File size in bytes
117
+ uint64_t file_size; // File size in bytes
118
118
  SequenceNumber smallest_seqno; // The smallest seqno in this file
119
119
  SequenceNumber largest_seqno; // The largest seqno in this file
120
120
 
@@ -146,8 +146,8 @@ struct FileDescriptor {
146
146
  return packed_number_and_path_id & kFileNumberMask;
147
147
  }
148
148
  uint32_t GetPathId() const {
149
- return static_cast<uint32_t>(
150
- packed_number_and_path_id / (kFileNumberMask + 1));
149
+ return static_cast<uint32_t>(packed_number_and_path_id /
150
+ (kFileNumberMask + 1));
151
151
  }
152
152
  uint64_t GetFileSize() const { return file_size; }
153
153
  };
@@ -166,8 +166,8 @@ struct FileSampledStats {
166
166
 
167
167
  struct FileMetaData {
168
168
  FileDescriptor fd;
169
- InternalKey smallest; // Smallest internal key served by table
170
- InternalKey largest; // Largest internal key served by table
169
+ InternalKey smallest; // Smallest internal key served by table
170
+ InternalKey largest; // Largest internal key served by table
171
171
 
172
172
  // Needs to be disposed when refs becomes 0.
173
173
  Cache::Handle* table_reader_handle = nullptr;
@@ -312,15 +312,11 @@ struct FileMetaData {
312
312
  struct FdWithKeyRange {
313
313
  FileDescriptor fd;
314
314
  FileMetaData* file_metadata; // Point to all metadata
315
- Slice smallest_key; // slice that contain smallest key
316
- Slice largest_key; // slice that contain largest key
315
+ Slice smallest_key; // slice that contain smallest key
316
+ Slice largest_key; // slice that contain largest key
317
317
 
318
318
  FdWithKeyRange()
319
- : fd(),
320
- file_metadata(nullptr),
321
- smallest_key(),
322
- largest_key() {
323
- }
319
+ : fd(), file_metadata(nullptr), smallest_key(), largest_key() {}
324
320
 
325
321
  FdWithKeyRange(FileDescriptor _fd, Slice _smallest_key, Slice _largest_key,
326
322
  FileMetaData* _file_metadata)