Apply modernize-use-override (2nd iteration)

Summary:
Use C++11’s override and remove virtual where applicable.
Change are automatically generated.

Reviewed By: Orvid

Differential Revision: D14090024

fbshipit-source-id: 1e9432e87d2657e1ff0028e15370a85d1739ba2a
main
Michael Liu 6 years ago committed by Facebook Github Bot
parent c8c8104d7e
commit ca89ac2ba9
  1. 3
      cache/cache_test.cc
  2. 49
      cache/clock_cache.cc
  3. 2
      cache/lru_cache_test.cc
  4. 82
      db/c.cc
  5. 2
      db/column_family_test.cc
  6. 12
      db/compact_files_test.cc
  7. 50
      db/compaction_iterator_test.cc
  8. 6
      db/compaction_job_stats_test.cc
  9. 7
      db/compaction_picker_test.cc
  10. 52
      db/comparator_db_test.cc
  11. 6
      db/corruption_test.cc
  12. 2
      db/cuckoo_table_db_test.cc
  13. 15
      db/db_basic_test.cc
  14. 6
      db/db_block_cache_test.cc
  15. 6
      db/db_bloom_filter_test.cc
  16. 93
      db/db_compaction_filter_test.cc
  17. 23
      db/db_compaction_test.cc
  18. 2
      db/db_impl_open.cc
  19. 26
      db/db_iter.cc
  20. 24
      db/db_iter_test.cc
  21. 3
      db/db_iterator_test.cc
  22. 10
      db/db_log_iter_test.cc
  23. 47
      db/db_memtable_test.cc
  24. 6
      db/db_merge_operator_test.cc
  25. 6
      db/db_properties_test.cc
  26. 6
      db/db_range_del_test.cc
  27. 4
      db/db_sst_test.cc
  28. 260
      db/db_test.cc
  29. 90
      db/db_test2.cc
  30. 26
      db/db_universal_compaction_test.cc
  31. 4
      db/external_sst_file_basic_test.cc
  32. 6
      db/external_sst_file_test.cc
  33. 2
      db/fault_injection_test.cc
  34. 2
      db/file_indexer_test.cc
  35. 2
      db/forward_iterator.cc
  36. 20
      db/listener_test.cc
  37. 8
      db/log_test.cc
  38. 10
      db/manual_compaction_test.cc
  39. 29
      db/memtable.cc
  40. 2
      db/memtable_list_test.cc
  41. 2
      db/merge_helper_test.cc
  42. 21
      db/merge_test.cc
  43. 6
      db/plain_table_db_test.cc
  44. 31
      db/prefix_test.cc
  45. 2
      db/repair.cc
  46. 14
      db/table_properties_collector_test.cc
  47. 94
      memtable/hash_linklist_rep.cc
  48. 68
      memtable/hash_skiplist_rep.cc
  49. 136
      memtable/skiplistrep.cc
  50. 36
      memtable/vectorrep.cc
  51. 10
      table/block_based_filter_block_test.cc
  52. 10
      table/block_based_table_builder.cc
  53. 34
      table/block_based_table_reader.cc
  54. 2
      table/cuckoo_table_reader.cc
  55. 3
      table/flush_block_policy.cc
  56. 21
      table/full_filter_block_test.cc
  57. 32
      table/iterator.cc
  58. 2
      table/merger_test.cc
  59. 31
      table/merging_iterator.cc
  60. 6
      table/partitioned_filter_block_test.cc
  61. 2
      table/plain_table_reader.cc
  62. 175
      table/table_test.cc
  63. 28
      table/two_level_iterator.cc
  64. 23
      tools/db_bench_tool.cc
  65. 31
      tools/ldb_cmd.cc
  66. 2
      tools/sst_dump_test.cc
  67. 2
      tools/trace_analyzer_test.cc
  68. 6
      util/auto_roll_logger_test.cc
  69. 22
      util/bloom.cc
  70. 8
      util/bloom_test.cc
  71. 28
      util/comparator.cc
  72. 2
      util/delete_scheduler_test.cc
  73. 2
      util/event_logger_test.cc
  74. 177
      util/file_reader_writer.cc
  75. 12
      util/file_reader_writer_test.cc
  76. 3
      util/filelock_test.cc
  77. 34
      util/slice.cc
  78. 2
      util/slice_transform_test.cc
  79. 14
      util/testutil.cc
  80. 17
      utilities/backupable/backupable_db.cc
  81. 92
      utilities/backupable/backupable_db_test.cc
  82. 15
      utilities/blob_db/blob_compaction_filter.cc
  83. 21
      utilities/blob_db/blob_db_impl.cc
  84. 10
      utilities/blob_db/blob_db_test.cc
  85. 8
      utilities/cassandra/cassandra_functional_test.cc
  86. 2
      utilities/checkpoint/checkpoint_test.cc
  87. 73
      utilities/env_timed.cc
  88. 20
      utilities/merge_operators/max.cc
  89. 37
      utilities/merge_operators/put.cc
  90. 10
      utilities/merge_operators/uint64add.cc
  91. 38
      utilities/options/options_util_test.cc
  92. 6
      utilities/persistent_cache/hash_table_test.cc
  93. 75
      utilities/simulator_cache/sim_cache.cc
  94. 2
      utilities/transactions/optimistic_transaction_test.cc
  95. 11
      utilities/transactions/pessimistic_transaction.cc
  96. 4
      utilities/transactions/transaction_db_mutex_impl.cc
  97. 10
      utilities/transactions/transaction_test.cc
  98. 2
      utilities/transactions/write_prepared_transaction_test.cc
  99. 4
      utilities/transactions/write_prepared_txn.cc
  100. 3
      utilities/transactions/write_prepared_txn_db.cc
  101. Some files were not shown because too many files have changed in this diff Show More

@ -73,8 +73,7 @@ class CacheTest : public testing::TestWithParam<std::string> {
current_ = this; current_ = this;
} }
~CacheTest() { ~CacheTest() override {}
}
std::shared_ptr<Cache> NewCache(size_t capacity) { std::shared_ptr<Cache> NewCache(size_t capacity) {
auto type = GetParam(); auto type = GetParam();

@ -240,32 +240,29 @@ class ClockCacheShard : public CacheShard {
typedef tbb::concurrent_hash_map<CacheKey, CacheHandle*, CacheKey> HashTable; typedef tbb::concurrent_hash_map<CacheKey, CacheHandle*, CacheKey> HashTable;
ClockCacheShard(); ClockCacheShard();
~ClockCacheShard(); ~ClockCacheShard() override;
// Interfaces // Interfaces
virtual void SetCapacity(size_t capacity) override; void SetCapacity(size_t capacity) override;
virtual void SetStrictCapacityLimit(bool strict_capacity_limit) override; void SetStrictCapacityLimit(bool strict_capacity_limit) override;
virtual Status Insert(const Slice& key, uint32_t hash, void* value, Status Insert(const Slice& key, uint32_t hash, void* value, size_t charge,
size_t charge, void (*deleter)(const Slice& key, void* value),
void (*deleter)(const Slice& key, void* value), Cache::Handle** handle, Cache::Priority priority) override;
Cache::Handle** handle, Cache::Handle* Lookup(const Slice& key, uint32_t hash) override;
Cache::Priority priority) override;
virtual Cache::Handle* Lookup(const Slice& key, uint32_t hash) override;
// If the entry in in cache, increase reference count and return true. // If the entry in in cache, increase reference count and return true.
// Return false otherwise. // Return false otherwise.
// //
// Not necessary to hold mutex_ before being called. // Not necessary to hold mutex_ before being called.
virtual bool Ref(Cache::Handle* handle) override; bool Ref(Cache::Handle* handle) override;
virtual bool Release(Cache::Handle* handle, bool Release(Cache::Handle* handle, bool force_erase = false) override;
bool force_erase = false) override; void Erase(const Slice& key, uint32_t hash) override;
virtual void Erase(const Slice& key, uint32_t hash) override;
bool EraseAndConfirm(const Slice& key, uint32_t hash, bool EraseAndConfirm(const Slice& key, uint32_t hash,
CleanupContext* context); CleanupContext* context);
virtual size_t GetUsage() const override; size_t GetUsage() const override;
virtual size_t GetPinnedUsage() const override; size_t GetPinnedUsage() const override;
virtual void EraseUnRefEntries() override; void EraseUnRefEntries() override;
virtual void ApplyToAllCacheEntries(void (*callback)(void*, size_t), void ApplyToAllCacheEntries(void (*callback)(void*, size_t),
bool thread_safe) override; bool thread_safe) override;
private: private:
static const uint32_t kInCacheBit = 1; static const uint32_t kInCacheBit = 1;
@ -685,31 +682,31 @@ class ClockCache : public ShardedCache {
SetStrictCapacityLimit(strict_capacity_limit); SetStrictCapacityLimit(strict_capacity_limit);
} }
virtual ~ClockCache() { delete[] shards_; } ~ClockCache() override { delete[] shards_; }
virtual const char* Name() const override { return "ClockCache"; } const char* Name() const override { return "ClockCache"; }
virtual CacheShard* GetShard(int shard) override { CacheShard* GetShard(int shard) override {
return reinterpret_cast<CacheShard*>(&shards_[shard]); return reinterpret_cast<CacheShard*>(&shards_[shard]);
} }
virtual const CacheShard* GetShard(int shard) const override { const CacheShard* GetShard(int shard) const override {
return reinterpret_cast<CacheShard*>(&shards_[shard]); return reinterpret_cast<CacheShard*>(&shards_[shard]);
} }
virtual void* Value(Handle* handle) override { void* Value(Handle* handle) override {
return reinterpret_cast<const CacheHandle*>(handle)->value; return reinterpret_cast<const CacheHandle*>(handle)->value;
} }
virtual size_t GetCharge(Handle* handle) const override { size_t GetCharge(Handle* handle) const override {
return reinterpret_cast<const CacheHandle*>(handle)->charge; return reinterpret_cast<const CacheHandle*>(handle)->charge;
} }
virtual uint32_t GetHash(Handle* handle) const override { uint32_t GetHash(Handle* handle) const override {
return reinterpret_cast<const CacheHandle*>(handle)->hash; return reinterpret_cast<const CacheHandle*>(handle)->hash;
} }
virtual void DisownData() override { shards_ = nullptr; } void DisownData() override { shards_ = nullptr; }
private: private:
ClockCacheShard* shards_; ClockCacheShard* shards_;

@ -15,7 +15,7 @@ namespace rocksdb {
class LRUCacheTest : public testing::Test { class LRUCacheTest : public testing::Test {
public: public:
LRUCacheTest() {} LRUCacheTest() {}
~LRUCacheTest() { DeleteCache(); } ~LRUCacheTest() override { DeleteCache(); }
void DeleteCache() { void DeleteCache() {
if (cache_ != nullptr) { if (cache_ != nullptr) {

@ -208,13 +208,10 @@ struct rocksdb_compactionfilter_t : public CompactionFilter {
const char* (*name_)(void*); const char* (*name_)(void*);
unsigned char ignore_snapshots_; unsigned char ignore_snapshots_;
virtual ~rocksdb_compactionfilter_t() { ~rocksdb_compactionfilter_t() override { (*destructor_)(state_); }
(*destructor_)(state_);
}
virtual bool Filter(int level, const Slice& key, const Slice& existing_value, bool Filter(int level, const Slice& key, const Slice& existing_value,
std::string* new_value, std::string* new_value, bool* value_changed) const override {
bool* value_changed) const override {
char* c_new_value = nullptr; char* c_new_value = nullptr;
size_t new_value_length = 0; size_t new_value_length = 0;
unsigned char c_value_changed = 0; unsigned char c_value_changed = 0;
@ -231,9 +228,9 @@ struct rocksdb_compactionfilter_t : public CompactionFilter {
return result; return result;
} }
virtual const char* Name() const override { return (*name_)(state_); } const char* Name() const override { return (*name_)(state_); }
virtual bool IgnoreSnapshots() const override { return ignore_snapshots_; } bool IgnoreSnapshots() const override { return ignore_snapshots_; }
}; };
struct rocksdb_compactionfilterfactory_t : public CompactionFilterFactory { struct rocksdb_compactionfilterfactory_t : public CompactionFilterFactory {
@ -243,9 +240,9 @@ struct rocksdb_compactionfilterfactory_t : public CompactionFilterFactory {
void*, rocksdb_compactionfiltercontext_t* context); void*, rocksdb_compactionfiltercontext_t* context);
const char* (*name_)(void*); const char* (*name_)(void*);
virtual ~rocksdb_compactionfilterfactory_t() { (*destructor_)(state_); } ~rocksdb_compactionfilterfactory_t() override { (*destructor_)(state_); }
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter( std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& context) override { const CompactionFilter::Context& context) override {
rocksdb_compactionfiltercontext_t ccontext; rocksdb_compactionfiltercontext_t ccontext;
ccontext.rep = context; ccontext.rep = context;
@ -253,7 +250,7 @@ struct rocksdb_compactionfilterfactory_t : public CompactionFilterFactory {
return std::unique_ptr<CompactionFilter>(cf); return std::unique_ptr<CompactionFilter>(cf);
} }
virtual const char* Name() const override { return (*name_)(state_); } const char* Name() const override { return (*name_)(state_); }
}; };
struct rocksdb_comparator_t : public Comparator { struct rocksdb_comparator_t : public Comparator {
@ -265,20 +262,17 @@ struct rocksdb_comparator_t : public Comparator {
const char* b, size_t blen); const char* b, size_t blen);
const char* (*name_)(void*); const char* (*name_)(void*);
virtual ~rocksdb_comparator_t() { ~rocksdb_comparator_t() override { (*destructor_)(state_); }
(*destructor_)(state_);
}
virtual int Compare(const Slice& a, const Slice& b) const override { int Compare(const Slice& a, const Slice& b) const override {
return (*compare_)(state_, a.data(), a.size(), b.data(), b.size()); return (*compare_)(state_, a.data(), a.size(), b.data(), b.size());
} }
virtual const char* Name() const override { return (*name_)(state_); } const char* Name() const override { return (*name_)(state_); }
// No-ops since the C binding does not support key shortening methods. // No-ops since the C binding does not support key shortening methods.
virtual void FindShortestSeparator(std::string*, void FindShortestSeparator(std::string*, const Slice&) const override {}
const Slice&) const override {} void FindShortSuccessor(std::string* /*key*/) const override {}
virtual void FindShortSuccessor(std::string* /*key*/) const override {}
}; };
struct rocksdb_filterpolicy_t : public FilterPolicy { struct rocksdb_filterpolicy_t : public FilterPolicy {
@ -298,14 +292,11 @@ struct rocksdb_filterpolicy_t : public FilterPolicy {
void*, void*,
const char* filter, size_t filter_length); const char* filter, size_t filter_length);
virtual ~rocksdb_filterpolicy_t() { ~rocksdb_filterpolicy_t() override { (*destructor_)(state_); }
(*destructor_)(state_);
}
virtual const char* Name() const override { return (*name_)(state_); } const char* Name() const override { return (*name_)(state_); }
virtual void CreateFilter(const Slice* keys, int n, void CreateFilter(const Slice* keys, int n, std::string* dst) const override {
std::string* dst) const override {
std::vector<const char*> key_pointers(n); std::vector<const char*> key_pointers(n);
std::vector<size_t> key_sizes(n); std::vector<size_t> key_sizes(n);
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
@ -323,8 +314,7 @@ struct rocksdb_filterpolicy_t : public FilterPolicy {
} }
} }
virtual bool KeyMayMatch(const Slice& key, bool KeyMayMatch(const Slice& key, const Slice& filter) const override {
const Slice& filter) const override {
return (*key_match_)(state_, key.data(), key.size(), return (*key_match_)(state_, key.data(), key.size(),
filter.data(), filter.size()); filter.data(), filter.size());
} }
@ -349,14 +339,12 @@ struct rocksdb_mergeoperator_t : public MergeOperator {
void*, void*,
const char* value, size_t value_length); const char* value, size_t value_length);
virtual ~rocksdb_mergeoperator_t() { ~rocksdb_mergeoperator_t() override { (*destructor_)(state_); }
(*destructor_)(state_);
}
virtual const char* Name() const override { return (*name_)(state_); } const char* Name() const override { return (*name_)(state_); }
virtual bool FullMergeV2(const MergeOperationInput& merge_in, bool FullMergeV2(const MergeOperationInput& merge_in,
MergeOperationOutput* merge_out) const override { MergeOperationOutput* merge_out) const override {
size_t n = merge_in.operand_list.size(); size_t n = merge_in.operand_list.size();
std::vector<const char*> operand_pointers(n); std::vector<const char*> operand_pointers(n);
std::vector<size_t> operand_sizes(n); std::vector<size_t> operand_sizes(n);
@ -390,10 +378,10 @@ struct rocksdb_mergeoperator_t : public MergeOperator {
return success; return success;
} }
virtual bool PartialMergeMulti(const Slice& key, bool PartialMergeMulti(const Slice& key,
const std::deque<Slice>& operand_list, const std::deque<Slice>& operand_list,
std::string* new_value, std::string* new_value,
Logger* /*logger*/) const override { Logger* /*logger*/) const override {
size_t operand_count = operand_list.size(); size_t operand_count = operand_list.size();
std::vector<const char*> operand_pointers(operand_count); std::vector<const char*> operand_pointers(operand_count);
std::vector<size_t> operand_sizes(operand_count); std::vector<size_t> operand_sizes(operand_count);
@ -444,23 +432,21 @@ struct rocksdb_slicetransform_t : public SliceTransform {
void*, void*,
const char* key, size_t length); const char* key, size_t length);
virtual ~rocksdb_slicetransform_t() { ~rocksdb_slicetransform_t() override { (*destructor_)(state_); }
(*destructor_)(state_);
}
virtual const char* Name() const override { return (*name_)(state_); } const char* Name() const override { return (*name_)(state_); }
virtual Slice Transform(const Slice& src) const override { Slice Transform(const Slice& src) const override {
size_t len; size_t len;
char* dst = (*transform_)(state_, src.data(), src.size(), &len); char* dst = (*transform_)(state_, src.data(), src.size(), &len);
return Slice(dst, len); return Slice(dst, len);
} }
virtual bool InDomain(const Slice& src) const override { bool InDomain(const Slice& src) const override {
return (*in_domain_)(state_, src.data(), src.size()); return (*in_domain_)(state_, src.data(), src.size());
} }
virtual bool InRange(const Slice& src) const override { bool InRange(const Slice& src) const override {
return (*in_range_)(state_, src.data(), src.size()); return (*in_range_)(state_, src.data(), src.size());
} }
}; };
@ -1495,10 +1481,10 @@ class H : public WriteBatch::Handler {
void* state_; void* state_;
void (*put_)(void*, const char* k, size_t klen, const char* v, size_t vlen); void (*put_)(void*, const char* k, size_t klen, const char* v, size_t vlen);
void (*deleted_)(void*, const char* k, size_t klen); void (*deleted_)(void*, const char* k, size_t klen);
virtual void Put(const Slice& key, const Slice& value) override { void Put(const Slice& key, const Slice& value) override {
(*put_)(state_, key.data(), key.size(), value.data(), value.size()); (*put_)(state_, key.data(), key.size(), value.data(), value.size());
} }
virtual void Delete(const Slice& key) override { void Delete(const Slice& key) override {
(*deleted_)(state_, key.data(), key.size()); (*deleted_)(state_, key.data(), key.size());
} }
}; };
@ -2966,7 +2952,7 @@ rocksdb_filterpolicy_t* rocksdb_filterpolicy_create_bloom_format(int bits_per_ke
// supplied C functions. // supplied C functions.
struct Wrapper : public rocksdb_filterpolicy_t { struct Wrapper : public rocksdb_filterpolicy_t {
const FilterPolicy* rep_; const FilterPolicy* rep_;
~Wrapper() { delete rep_; } ~Wrapper() override { delete rep_; }
const char* Name() const override { return rep_->Name(); } const char* Name() const override { return rep_->Name(); }
void CreateFilter(const Slice* keys, int n, void CreateFilter(const Slice* keys, int n,
std::string* dst) const override { std::string* dst) const override {
@ -3421,7 +3407,7 @@ void rocksdb_slicetransform_destroy(rocksdb_slicetransform_t* st) {
struct Wrapper : public rocksdb_slicetransform_t { struct Wrapper : public rocksdb_slicetransform_t {
const SliceTransform* rep_; const SliceTransform* rep_;
~Wrapper() { delete rep_; } ~Wrapper() override { delete rep_; }
const char* Name() const override { return rep_->Name(); } const char* Name() const override { return rep_->Name(); }
Slice Transform(const Slice& src) const override { Slice Transform(const Slice& src) const override {
return rep_->Transform(src); return rep_->Transform(src);

@ -69,7 +69,7 @@ class ColumnFamilyTestBase : public testing::Test {
DestroyDB(dbname_, Options(db_options_, column_family_options_)); DestroyDB(dbname_, Options(db_options_, column_family_options_));
} }
virtual ~ColumnFamilyTestBase() { ~ColumnFamilyTestBase() override {
std::vector<ColumnFamilyDescriptor> column_families; std::vector<ColumnFamilyDescriptor> column_families;
for (auto h : handles_) { for (auto h : handles_) {
ColumnFamilyDescriptor cfdescriptor; ColumnFamilyDescriptor cfdescriptor;

@ -35,9 +35,9 @@ class CompactFilesTest : public testing::Test {
class FlushedFileCollector : public EventListener { class FlushedFileCollector : public EventListener {
public: public:
FlushedFileCollector() {} FlushedFileCollector() {}
~FlushedFileCollector() {} ~FlushedFileCollector() override {}
virtual void OnFlushCompleted(DB* /*db*/, const FlushJobInfo& info) override { void OnFlushCompleted(DB* /*db*/, const FlushJobInfo& info) override {
std::lock_guard<std::mutex> lock(mutex_); std::lock_guard<std::mutex> lock(mutex_);
flushed_files_.push_back(info.file_path); flushed_files_.push_back(info.file_path);
} }
@ -256,9 +256,9 @@ TEST_F(CompactFilesTest, CapturingPendingFiles) {
TEST_F(CompactFilesTest, CompactionFilterWithGetSv) { TEST_F(CompactFilesTest, CompactionFilterWithGetSv) {
class FilterWithGet : public CompactionFilter { class FilterWithGet : public CompactionFilter {
public: public:
virtual bool Filter(int /*level*/, const Slice& /*key*/, bool Filter(int /*level*/, const Slice& /*key*/, const Slice& /*value*/,
const Slice& /*value*/, std::string* /*new_value*/, std::string* /*new_value*/,
bool* /*value_changed*/) const override { bool* /*value_changed*/) const override {
if (db_ == nullptr) { if (db_ == nullptr) {
return true; return true;
} }
@ -271,7 +271,7 @@ TEST_F(CompactFilesTest, CompactionFilterWithGetSv) {
db_ = db; db_ = db;
} }
virtual const char* Name() const override { return "FilterWithGet"; } const char* Name() const override { return "FilterWithGet"; }
private: private:
DB* db_; DB* db_;

@ -112,39 +112,39 @@ class LoggingForwardVectorIterator : public InternalIterator {
assert(keys_.size() == values_.size()); assert(keys_.size() == values_.size());
} }
virtual bool Valid() const override { return current_ < keys_.size(); } bool Valid() const override { return current_ < keys_.size(); }
virtual void SeekToFirst() override { void SeekToFirst() override {
log.emplace_back(Action::Type::SEEK_TO_FIRST); log.emplace_back(Action::Type::SEEK_TO_FIRST);
current_ = 0; current_ = 0;
} }
virtual void SeekToLast() override { assert(false); } void SeekToLast() override { assert(false); }
virtual void Seek(const Slice& target) override { void Seek(const Slice& target) override {
log.emplace_back(Action::Type::SEEK, target.ToString()); log.emplace_back(Action::Type::SEEK, target.ToString());
current_ = std::lower_bound(keys_.begin(), keys_.end(), target.ToString()) - current_ = std::lower_bound(keys_.begin(), keys_.end(), target.ToString()) -
keys_.begin(); keys_.begin();
} }
virtual void SeekForPrev(const Slice& /*target*/) override { assert(false); } void SeekForPrev(const Slice& /*target*/) override { assert(false); }
virtual void Next() override { void Next() override {
assert(Valid()); assert(Valid());
log.emplace_back(Action::Type::NEXT); log.emplace_back(Action::Type::NEXT);
current_++; current_++;
} }
virtual void Prev() override { assert(false); } void Prev() override { assert(false); }
virtual Slice key() const override { Slice key() const override {
assert(Valid()); assert(Valid());
return Slice(keys_[current_]); return Slice(keys_[current_]);
} }
virtual Slice value() const override { Slice value() const override {
assert(Valid()); assert(Valid());
return Slice(values_[current_]); return Slice(values_[current_]);
} }
virtual Status status() const override { return Status::OK(); } Status status() const override { return Status::OK(); }
std::vector<Action> log; std::vector<Action> log;
@ -158,22 +158,20 @@ class FakeCompaction : public CompactionIterator::CompactionProxy {
public: public:
FakeCompaction() = default; FakeCompaction() = default;
virtual int level(size_t /*compaction_input_level*/) const override { int level(size_t /*compaction_input_level*/) const override { return 0; }
return 0; bool KeyNotExistsBeyondOutputLevel(
}
virtual bool KeyNotExistsBeyondOutputLevel(
const Slice& /*user_key*/, const Slice& /*user_key*/,
std::vector<size_t>* /*level_ptrs*/) const override { std::vector<size_t>* /*level_ptrs*/) const override {
return is_bottommost_level || key_not_exists_beyond_output_level; return is_bottommost_level || key_not_exists_beyond_output_level;
} }
virtual bool bottommost_level() const override { return is_bottommost_level; } bool bottommost_level() const override { return is_bottommost_level; }
virtual int number_levels() const override { return 1; } int number_levels() const override { return 1; }
virtual Slice GetLargestUserKey() const override { Slice GetLargestUserKey() const override {
return "\xff\xff\xff\xff\xff\xff\xff\xff\xff"; return "\xff\xff\xff\xff\xff\xff\xff\xff\xff";
} }
virtual bool allow_ingest_behind() const override { return false; } bool allow_ingest_behind() const override { return false; }
virtual bool preserve_deletes() const override { return false; } bool preserve_deletes() const override { return false; }
bool key_not_exists_beyond_output_level = false; bool key_not_exists_beyond_output_level = false;
@ -377,10 +375,9 @@ TEST_P(CompactionIteratorTest, RangeDeletionWithSnapshots) {
TEST_P(CompactionIteratorTest, CompactionFilterSkipUntil) { TEST_P(CompactionIteratorTest, CompactionFilterSkipUntil) {
class Filter : public CompactionFilter { class Filter : public CompactionFilter {
virtual Decision FilterV2(int /*level*/, const Slice& key, ValueType t, Decision FilterV2(int /*level*/, const Slice& key, ValueType t,
const Slice& existing_value, const Slice& existing_value, std::string* /*new_value*/,
std::string* /*new_value*/, std::string* skip_until) const override {
std::string* skip_until) const override {
std::string k = key.ToString(); std::string k = key.ToString();
std::string v = existing_value.ToString(); std::string v = existing_value.ToString();
// See InitIterators() call below for the sequence of keys and their // See InitIterators() call below for the sequence of keys and their
@ -560,10 +557,9 @@ TEST_P(CompactionIteratorTest, ShuttingDownInMerge) {
TEST_P(CompactionIteratorTest, SingleMergeOperand) { TEST_P(CompactionIteratorTest, SingleMergeOperand) {
class Filter : public CompactionFilter { class Filter : public CompactionFilter {
virtual Decision FilterV2(int /*level*/, const Slice& key, ValueType t, Decision FilterV2(int /*level*/, const Slice& key, ValueType t,
const Slice& existing_value, const Slice& existing_value, std::string* /*new_value*/,
std::string* /*new_value*/, std::string* /*skip_until*/) const override {
std::string* /*skip_until*/) const override {
std::string k = key.ToString(); std::string k = key.ToString();
std::string v = existing_value.ToString(); std::string v = existing_value.ToString();

@ -113,7 +113,7 @@ class CompactionJobStatsTest : public testing::Test,
Reopen(options); Reopen(options);
} }
~CompactionJobStatsTest() { ~CompactionJobStatsTest() override {
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); rocksdb::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->LoadDependency({}); rocksdb::SyncPoint::GetInstance()->LoadDependency({});
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks();
@ -426,7 +426,7 @@ class CompactionJobStatsChecker : public EventListener {
// Once a compaction completed, this function will verify the returned // Once a compaction completed, this function will verify the returned
// CompactionJobInfo with the oldest CompactionJobInfo added earlier // CompactionJobInfo with the oldest CompactionJobInfo added earlier
// in "expected_stats_" which has not yet being used for verification. // in "expected_stats_" which has not yet being used for verification.
virtual void OnCompactionCompleted(DB* /*db*/, const CompactionJobInfo& ci) { void OnCompactionCompleted(DB* /*db*/, const CompactionJobInfo& ci) override {
if (verify_next_comp_io_stats_) { if (verify_next_comp_io_stats_) {
ASSERT_GT(ci.stats.file_write_nanos, 0); ASSERT_GT(ci.stats.file_write_nanos, 0);
ASSERT_GT(ci.stats.file_range_sync_nanos, 0); ASSERT_GT(ci.stats.file_range_sync_nanos, 0);
@ -523,7 +523,7 @@ class CompactionJobDeletionStatsChecker : public CompactionJobStatsChecker {
public: public:
// Verifies whether two CompactionJobStats match. // Verifies whether two CompactionJobStats match.
void Verify(const CompactionJobStats& current_stats, void Verify(const CompactionJobStats& current_stats,
const CompactionJobStats& stats) { const CompactionJobStats& stats) override {
ASSERT_EQ( ASSERT_EQ(
current_stats.num_input_deletion_records, current_stats.num_input_deletion_records,
stats.num_input_deletion_records); stats.num_input_deletion_records);

@ -22,9 +22,7 @@ namespace rocksdb {
class CountingLogger : public Logger { class CountingLogger : public Logger {
public: public:
using Logger::Logv; using Logger::Logv;
virtual void Logv(const char* /*format*/, va_list /*ap*/) override { void Logv(const char* /*format*/, va_list /*ap*/) override { log_count++; }
log_count++;
}
size_t log_count; size_t log_count;
}; };
@ -68,8 +66,7 @@ class CompactionPickerTest : public testing::Test {
std::numeric_limits<uint64_t>::max()); std::numeric_limits<uint64_t>::max());
} }
~CompactionPickerTest() { ~CompactionPickerTest() override {}
}
void NewVersionStorage(int num_levels, CompactionStyle style) { void NewVersionStorage(int num_levels, CompactionStyle style) {
DeleteVersionStorage(); DeleteVersionStorage();

@ -27,24 +27,24 @@ class KVIter : public Iterator {
public: public:
explicit KVIter(const stl_wrappers::KVMap* map) explicit KVIter(const stl_wrappers::KVMap* map)
: map_(map), iter_(map_->end()) {} : map_(map), iter_(map_->end()) {}
virtual bool Valid() const override { return iter_ != map_->end(); } bool Valid() const override { return iter_ != map_->end(); }
virtual void SeekToFirst() override { iter_ = map_->begin(); } void SeekToFirst() override { iter_ = map_->begin(); }
virtual void SeekToLast() override { void SeekToLast() override {
if (map_->empty()) { if (map_->empty()) {
iter_ = map_->end(); iter_ = map_->end();
} else { } else {
iter_ = map_->find(map_->rbegin()->first); iter_ = map_->find(map_->rbegin()->first);
} }
} }
virtual void Seek(const Slice& k) override { void Seek(const Slice& k) override {
iter_ = map_->lower_bound(k.ToString()); iter_ = map_->lower_bound(k.ToString());
} }
virtual void SeekForPrev(const Slice& k) override { void SeekForPrev(const Slice& k) override {
iter_ = map_->upper_bound(k.ToString()); iter_ = map_->upper_bound(k.ToString());
Prev(); Prev();
} }
virtual void Next() override { ++iter_; } void Next() override { ++iter_; }
virtual void Prev() override { void Prev() override {
if (iter_ == map_->begin()) { if (iter_ == map_->begin()) {
iter_ = map_->end(); iter_ = map_->end();
return; return;
@ -52,9 +52,9 @@ class KVIter : public Iterator {
--iter_; --iter_;
} }
virtual Slice key() const override { return iter_->first; } Slice key() const override { return iter_->first; }
virtual Slice value() const override { return iter_->second; } Slice value() const override { return iter_->second; }
virtual Status status() const override { return Status::OK(); } Status status() const override { return Status::OK(); }
private: private:
const stl_wrappers::KVMap* const map_; const stl_wrappers::KVMap* const map_;
@ -171,9 +171,9 @@ class DoubleComparator : public Comparator {
public: public:
DoubleComparator() {} DoubleComparator() {}
virtual const char* Name() const override { return "DoubleComparator"; } const char* Name() const override { return "DoubleComparator"; }
virtual int Compare(const Slice& a, const Slice& b) const override { int Compare(const Slice& a, const Slice& b) const override {
#ifndef CYGWIN #ifndef CYGWIN
double da = std::stod(a.ToString()); double da = std::stod(a.ToString());
double db = std::stod(b.ToString()); double db = std::stod(b.ToString());
@ -189,19 +189,19 @@ class DoubleComparator : public Comparator {
return -1; return -1;
} }
} }
virtual void FindShortestSeparator(std::string* /*start*/, void FindShortestSeparator(std::string* /*start*/,
const Slice& /*limit*/) const override {} const Slice& /*limit*/) const override {}
virtual void FindShortSuccessor(std::string* /*key*/) const override {} void FindShortSuccessor(std::string* /*key*/) const override {}
}; };
class HashComparator : public Comparator { class HashComparator : public Comparator {
public: public:
HashComparator() {} HashComparator() {}
virtual const char* Name() const override { return "HashComparator"; } const char* Name() const override { return "HashComparator"; }
virtual int Compare(const Slice& a, const Slice& b) const override { int Compare(const Slice& a, const Slice& b) const override {
uint32_t ha = Hash(a.data(), a.size(), 66); uint32_t ha = Hash(a.data(), a.size(), 66);
uint32_t hb = Hash(b.data(), b.size(), 66); uint32_t hb = Hash(b.data(), b.size(), 66);
if (ha == hb) { if (ha == hb) {
@ -212,19 +212,19 @@ class HashComparator : public Comparator {
return -1; return -1;
} }
} }
virtual void FindShortestSeparator(std::string* /*start*/, void FindShortestSeparator(std::string* /*start*/,
const Slice& /*limit*/) const override {} const Slice& /*limit*/) const override {}
virtual void FindShortSuccessor(std::string* /*key*/) const override {} void FindShortSuccessor(std::string* /*key*/) const override {}
}; };
class TwoStrComparator : public Comparator { class TwoStrComparator : public Comparator {
public: public:
TwoStrComparator() {} TwoStrComparator() {}
virtual const char* Name() const override { return "TwoStrComparator"; } const char* Name() const override { return "TwoStrComparator"; }
virtual int Compare(const Slice& a, const Slice& b) const override { int Compare(const Slice& a, const Slice& b) const override {
assert(a.size() >= 2); assert(a.size() >= 2);
assert(b.size() >= 2); assert(b.size() >= 2);
size_t size_a1 = static_cast<size_t>(a[0]); size_t size_a1 = static_cast<size_t>(a[0]);
@ -244,10 +244,10 @@ class TwoStrComparator : public Comparator {
} }
return a2.compare(b2); return a2.compare(b2);
} }
virtual void FindShortestSeparator(std::string* /*start*/, void FindShortestSeparator(std::string* /*start*/,
const Slice& /*limit*/) const override {} const Slice& /*limit*/) const override {}
virtual void FindShortSuccessor(std::string* /*key*/) const override {} void FindShortSuccessor(std::string* /*key*/) const override {}
}; };
} // namespace } // namespace
@ -272,7 +272,7 @@ class ComparatorDBTest
EXPECT_OK(DestroyDB(dbname_, last_options_)); EXPECT_OK(DestroyDB(dbname_, last_options_));
} }
~ComparatorDBTest() { ~ComparatorDBTest() override {
delete db_; delete db_;
EXPECT_OK(DestroyDB(dbname_, last_options_)); EXPECT_OK(DestroyDB(dbname_, last_options_));
comparator = BytewiseComparator(); comparator = BytewiseComparator();

@ -62,9 +62,9 @@ class CorruptionTest : public testing::Test {
options_.create_if_missing = false; options_.create_if_missing = false;
} }
~CorruptionTest() { ~CorruptionTest() override {
delete db_; delete db_;
DestroyDB(dbname_, Options()); DestroyDB(dbname_, Options());
} }
void CloseDb() { void CloseDb() {

@ -31,7 +31,7 @@ class CuckooTableDBTest : public testing::Test {
Reopen(); Reopen();
} }
~CuckooTableDBTest() { ~CuckooTableDBTest() override {
delete db_; delete db_;
EXPECT_OK(DestroyDB(dbname_, Options())); EXPECT_OK(DestroyDB(dbname_, Options()));
} }

@ -852,18 +852,17 @@ class TestEnv : public EnvWrapper {
public: public:
using Logger::Logv; using Logger::Logv;
TestLogger(TestEnv *env_ptr) : Logger() { env = env_ptr; } TestLogger(TestEnv *env_ptr) : Logger() { env = env_ptr; }
~TestLogger() { ~TestLogger() override {
if (!closed_) { if (!closed_) {
CloseHelper(); CloseHelper();
} }
} }
virtual void Logv(const char* /*format*/, va_list /*ap*/) override{}; void Logv(const char* /*format*/, va_list /*ap*/) override{};
protected: protected:
virtual Status CloseImpl() override { Status CloseImpl() override { return CloseHelper(); }
return CloseHelper();
} private:
private:
Status CloseHelper() { Status CloseHelper() {
env->CloseCountInc();; env->CloseCountInc();;
return Status::IOError(); return Status::IOError();
@ -875,8 +874,8 @@ class TestEnv : public EnvWrapper {
int GetCloseCount() { return close_count; } int GetCloseCount() { return close_count; }
virtual Status NewLogger(const std::string& /*fname*/, Status NewLogger(const std::string& /*fname*/,
std::shared_ptr<Logger>* result) { std::shared_ptr<Logger>* result) override {
result->reset(new TestLogger(this)); result->reset(new TestLogger(this));
return Status::OK(); return Status::OK();
} }

@ -395,9 +395,9 @@ class MockCache : public LRUCache {
false /*strict_capacity_limit*/, 0.0 /*high_pri_pool_ratio*/) { false /*strict_capacity_limit*/, 0.0 /*high_pri_pool_ratio*/) {
} }
virtual Status Insert(const Slice& key, void* value, size_t charge, Status Insert(const Slice& key, void* value, size_t charge,
void (*deleter)(const Slice& key, void* value), void (*deleter)(const Slice& key, void* value), Handle** handle,
Handle** handle, Priority priority) override { Priority priority) override {
if (priority == Priority::LOW) { if (priority == Priority::LOW) {
low_pri_insert_count++; low_pri_insert_count++;
} else { } else {

@ -32,7 +32,7 @@ class DBBloomFilterTestWithParam
public: public:
DBBloomFilterTestWithParam() : DBTestBase("/db_bloom_filter_tests") {} DBBloomFilterTestWithParam() : DBTestBase("/db_bloom_filter_tests") {}
~DBBloomFilterTestWithParam() {} ~DBBloomFilterTestWithParam() override {}
void SetUp() override { void SetUp() override {
use_block_based_filter_ = std::get<0>(GetParam()); use_block_based_filter_ = std::get<0>(GetParam());
@ -642,7 +642,7 @@ class WrappedBloom : public FilterPolicy {
explicit WrappedBloom(int bits_per_key) explicit WrappedBloom(int bits_per_key)
: filter_(NewBloomFilterPolicy(bits_per_key)), counter_(0) {} : filter_(NewBloomFilterPolicy(bits_per_key)), counter_(0) {}
~WrappedBloom() { delete filter_; } ~WrappedBloom() override { delete filter_; }
const char* Name() const override { return "WrappedRocksDbFilterPolicy"; } const char* Name() const override { return "WrappedRocksDbFilterPolicy"; }
@ -823,7 +823,7 @@ class BloomStatsTestWithParam
DestroyAndReopen(options_); DestroyAndReopen(options_);
} }
~BloomStatsTestWithParam() { ~BloomStatsTestWithParam() override {
get_perf_context()->Reset(); get_perf_context()->Reset();
Destroy(options_); Destroy(options_);
} }

@ -63,33 +63,33 @@ INSTANTIATE_TEST_CASE_P(DBTestCompactionFilterWithCompactOption,
class KeepFilter : public CompactionFilter { class KeepFilter : public CompactionFilter {
public: public:
virtual bool Filter(int /*level*/, const Slice& /*key*/, bool Filter(int /*level*/, const Slice& /*key*/, const Slice& /*value*/,
const Slice& /*value*/, std::string* /*new_value*/, std::string* /*new_value*/,
bool* /*value_changed*/) const override { bool* /*value_changed*/) const override {
cfilter_count++; cfilter_count++;
return false; return false;
} }
virtual const char* Name() const override { return "KeepFilter"; } const char* Name() const override { return "KeepFilter"; }
}; };
class DeleteFilter : public CompactionFilter { class DeleteFilter : public CompactionFilter {
public: public:
virtual bool Filter(int /*level*/, const Slice& /*key*/, bool Filter(int /*level*/, const Slice& /*key*/, const Slice& /*value*/,
const Slice& /*value*/, std::string* /*new_value*/, std::string* /*new_value*/,
bool* /*value_changed*/) const override { bool* /*value_changed*/) const override {
cfilter_count++; cfilter_count++;
return true; return true;
} }
virtual const char* Name() const override { return "DeleteFilter"; } const char* Name() const override { return "DeleteFilter"; }
}; };
class DeleteISFilter : public CompactionFilter { class DeleteISFilter : public CompactionFilter {
public: public:
virtual bool Filter(int /*level*/, const Slice& key, const Slice& /*value*/, bool Filter(int /*level*/, const Slice& key, const Slice& /*value*/,
std::string* /*new_value*/, std::string* /*new_value*/,
bool* /*value_changed*/) const override { bool* /*value_changed*/) const override {
cfilter_count++; cfilter_count++;
int i = std::stoi(key.ToString()); int i = std::stoi(key.ToString());
if (i > 5 && i <= 105) { if (i > 5 && i <= 105) {
@ -98,20 +98,18 @@ class DeleteISFilter : public CompactionFilter {
return false; return false;
} }
virtual bool IgnoreSnapshots() const override { return true; } bool IgnoreSnapshots() const override { return true; }
virtual const char* Name() const override { return "DeleteFilter"; } const char* Name() const override { return "DeleteFilter"; }
}; };
// Skip x if floor(x/10) is even, use range skips. Requires that keys are // Skip x if floor(x/10) is even, use range skips. Requires that keys are
// zero-padded to length 10. // zero-padded to length 10.
class SkipEvenFilter : public CompactionFilter { class SkipEvenFilter : public CompactionFilter {
public: public:
virtual Decision FilterV2(int /*level*/, const Slice& key, Decision FilterV2(int /*level*/, const Slice& key, ValueType /*value_type*/,
ValueType /*value_type*/, const Slice& /*existing_value*/, std::string* /*new_value*/,
const Slice& /*existing_value*/, std::string* skip_until) const override {
std::string* /*new_value*/,
std::string* skip_until) const override {
cfilter_count++; cfilter_count++;
int i = std::stoi(key.ToString()); int i = std::stoi(key.ToString());
if (i / 10 % 2 == 0) { if (i / 10 % 2 == 0) {
@ -124,22 +122,22 @@ class SkipEvenFilter : public CompactionFilter {
return Decision::kKeep; return Decision::kKeep;
} }
virtual bool IgnoreSnapshots() const override { return true; } bool IgnoreSnapshots() const override { return true; }
virtual const char* Name() const override { return "DeleteFilter"; } const char* Name() const override { return "DeleteFilter"; }
}; };
class DelayFilter : public CompactionFilter { class DelayFilter : public CompactionFilter {
public: public:
explicit DelayFilter(DBTestBase* d) : db_test(d) {} explicit DelayFilter(DBTestBase* d) : db_test(d) {}
virtual bool Filter(int /*level*/, const Slice& /*key*/, bool Filter(int /*level*/, const Slice& /*key*/, const Slice& /*value*/,
const Slice& /*value*/, std::string* /*new_value*/, std::string* /*new_value*/,
bool* /*value_changed*/) const override { bool* /*value_changed*/) const override {
db_test->env_->addon_time_.fetch_add(1000); db_test->env_->addon_time_.fetch_add(1000);
return true; return true;
} }
virtual const char* Name() const override { return "DelayFilter"; } const char* Name() const override { return "DelayFilter"; }
private: private:
DBTestBase* db_test; DBTestBase* db_test;
@ -149,13 +147,13 @@ class ConditionalFilter : public CompactionFilter {
public: public:
explicit ConditionalFilter(const std::string* filtered_value) explicit ConditionalFilter(const std::string* filtered_value)
: filtered_value_(filtered_value) {} : filtered_value_(filtered_value) {}
virtual bool Filter(int /*level*/, const Slice& /*key*/, const Slice& value, bool Filter(int /*level*/, const Slice& /*key*/, const Slice& value,
std::string* /*new_value*/, std::string* /*new_value*/,
bool* /*value_changed*/) const override { bool* /*value_changed*/) const override {
return value.ToString() == *filtered_value_; return value.ToString() == *filtered_value_;
} }
virtual const char* Name() const override { return "ConditionalFilter"; } const char* Name() const override { return "ConditionalFilter"; }
private: private:
const std::string* filtered_value_; const std::string* filtered_value_;
@ -165,16 +163,15 @@ class ChangeFilter : public CompactionFilter {
public: public:
explicit ChangeFilter() {} explicit ChangeFilter() {}
virtual bool Filter(int /*level*/, const Slice& /*key*/, bool Filter(int /*level*/, const Slice& /*key*/, const Slice& /*value*/,
const Slice& /*value*/, std::string* new_value, std::string* new_value, bool* value_changed) const override {
bool* value_changed) const override {
assert(new_value != nullptr); assert(new_value != nullptr);
*new_value = NEW_VALUE; *new_value = NEW_VALUE;
*value_changed = true; *value_changed = true;
return false; return false;
} }
virtual const char* Name() const override { return "ChangeFilter"; } const char* Name() const override { return "ChangeFilter"; }
}; };
class KeepFilterFactory : public CompactionFilterFactory { class KeepFilterFactory : public CompactionFilterFactory {
@ -185,7 +182,7 @@ class KeepFilterFactory : public CompactionFilterFactory {
check_context_cf_id_(check_context_cf_id), check_context_cf_id_(check_context_cf_id),
compaction_filter_created_(false) {} compaction_filter_created_(false) {}
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter( std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& context) override { const CompactionFilter::Context& context) override {
if (check_context_) { if (check_context_) {
EXPECT_EQ(expect_full_compaction_.load(), context.is_full_compaction); EXPECT_EQ(expect_full_compaction_.load(), context.is_full_compaction);
@ -200,7 +197,7 @@ class KeepFilterFactory : public CompactionFilterFactory {
bool compaction_filter_created() const { return compaction_filter_created_; } bool compaction_filter_created() const { return compaction_filter_created_; }
virtual const char* Name() const override { return "KeepFilterFactory"; } const char* Name() const override { return "KeepFilterFactory"; }
bool check_context_; bool check_context_;
bool check_context_cf_id_; bool check_context_cf_id_;
std::atomic_bool expect_full_compaction_; std::atomic_bool expect_full_compaction_;
@ -211,7 +208,7 @@ class KeepFilterFactory : public CompactionFilterFactory {
class DeleteFilterFactory : public CompactionFilterFactory { class DeleteFilterFactory : public CompactionFilterFactory {
public: public:
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter( std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& context) override { const CompactionFilter::Context& context) override {
if (context.is_manual_compaction) { if (context.is_manual_compaction) {
return std::unique_ptr<CompactionFilter>(new DeleteFilter()); return std::unique_ptr<CompactionFilter>(new DeleteFilter());
@ -220,13 +217,13 @@ class DeleteFilterFactory : public CompactionFilterFactory {
} }
} }
virtual const char* Name() const override { return "DeleteFilterFactory"; } const char* Name() const override { return "DeleteFilterFactory"; }
}; };
// Delete Filter Factory which ignores snapshots // Delete Filter Factory which ignores snapshots
class DeleteISFilterFactory : public CompactionFilterFactory { class DeleteISFilterFactory : public CompactionFilterFactory {
public: public:
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter( std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& context) override { const CompactionFilter::Context& context) override {
if (context.is_manual_compaction) { if (context.is_manual_compaction) {
return std::unique_ptr<CompactionFilter>(new DeleteISFilter()); return std::unique_ptr<CompactionFilter>(new DeleteISFilter());
@ -235,12 +232,12 @@ class DeleteISFilterFactory : public CompactionFilterFactory {
} }
} }
virtual const char* Name() const override { return "DeleteFilterFactory"; } const char* Name() const override { return "DeleteFilterFactory"; }
}; };
class SkipEvenFilterFactory : public CompactionFilterFactory { class SkipEvenFilterFactory : public CompactionFilterFactory {
public: public:
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter( std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& context) override { const CompactionFilter::Context& context) override {
if (context.is_manual_compaction) { if (context.is_manual_compaction) {
return std::unique_ptr<CompactionFilter>(new SkipEvenFilter()); return std::unique_ptr<CompactionFilter>(new SkipEvenFilter());
@ -249,18 +246,18 @@ class SkipEvenFilterFactory : public CompactionFilterFactory {
} }
} }
virtual const char* Name() const override { return "SkipEvenFilterFactory"; } const char* Name() const override { return "SkipEvenFilterFactory"; }
}; };
class DelayFilterFactory : public CompactionFilterFactory { class DelayFilterFactory : public CompactionFilterFactory {
public: public:
explicit DelayFilterFactory(DBTestBase* d) : db_test(d) {} explicit DelayFilterFactory(DBTestBase* d) : db_test(d) {}
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter( std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& /*context*/) override { const CompactionFilter::Context& /*context*/) override {
return std::unique_ptr<CompactionFilter>(new DelayFilter(db_test)); return std::unique_ptr<CompactionFilter>(new DelayFilter(db_test));
} }
virtual const char* Name() const override { return "DelayFilterFactory"; } const char* Name() const override { return "DelayFilterFactory"; }
private: private:
DBTestBase* db_test; DBTestBase* db_test;
@ -271,15 +268,13 @@ class ConditionalFilterFactory : public CompactionFilterFactory {
explicit ConditionalFilterFactory(const Slice& filtered_value) explicit ConditionalFilterFactory(const Slice& filtered_value)
: filtered_value_(filtered_value.ToString()) {} : filtered_value_(filtered_value.ToString()) {}
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter( std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& /*context*/) override { const CompactionFilter::Context& /*context*/) override {
return std::unique_ptr<CompactionFilter>( return std::unique_ptr<CompactionFilter>(
new ConditionalFilter(&filtered_value_)); new ConditionalFilter(&filtered_value_));
} }
virtual const char* Name() const override { const char* Name() const override { return "ConditionalFilterFactory"; }
return "ConditionalFilterFactory";
}
private: private:
std::string filtered_value_; std::string filtered_value_;
@ -289,12 +284,12 @@ class ChangeFilterFactory : public CompactionFilterFactory {
public: public:
explicit ChangeFilterFactory() {} explicit ChangeFilterFactory() {}
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter( std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& /*context*/) override { const CompactionFilter::Context& /*context*/) override {
return std::unique_ptr<CompactionFilter>(new ChangeFilter()); return std::unique_ptr<CompactionFilter>(new ChangeFilter());
} }
virtual const char* Name() const override { return "ChangeFilterFactory"; } const char* Name() const override { return "ChangeFilterFactory"; }
}; };
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
@ -845,7 +840,7 @@ class TestNotSupportedFilter : public CompactionFilter {
return true; return true;
} }
virtual const char* Name() const override { return "NotSupported"; } const char* Name() const override { return "NotSupported"; }
bool IgnoreSnapshots() const override { return false; } bool IgnoreSnapshots() const override { return false; }
}; };

@ -55,9 +55,9 @@ namespace {
class FlushedFileCollector : public EventListener { class FlushedFileCollector : public EventListener {
public: public:
FlushedFileCollector() {} FlushedFileCollector() {}
~FlushedFileCollector() {} ~FlushedFileCollector() override {}
virtual void OnFlushCompleted(DB* /*db*/, const FlushJobInfo& info) override { void OnFlushCompleted(DB* /*db*/, const FlushJobInfo& info) override {
std::lock_guard<std::mutex> lock(mutex_); std::lock_guard<std::mutex> lock(mutex_);
flushed_files_.push_back(info.file_path); flushed_files_.push_back(info.file_path);
} }
@ -87,24 +87,23 @@ public:
} }
} }
~CompactionStatsCollector() {} ~CompactionStatsCollector() override {}
virtual void OnCompactionCompleted(DB* /* db */, void OnCompactionCompleted(DB* /* db */,
const CompactionJobInfo& info) override { const CompactionJobInfo& info) override {
int k = static_cast<int>(info.compaction_reason); int k = static_cast<int>(info.compaction_reason);
int num_of_reasons = static_cast<int>(CompactionReason::kNumOfReasons); int num_of_reasons = static_cast<int>(CompactionReason::kNumOfReasons);
assert(k >= 0 && k < num_of_reasons); assert(k >= 0 && k < num_of_reasons);
compaction_completed_[k]++; compaction_completed_[k]++;
} }
virtual void OnExternalFileIngested(DB* /* db */, void OnExternalFileIngested(
const ExternalFileIngestionInfo& /* info */) override { DB* /* db */, const ExternalFileIngestionInfo& /* info */) override {
int k = static_cast<int>(CompactionReason::kExternalSstIngestion); int k = static_cast<int>(CompactionReason::kExternalSstIngestion);
compaction_completed_[k]++; compaction_completed_[k]++;
} }
virtual void OnFlushCompleted(DB* /* db */, void OnFlushCompleted(DB* /* db */, const FlushJobInfo& /* info */) override {
const FlushJobInfo& /* info */) override {
int k = static_cast<int>(CompactionReason::kFlush); int k = static_cast<int>(CompactionReason::kFlush);
compaction_completed_[k]++; compaction_completed_[k]++;
} }
@ -4187,14 +4186,14 @@ class NoopMergeOperator : public MergeOperator {
public: public:
NoopMergeOperator() {} NoopMergeOperator() {}
virtual bool FullMergeV2(const MergeOperationInput& /*merge_in*/, bool FullMergeV2(const MergeOperationInput& /*merge_in*/,
MergeOperationOutput* merge_out) const override { MergeOperationOutput* merge_out) const override {
std::string val("bar"); std::string val("bar");
merge_out->new_value = val; merge_out->new_value = val;
return true; return true;
} }
virtual const char* Name() const override { return "Noop"; } const char* Name() const override { return "Noop"; }
}; };
TEST_F(DBCompactionTest, PartialManualCompaction) { TEST_F(DBCompactionTest, PartialManualCompaction) {

@ -512,7 +512,7 @@ Status DBImpl::RecoverLogFiles(const std::vector<uint64_t>& log_numbers,
Logger* info_log; Logger* info_log;
const char* fname; const char* fname;
Status* status; // nullptr if immutable_db_options_.paranoid_checks==false Status* status; // nullptr if immutable_db_options_.paranoid_checks==false
virtual void Corruption(size_t bytes, const Status& s) override { void Corruption(size_t bytes, const Status& s) override {
ROCKS_LOG_WARN(info_log, "%s%s: dropping %d bytes; %s", ROCKS_LOG_WARN(info_log, "%s%s: dropping %d bytes; %s",
(this->status == nullptr ? "(ignoring error) " : ""), (this->status == nullptr ? "(ignoring error) " : ""),
fname, static_cast<int>(bytes), s.ToString().c_str()); fname, static_cast<int>(bytes), s.ToString().c_str());

@ -152,7 +152,7 @@ class DBIter final: public Iterator {
iter_->SetPinnedItersMgr(&pinned_iters_mgr_); iter_->SetPinnedItersMgr(&pinned_iters_mgr_);
} }
} }
virtual ~DBIter() { ~DBIter() override {
// Release pinned data if any // Release pinned data if any
if (pinned_iters_mgr_.PinningEnabled()) { if (pinned_iters_mgr_.PinningEnabled()) {
pinned_iters_mgr_.ReleasePinnedData(); pinned_iters_mgr_.ReleasePinnedData();
@ -175,17 +175,16 @@ class DBIter final: public Iterator {
return &range_del_agg_; return &range_del_agg_;
} }
virtual bool Valid() const override { return valid_; } bool Valid() const override { return valid_; }
virtual Slice key() const override { Slice key() const override {
assert(valid_); assert(valid_);
if(start_seqnum_ > 0) { if(start_seqnum_ > 0) {
return saved_key_.GetInternalKey(); return saved_key_.GetInternalKey();
} else { } else {
return saved_key_.GetUserKey(); return saved_key_.GetUserKey();
} }
} }
virtual Slice value() const override { Slice value() const override {
assert(valid_); assert(valid_);
if (current_entry_is_merged_) { if (current_entry_is_merged_) {
// If pinned_value_ is set then the result of merge operator is one of // If pinned_value_ is set then the result of merge operator is one of
@ -197,7 +196,7 @@ class DBIter final: public Iterator {
return iter_->value(); return iter_->value();
} }
} }
virtual Status status() const override { Status status() const override {
if (status_.ok()) { if (status_.ok()) {
return iter_->status(); return iter_->status();
} else { } else {
@ -210,8 +209,7 @@ class DBIter final: public Iterator {
return is_blob_; return is_blob_;
} }
virtual Status GetProperty(std::string prop_name, Status GetProperty(std::string prop_name, std::string* prop) override {
std::string* prop) override {
if (prop == nullptr) { if (prop == nullptr) {
return Status::InvalidArgument("prop is nullptr"); return Status::InvalidArgument("prop is nullptr");
} }
@ -232,12 +230,12 @@ class DBIter final: public Iterator {
return Status::InvalidArgument("Unidentified property."); return Status::InvalidArgument("Unidentified property.");
} }
virtual void Next() override; void Next() override;
virtual void Prev() override; void Prev() override;
virtual void Seek(const Slice& target) override; void Seek(const Slice& target) override;
virtual void SeekForPrev(const Slice& target) override; void SeekForPrev(const Slice& target) override;
virtual void SeekToFirst() override; void SeekToFirst() override;
virtual void SeekToLast() override; void SeekToLast() override;
Env* env() { return env_; } Env* env() { return env_; }
void set_sequence(uint64_t s) { sequence_ = s; } void set_sequence(uint64_t s) { sequence_ = s; }
void set_valid(bool v) { valid_ = v; } void set_valid(bool v) { valid_ = v; }

@ -116,12 +116,12 @@ class TestIterator : public InternalIterator {
// Number of operations done on this iterator since construction. // Number of operations done on this iterator since construction.
size_t steps() const { return steps_; } size_t steps() const { return steps_; }
virtual bool Valid() const override { bool Valid() const override {
assert(initialized_); assert(initialized_);
return valid_; return valid_;
} }
virtual void SeekToFirst() override { void SeekToFirst() override {
assert(initialized_); assert(initialized_);
++steps_; ++steps_;
DeleteCurrentIfNeeded(); DeleteCurrentIfNeeded();
@ -129,7 +129,7 @@ class TestIterator : public InternalIterator {
iter_ = 0; iter_ = 0;
} }
virtual void SeekToLast() override { void SeekToLast() override {
assert(initialized_); assert(initialized_);
++steps_; ++steps_;
DeleteCurrentIfNeeded(); DeleteCurrentIfNeeded();
@ -137,7 +137,7 @@ class TestIterator : public InternalIterator {
iter_ = data_.size() - 1; iter_ = data_.size() - 1;
} }
virtual void Seek(const Slice& target) override { void Seek(const Slice& target) override {
assert(initialized_); assert(initialized_);
SeekToFirst(); SeekToFirst();
++steps_; ++steps_;
@ -154,13 +154,13 @@ class TestIterator : public InternalIterator {
} }
} }
virtual void SeekForPrev(const Slice& target) override { void SeekForPrev(const Slice& target) override {
assert(initialized_); assert(initialized_);
DeleteCurrentIfNeeded(); DeleteCurrentIfNeeded();
SeekForPrevImpl(target, &cmp); SeekForPrevImpl(target, &cmp);
} }
virtual void Next() override { void Next() override {
assert(initialized_); assert(initialized_);
assert(valid_); assert(valid_);
assert(iter_ < data_.size()); assert(iter_ < data_.size());
@ -174,7 +174,7 @@ class TestIterator : public InternalIterator {
valid_ = iter_ < data_.size(); valid_ = iter_ < data_.size();
} }
virtual void Prev() override { void Prev() override {
assert(initialized_); assert(initialized_);
assert(valid_); assert(valid_);
assert(iter_ < data_.size()); assert(iter_ < data_.size());
@ -188,23 +188,23 @@ class TestIterator : public InternalIterator {
} }
} }
virtual Slice key() const override { Slice key() const override {
assert(initialized_); assert(initialized_);
return data_[iter_].first; return data_[iter_].first;
} }
virtual Slice value() const override { Slice value() const override {
assert(initialized_); assert(initialized_);
return data_[iter_].second; return data_[iter_].second;
} }
virtual Status status() const override { Status status() const override {
assert(initialized_); assert(initialized_);
return Status::OK(); return Status::OK();
} }
virtual bool IsKeyPinned() const override { return true; } bool IsKeyPinned() const override { return true; }
virtual bool IsValuePinned() const override { return true; } bool IsValuePinned() const override { return true; }
private: private:
bool initialized_; bool initialized_;

@ -50,13 +50,14 @@ class DBIteratorTest : public DBTestBase,
class FlushBlockEveryKeyPolicy : public FlushBlockPolicy { class FlushBlockEveryKeyPolicy : public FlushBlockPolicy {
public: public:
virtual bool Update(const Slice& /*key*/, const Slice& /*value*/) override { bool Update(const Slice& /*key*/, const Slice& /*value*/) override {
if (!start_) { if (!start_) {
start_ = true; start_ = true;
return false; return false;
} }
return true; return true;
} }
private: private:
bool start_ = false; bool start_ = false;
}; };

@ -249,22 +249,20 @@ TEST_F(DBTestXactLogIterator, TransactionLogIteratorBlobs) {
auto res = OpenTransactionLogIter(0)->GetBatch(); auto res = OpenTransactionLogIter(0)->GetBatch();
struct Handler : public WriteBatch::Handler { struct Handler : public WriteBatch::Handler {
std::string seen; std::string seen;
virtual Status PutCF(uint32_t cf, const Slice& key, Status PutCF(uint32_t cf, const Slice& key, const Slice& value) override {
const Slice& value) override {
seen += "Put(" + ToString(cf) + ", " + key.ToString() + ", " + seen += "Put(" + ToString(cf) + ", " + key.ToString() + ", " +
ToString(value.size()) + ")"; ToString(value.size()) + ")";
return Status::OK(); return Status::OK();
} }
virtual Status MergeCF(uint32_t cf, const Slice& key, Status MergeCF(uint32_t cf, const Slice& key, const Slice& value) override {
const Slice& value) override {
seen += "Merge(" + ToString(cf) + ", " + key.ToString() + ", " + seen += "Merge(" + ToString(cf) + ", " + key.ToString() + ", " +
ToString(value.size()) + ")"; ToString(value.size()) + ")";
return Status::OK(); return Status::OK();
} }
virtual void LogData(const Slice& blob) override { void LogData(const Slice& blob) override {
seen += "LogData(" + blob.ToString() + ")"; seen += "LogData(" + blob.ToString() + ")";
} }
virtual Status DeleteCF(uint32_t cf, const Slice& key) override { Status DeleteCF(uint32_t cf, const Slice& key) override {
seen += "Delete(" + ToString(cf) + ", " + key.ToString() + ")"; seen += "Delete(" + ToString(cf) + ", " + key.ToString() + ")";
return Status::OK(); return Status::OK();
} }

@ -25,13 +25,13 @@ class MockMemTableRep : public MemTableRep {
explicit MockMemTableRep(Allocator* allocator, MemTableRep* rep) explicit MockMemTableRep(Allocator* allocator, MemTableRep* rep)
: MemTableRep(allocator), rep_(rep), num_insert_with_hint_(0) {} : MemTableRep(allocator), rep_(rep), num_insert_with_hint_(0) {}
virtual KeyHandle Allocate(const size_t len, char** buf) override { KeyHandle Allocate(const size_t len, char** buf) override {
return rep_->Allocate(len, buf); return rep_->Allocate(len, buf);
} }
virtual void Insert(KeyHandle handle) override { rep_->Insert(handle); } void Insert(KeyHandle handle) override { rep_->Insert(handle); }
virtual void InsertWithHint(KeyHandle handle, void** hint) override { void InsertWithHint(KeyHandle handle, void** hint) override {
num_insert_with_hint_++; num_insert_with_hint_++;
EXPECT_NE(nullptr, hint); EXPECT_NE(nullptr, hint);
last_hint_in_ = *hint; last_hint_in_ = *hint;
@ -39,21 +39,18 @@ class MockMemTableRep : public MemTableRep {
last_hint_out_ = *hint; last_hint_out_ = *hint;
} }
virtual bool Contains(const char* key) const override { bool Contains(const char* key) const override { return rep_->Contains(key); }
return rep_->Contains(key);
}
virtual void Get(const LookupKey& k, void* callback_args, void Get(const LookupKey& k, void* callback_args,
bool (*callback_func)(void* arg, bool (*callback_func)(void* arg, const char* entry)) override {
const char* entry)) override {
rep_->Get(k, callback_args, callback_func); rep_->Get(k, callback_args, callback_func);
} }
virtual size_t ApproximateMemoryUsage() override { size_t ApproximateMemoryUsage() override {
return rep_->ApproximateMemoryUsage(); return rep_->ApproximateMemoryUsage();
} }
virtual Iterator* GetIterator(Arena* arena) override { Iterator* GetIterator(Arena* arena) override {
return rep_->GetIterator(arena); return rep_->GetIterator(arena);
} }
@ -70,10 +67,10 @@ class MockMemTableRep : public MemTableRep {
class MockMemTableRepFactory : public MemTableRepFactory { class MockMemTableRepFactory : public MemTableRepFactory {
public: public:
virtual MemTableRep* CreateMemTableRep(const MemTableRep::KeyComparator& cmp, MemTableRep* CreateMemTableRep(const MemTableRep::KeyComparator& cmp,
Allocator* allocator, Allocator* allocator,
const SliceTransform* transform, const SliceTransform* transform,
Logger* logger) override { Logger* logger) override {
SkipListFactory factory; SkipListFactory factory;
MemTableRep* skiplist_rep = MemTableRep* skiplist_rep =
factory.CreateMemTableRep(cmp, allocator, transform, logger); factory.CreateMemTableRep(cmp, allocator, transform, logger);
@ -81,16 +78,16 @@ class MockMemTableRepFactory : public MemTableRepFactory {
return mock_rep_; return mock_rep_;
} }
virtual MemTableRep* CreateMemTableRep(const MemTableRep::KeyComparator& cmp, MemTableRep* CreateMemTableRep(const MemTableRep::KeyComparator& cmp,
Allocator* allocator, Allocator* allocator,
const SliceTransform* transform, const SliceTransform* transform,
Logger* logger, Logger* logger,
uint32_t column_family_id) override { uint32_t column_family_id) override {
last_column_family_id_ = column_family_id; last_column_family_id_ = column_family_id;
return CreateMemTableRep(cmp, allocator, transform, logger); return CreateMemTableRep(cmp, allocator, transform, logger);
} }
virtual const char* Name() const override { return "MockMemTableRepFactory"; } const char* Name() const override { return "MockMemTableRepFactory"; }
MockMemTableRep* rep() { return mock_rep_; } MockMemTableRep* rep() { return mock_rep_; }
@ -106,9 +103,9 @@ class MockMemTableRepFactory : public MemTableRepFactory {
class TestPrefixExtractor : public SliceTransform { class TestPrefixExtractor : public SliceTransform {
public: public:
virtual const char* Name() const override { return "TestPrefixExtractor"; } const char* Name() const override { return "TestPrefixExtractor"; }
virtual Slice Transform(const Slice& key) const override { Slice Transform(const Slice& key) const override {
const char* p = separator(key); const char* p = separator(key);
if (p == nullptr) { if (p == nullptr) {
return Slice(); return Slice();
@ -116,11 +113,11 @@ class TestPrefixExtractor : public SliceTransform {
return Slice(key.data(), p - key.data() + 1); return Slice(key.data(), p - key.data() + 1);
} }
virtual bool InDomain(const Slice& key) const override { bool InDomain(const Slice& key) const override {
return separator(key) != nullptr; return separator(key) != nullptr;
} }
virtual bool InRange(const Slice& /*key*/) const override { return false; } bool InRange(const Slice& /*key*/) const override { return false; }
private: private:
const char* separator(const Slice& key) const { const char* separator(const Slice& key) const {

@ -340,15 +340,15 @@ class MergeOperatorHook : public MergeOperator {
explicit MergeOperatorHook(std::shared_ptr<MergeOperator> _merge_op) explicit MergeOperatorHook(std::shared_ptr<MergeOperator> _merge_op)
: merge_op_(_merge_op) {} : merge_op_(_merge_op) {}
virtual bool FullMergeV2(const MergeOperationInput& merge_in, bool FullMergeV2(const MergeOperationInput& merge_in,
MergeOperationOutput* merge_out) const override { MergeOperationOutput* merge_out) const override {
before_merge_(); before_merge_();
bool res = merge_op_->FullMergeV2(merge_in, merge_out); bool res = merge_op_->FullMergeV2(merge_in, merge_out);
after_merge_(); after_merge_();
return res; return res;
} }
virtual const char* Name() const override { return merge_op_->Name(); } const char* Name() const override { return merge_op_->Name(); }
std::shared_ptr<MergeOperator> merge_op_; std::shared_ptr<MergeOperator> merge_op_;
std::function<void()> before_merge_ = []() {}; std::function<void()> before_merge_ = []() {};

@ -1094,7 +1094,7 @@ class CountingUserTblPropCollector : public TablePropertiesCollector {
return Status::OK(); return Status::OK();
} }
virtual UserCollectedProperties GetReadableProperties() const override { UserCollectedProperties GetReadableProperties() const override {
return UserCollectedProperties{}; return UserCollectedProperties{};
} }
@ -1110,7 +1110,7 @@ class CountingUserTblPropCollectorFactory
uint32_t expected_column_family_id) uint32_t expected_column_family_id)
: expected_column_family_id_(expected_column_family_id), : expected_column_family_id_(expected_column_family_id),
num_created_(0) {} num_created_(0) {}
virtual TablePropertiesCollector* CreateTablePropertiesCollector( TablePropertiesCollector* CreateTablePropertiesCollector(
TablePropertiesCollectorFactory::Context context) override { TablePropertiesCollectorFactory::Context context) override {
EXPECT_EQ(expected_column_family_id_, context.column_family_id); EXPECT_EQ(expected_column_family_id_, context.column_family_id);
num_created_++; num_created_++;
@ -1158,7 +1158,7 @@ class CountingDeleteTabPropCollector : public TablePropertiesCollector {
class CountingDeleteTabPropCollectorFactory class CountingDeleteTabPropCollectorFactory
: public TablePropertiesCollectorFactory { : public TablePropertiesCollectorFactory {
public: public:
virtual TablePropertiesCollector* CreateTablePropertiesCollector( TablePropertiesCollector* CreateTablePropertiesCollector(
TablePropertiesCollectorFactory::Context /*context*/) override { TablePropertiesCollectorFactory::Context /*context*/) override {
return new CountingDeleteTabPropCollector(); return new CountingDeleteTabPropCollector();
} }

@ -1111,14 +1111,14 @@ class MockMergeOperator : public MergeOperator {
// Mock non-associative operator. Non-associativity is expressed by lack of // Mock non-associative operator. Non-associativity is expressed by lack of
// implementation for any `PartialMerge*` functions. // implementation for any `PartialMerge*` functions.
public: public:
virtual bool FullMergeV2(const MergeOperationInput& merge_in, bool FullMergeV2(const MergeOperationInput& merge_in,
MergeOperationOutput* merge_out) const override { MergeOperationOutput* merge_out) const override {
assert(merge_out != nullptr); assert(merge_out != nullptr);
merge_out->new_value = merge_in.operand_list.back().ToString(); merge_out->new_value = merge_in.operand_list.back().ToString();
return true; return true;
} }
virtual const char* Name() const override { return "MockMergeOperator"; } const char* Name() const override { return "MockMergeOperator"; }
}; };
TEST_F(DBRangeDelTest, KeyAtOverlappingEndpointReappears) { TEST_F(DBRangeDelTest, KeyAtOverlappingEndpointReappears) {

@ -25,9 +25,9 @@ class DBSSTTest : public DBTestBase {
class FlushedFileCollector : public EventListener { class FlushedFileCollector : public EventListener {
public: public:
FlushedFileCollector() {} FlushedFileCollector() {}
~FlushedFileCollector() {} ~FlushedFileCollector() override {}
virtual void OnFlushCompleted(DB* /*db*/, const FlushJobInfo& info) override { void OnFlushCompleted(DB* /*db*/, const FlushJobInfo& info) override {
std::lock_guard<std::mutex> lock(mutex_); std::lock_guard<std::mutex> lock(mutex_);
flushed_files_.push_back(info.file_path); flushed_files_.push_back(info.file_path);
} }

@ -940,13 +940,13 @@ TEST_F(DBTest, FlushSchedule) {
namespace { namespace {
class KeepFilter : public CompactionFilter { class KeepFilter : public CompactionFilter {
public: public:
virtual bool Filter(int /*level*/, const Slice& /*key*/, bool Filter(int /*level*/, const Slice& /*key*/, const Slice& /*value*/,
const Slice& /*value*/, std::string* /*new_value*/, std::string* /*new_value*/,
bool* /*value_changed*/) const override { bool* /*value_changed*/) const override {
return false; return false;
} }
virtual const char* Name() const override { return "KeepFilter"; } const char* Name() const override { return "KeepFilter"; }
}; };
class KeepFilterFactory : public CompactionFilterFactory { class KeepFilterFactory : public CompactionFilterFactory {
@ -954,7 +954,7 @@ class KeepFilterFactory : public CompactionFilterFactory {
explicit KeepFilterFactory(bool check_context = false) explicit KeepFilterFactory(bool check_context = false)
: check_context_(check_context) {} : check_context_(check_context) {}
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter( std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& context) override { const CompactionFilter::Context& context) override {
if (check_context_) { if (check_context_) {
EXPECT_EQ(expect_full_compaction_.load(), context.is_full_compaction); EXPECT_EQ(expect_full_compaction_.load(), context.is_full_compaction);
@ -963,7 +963,7 @@ class KeepFilterFactory : public CompactionFilterFactory {
return std::unique_ptr<CompactionFilter>(new KeepFilter()); return std::unique_ptr<CompactionFilter>(new KeepFilter());
} }
virtual const char* Name() const override { return "KeepFilterFactory"; } const char* Name() const override { return "KeepFilterFactory"; }
bool check_context_; bool check_context_;
std::atomic_bool expect_full_compaction_; std::atomic_bool expect_full_compaction_;
std::atomic_bool expect_manual_compaction_; std::atomic_bool expect_manual_compaction_;
@ -972,14 +972,14 @@ class KeepFilterFactory : public CompactionFilterFactory {
class DelayFilter : public CompactionFilter { class DelayFilter : public CompactionFilter {
public: public:
explicit DelayFilter(DBTestBase* d) : db_test(d) {} explicit DelayFilter(DBTestBase* d) : db_test(d) {}
virtual bool Filter(int /*level*/, const Slice& /*key*/, bool Filter(int /*level*/, const Slice& /*key*/, const Slice& /*value*/,
const Slice& /*value*/, std::string* /*new_value*/, std::string* /*new_value*/,
bool* /*value_changed*/) const override { bool* /*value_changed*/) const override {
db_test->env_->addon_time_.fetch_add(1000); db_test->env_->addon_time_.fetch_add(1000);
return true; return true;
} }
virtual const char* Name() const override { return "DelayFilter"; } const char* Name() const override { return "DelayFilter"; }
private: private:
DBTestBase* db_test; DBTestBase* db_test;
@ -988,12 +988,12 @@ class DelayFilter : public CompactionFilter {
class DelayFilterFactory : public CompactionFilterFactory { class DelayFilterFactory : public CompactionFilterFactory {
public: public:
explicit DelayFilterFactory(DBTestBase* d) : db_test(d) {} explicit DelayFilterFactory(DBTestBase* d) : db_test(d) {}
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter( std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& /*context*/) override { const CompactionFilter::Context& /*context*/) override {
return std::unique_ptr<CompactionFilter>(new DelayFilter(db_test)); return std::unique_ptr<CompactionFilter>(new DelayFilter(db_test));
} }
virtual const char* Name() const override { return "DelayFilterFactory"; } const char* Name() const override { return "DelayFilterFactory"; }
private: private:
DBTestBase* db_test; DBTestBase* db_test;
@ -1775,17 +1775,14 @@ TEST_F(DBTest, OverlapInLevel0) {
TEST_F(DBTest, ComparatorCheck) { TEST_F(DBTest, ComparatorCheck) {
class NewComparator : public Comparator { class NewComparator : public Comparator {
public: public:
virtual const char* Name() const override { const char* Name() const override { return "rocksdb.NewComparator"; }
return "rocksdb.NewComparator"; int Compare(const Slice& a, const Slice& b) const override {
}
virtual int Compare(const Slice& a, const Slice& b) const override {
return BytewiseComparator()->Compare(a, b); return BytewiseComparator()->Compare(a, b);
} }
virtual void FindShortestSeparator(std::string* s, void FindShortestSeparator(std::string* s, const Slice& l) const override {
const Slice& l) const override {
BytewiseComparator()->FindShortestSeparator(s, l); BytewiseComparator()->FindShortestSeparator(s, l);
} }
virtual void FindShortSuccessor(std::string* key) const override { void FindShortSuccessor(std::string* key) const override {
BytewiseComparator()->FindShortSuccessor(key); BytewiseComparator()->FindShortSuccessor(key);
} }
}; };
@ -1808,18 +1805,15 @@ TEST_F(DBTest, ComparatorCheck) {
TEST_F(DBTest, CustomComparator) { TEST_F(DBTest, CustomComparator) {
class NumberComparator : public Comparator { class NumberComparator : public Comparator {
public: public:
virtual const char* Name() const override { const char* Name() const override { return "test.NumberComparator"; }
return "test.NumberComparator"; int Compare(const Slice& a, const Slice& b) const override {
}
virtual int Compare(const Slice& a, const Slice& b) const override {
return ToNumber(a) - ToNumber(b); return ToNumber(a) - ToNumber(b);
} }
virtual void FindShortestSeparator(std::string* s, void FindShortestSeparator(std::string* s, const Slice& l) const override {
const Slice& l) const override {
ToNumber(*s); // Check format ToNumber(*s); // Check format
ToNumber(l); // Check format ToNumber(l); // Check format
} }
virtual void FindShortSuccessor(std::string* key) const override { void FindShortSuccessor(std::string* key) const override {
ToNumber(*key); // Check format ToNumber(*key); // Check format
} }
@ -2253,7 +2247,7 @@ static void MTThreadBody(void* arg) {
class MultiThreadedDBTest : public DBTest, class MultiThreadedDBTest : public DBTest,
public ::testing::WithParamInterface<int> { public ::testing::WithParamInterface<int> {
public: public:
virtual void SetUp() override { option_config_ = GetParam(); } void SetUp() override { option_config_ = GetParam(); }
static std::vector<int> GenerateOptionConfigs() { static std::vector<int> GenerateOptionConfigs() {
std::vector<int> optionConfigs; std::vector<int> optionConfigs;
@ -2398,7 +2392,7 @@ class ModelDB : public DB {
public: public:
KVMap map_; KVMap map_;
virtual SequenceNumber GetSequenceNumber() const override { SequenceNumber GetSequenceNumber() const override {
// no need to call this // no need to call this
assert(false); assert(false);
return 0; return 0;
@ -2407,43 +2401,43 @@ class ModelDB : public DB {
explicit ModelDB(const Options& options) : options_(options) {} explicit ModelDB(const Options& options) : options_(options) {}
using DB::Put; using DB::Put;
virtual Status Put(const WriteOptions& o, ColumnFamilyHandle* cf, Status Put(const WriteOptions& o, ColumnFamilyHandle* cf, const Slice& k,
const Slice& k, const Slice& v) override { const Slice& v) override {
WriteBatch batch; WriteBatch batch;
batch.Put(cf, k, v); batch.Put(cf, k, v);
return Write(o, &batch); return Write(o, &batch);
} }
using DB::Close; using DB::Close;
virtual Status Close() override { return Status::OK(); } Status Close() override { return Status::OK(); }
using DB::Delete; using DB::Delete;
virtual Status Delete(const WriteOptions& o, ColumnFamilyHandle* cf, Status Delete(const WriteOptions& o, ColumnFamilyHandle* cf,
const Slice& key) override { const Slice& key) override {
WriteBatch batch; WriteBatch batch;
batch.Delete(cf, key); batch.Delete(cf, key);
return Write(o, &batch); return Write(o, &batch);
} }
using DB::SingleDelete; using DB::SingleDelete;
virtual Status SingleDelete(const WriteOptions& o, ColumnFamilyHandle* cf, Status SingleDelete(const WriteOptions& o, ColumnFamilyHandle* cf,
const Slice& key) override { const Slice& key) override {
WriteBatch batch; WriteBatch batch;
batch.SingleDelete(cf, key); batch.SingleDelete(cf, key);
return Write(o, &batch); return Write(o, &batch);
} }
using DB::Merge; using DB::Merge;
virtual Status Merge(const WriteOptions& o, ColumnFamilyHandle* cf, Status Merge(const WriteOptions& o, ColumnFamilyHandle* cf, const Slice& k,
const Slice& k, const Slice& v) override { const Slice& v) override {
WriteBatch batch; WriteBatch batch;
batch.Merge(cf, k, v); batch.Merge(cf, k, v);
return Write(o, &batch); return Write(o, &batch);
} }
using DB::Get; using DB::Get;
virtual Status Get(const ReadOptions& /*options*/, ColumnFamilyHandle* /*cf*/, Status Get(const ReadOptions& /*options*/, ColumnFamilyHandle* /*cf*/,
const Slice& key, PinnableSlice* /*value*/) override { const Slice& key, PinnableSlice* /*value*/) override {
return Status::NotSupported(key); return Status::NotSupported(key);
} }
using DB::MultiGet; using DB::MultiGet;
virtual std::vector<Status> MultiGet( std::vector<Status> MultiGet(
const ReadOptions& /*options*/, const ReadOptions& /*options*/,
const std::vector<ColumnFamilyHandle*>& /*column_family*/, const std::vector<ColumnFamilyHandle*>& /*column_family*/,
const std::vector<Slice>& keys, const std::vector<Slice>& keys,
@ -2455,7 +2449,7 @@ class ModelDB : public DB {
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
using DB::IngestExternalFile; using DB::IngestExternalFile;
virtual Status IngestExternalFile( Status IngestExternalFile(
ColumnFamilyHandle* /*column_family*/, ColumnFamilyHandle* /*column_family*/,
const std::vector<std::string>& /*external_files*/, const std::vector<std::string>& /*external_files*/,
const IngestExternalFileOptions& /*options*/) override { const IngestExternalFileOptions& /*options*/) override {
@ -2463,23 +2457,23 @@ class ModelDB : public DB {
} }
using DB::IngestExternalFiles; using DB::IngestExternalFiles;
virtual Status IngestExternalFiles( Status IngestExternalFiles(
const std::vector<IngestExternalFileArg>& /*args*/) override { const std::vector<IngestExternalFileArg>& /*args*/) override {
return Status::NotSupported("Not implemented"); return Status::NotSupported("Not implemented");
} }
virtual Status VerifyChecksum() override { Status VerifyChecksum() override {
return Status::NotSupported("Not implemented."); return Status::NotSupported("Not implemented.");
} }
using DB::GetPropertiesOfAllTables; using DB::GetPropertiesOfAllTables;
virtual Status GetPropertiesOfAllTables( Status GetPropertiesOfAllTables(
ColumnFamilyHandle* /*column_family*/, ColumnFamilyHandle* /*column_family*/,
TablePropertiesCollection* /*props*/) override { TablePropertiesCollection* /*props*/) override {
return Status(); return Status();
} }
virtual Status GetPropertiesOfTablesInRange( Status GetPropertiesOfTablesInRange(
ColumnFamilyHandle* /*column_family*/, const Range* /*range*/, ColumnFamilyHandle* /*column_family*/, const Range* /*range*/,
std::size_t /*n*/, TablePropertiesCollection* /*props*/) override { std::size_t /*n*/, TablePropertiesCollection* /*props*/) override {
return Status(); return Status();
@ -2487,19 +2481,18 @@ class ModelDB : public DB {
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE
using DB::KeyMayExist; using DB::KeyMayExist;
virtual bool KeyMayExist(const ReadOptions& /*options*/, bool KeyMayExist(const ReadOptions& /*options*/,
ColumnFamilyHandle* /*column_family*/, ColumnFamilyHandle* /*column_family*/, const Slice& /*key*/,
const Slice& /*key*/, std::string* /*value*/, std::string* /*value*/,
bool* value_found = nullptr) override { bool* value_found = nullptr) override {
if (value_found != nullptr) { if (value_found != nullptr) {
*value_found = false; *value_found = false;
} }
return true; // Not Supported directly return true; // Not Supported directly
} }
using DB::NewIterator; using DB::NewIterator;
virtual Iterator* NewIterator( Iterator* NewIterator(const ReadOptions& options,
const ReadOptions& options, ColumnFamilyHandle* /*column_family*/) override {
ColumnFamilyHandle* /*column_family*/) override {
if (options.snapshot == nullptr) { if (options.snapshot == nullptr) {
KVMap* saved = new KVMap; KVMap* saved = new KVMap;
*saved = map_; *saved = map_;
@ -2510,38 +2503,33 @@ class ModelDB : public DB {
return new ModelIter(snapshot_state, false); return new ModelIter(snapshot_state, false);
} }
} }
virtual Status NewIterators( Status NewIterators(const ReadOptions& /*options*/,
const ReadOptions& /*options*/, const std::vector<ColumnFamilyHandle*>& /*column_family*/,
const std::vector<ColumnFamilyHandle*>& /*column_family*/, std::vector<Iterator*>* /*iterators*/) override {
std::vector<Iterator*>* /*iterators*/) override {
return Status::NotSupported("Not supported yet"); return Status::NotSupported("Not supported yet");
} }
virtual const Snapshot* GetSnapshot() override { const Snapshot* GetSnapshot() override {
ModelSnapshot* snapshot = new ModelSnapshot; ModelSnapshot* snapshot = new ModelSnapshot;
snapshot->map_ = map_; snapshot->map_ = map_;
return snapshot; return snapshot;
} }
virtual void ReleaseSnapshot(const Snapshot* snapshot) override { void ReleaseSnapshot(const Snapshot* snapshot) override {
delete reinterpret_cast<const ModelSnapshot*>(snapshot); delete reinterpret_cast<const ModelSnapshot*>(snapshot);
} }
virtual Status Write(const WriteOptions& /*options*/, Status Write(const WriteOptions& /*options*/, WriteBatch* batch) override {
WriteBatch* batch) override {
class Handler : public WriteBatch::Handler { class Handler : public WriteBatch::Handler {
public: public:
KVMap* map_; KVMap* map_;
virtual void Put(const Slice& key, const Slice& value) override { void Put(const Slice& key, const Slice& value) override {
(*map_)[key.ToString()] = value.ToString(); (*map_)[key.ToString()] = value.ToString();
} }
virtual void Merge(const Slice& /*key*/, void Merge(const Slice& /*key*/, const Slice& /*value*/) override {
const Slice& /*value*/) override {
// ignore merge for now // ignore merge for now
// (*map_)[key.ToString()] = value.ToString(); // (*map_)[key.ToString()] = value.ToString();
} }
virtual void Delete(const Slice& key) override { void Delete(const Slice& key) override { map_->erase(key.ToString()); }
map_->erase(key.ToString());
}
}; };
Handler handler; Handler handler;
handler.map_ = &map_; handler.map_ = &map_;
@ -2549,61 +2537,58 @@ class ModelDB : public DB {
} }
using DB::GetProperty; using DB::GetProperty;
virtual bool GetProperty(ColumnFamilyHandle* /*column_family*/, bool GetProperty(ColumnFamilyHandle* /*column_family*/,
const Slice& /*property*/, const Slice& /*property*/, std::string* /*value*/) override {
std::string* /*value*/) override {
return false; return false;
} }
using DB::GetIntProperty; using DB::GetIntProperty;
virtual bool GetIntProperty(ColumnFamilyHandle* /*column_family*/, bool GetIntProperty(ColumnFamilyHandle* /*column_family*/,
const Slice& /*property*/, const Slice& /*property*/, uint64_t* /*value*/) override {
uint64_t* /*value*/) override {
return false; return false;
} }
using DB::GetMapProperty; using DB::GetMapProperty;
virtual bool GetMapProperty( bool GetMapProperty(ColumnFamilyHandle* /*column_family*/,
ColumnFamilyHandle* /*column_family*/, const Slice& /*property*/, const Slice& /*property*/,
std::map<std::string, std::string>* /*value*/) override { std::map<std::string, std::string>* /*value*/) override {
return false; return false;
} }
using DB::GetAggregatedIntProperty; using DB::GetAggregatedIntProperty;
virtual bool GetAggregatedIntProperty(const Slice& /*property*/, bool GetAggregatedIntProperty(const Slice& /*property*/,
uint64_t* /*value*/) override { uint64_t* /*value*/) override {
return false; return false;
} }
using DB::GetApproximateSizes; using DB::GetApproximateSizes;
virtual void GetApproximateSizes(ColumnFamilyHandle* /*column_family*/, void GetApproximateSizes(ColumnFamilyHandle* /*column_family*/,
const Range* /*range*/, int n, const Range* /*range*/, int n, uint64_t* sizes,
uint64_t* sizes, uint8_t /*include_flags*/
uint8_t /*include_flags*/ = INCLUDE_FILES) override {
= INCLUDE_FILES) override {
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
sizes[i] = 0; sizes[i] = 0;
} }
} }
using DB::GetApproximateMemTableStats; using DB::GetApproximateMemTableStats;
virtual void GetApproximateMemTableStats( void GetApproximateMemTableStats(ColumnFamilyHandle* /*column_family*/,
ColumnFamilyHandle* /*column_family*/, const Range& /*range*/, const Range& /*range*/,
uint64_t* const count, uint64_t* const size) override { uint64_t* const count,
uint64_t* const size) override {
*count = 0; *count = 0;
*size = 0; *size = 0;
} }
using DB::CompactRange; using DB::CompactRange;
virtual Status CompactRange(const CompactRangeOptions& /*options*/, Status CompactRange(const CompactRangeOptions& /*options*/,
ColumnFamilyHandle* /*column_family*/, ColumnFamilyHandle* /*column_family*/,
const Slice* /*start*/, const Slice* /*start*/, const Slice* /*end*/) override {
const Slice* /*end*/) override {
return Status::NotSupported("Not supported operation."); return Status::NotSupported("Not supported operation.");
} }
virtual Status SetDBOptions( Status SetDBOptions(
const std::unordered_map<std::string, std::string>& /*new_options*/) const std::unordered_map<std::string, std::string>& /*new_options*/)
override { override {
return Status::NotSupported("Not supported operation."); return Status::NotSupported("Not supported operation.");
} }
using DB::CompactFiles; using DB::CompactFiles;
virtual Status CompactFiles( Status CompactFiles(
const CompactionOptions& /*compact_options*/, const CompactionOptions& /*compact_options*/,
ColumnFamilyHandle* /*column_family*/, ColumnFamilyHandle* /*column_family*/,
const std::vector<std::string>& /*input_file_names*/, const std::vector<std::string>& /*input_file_names*/,
@ -2628,69 +2613,60 @@ class ModelDB : public DB {
} }
using DB::NumberLevels; using DB::NumberLevels;
virtual int NumberLevels(ColumnFamilyHandle* /*column_family*/) override { int NumberLevels(ColumnFamilyHandle* /*column_family*/) override { return 1; }
return 1;
}
using DB::MaxMemCompactionLevel; using DB::MaxMemCompactionLevel;
virtual int MaxMemCompactionLevel( int MaxMemCompactionLevel(ColumnFamilyHandle* /*column_family*/) override {
ColumnFamilyHandle* /*column_family*/) override {
return 1; return 1;
} }
using DB::Level0StopWriteTrigger; using DB::Level0StopWriteTrigger;
virtual int Level0StopWriteTrigger( int Level0StopWriteTrigger(ColumnFamilyHandle* /*column_family*/) override {
ColumnFamilyHandle* /*column_family*/) override {
return -1; return -1;
} }
virtual const std::string& GetName() const override { return name_; } const std::string& GetName() const override { return name_; }
virtual Env* GetEnv() const override { return nullptr; } Env* GetEnv() const override { return nullptr; }
using DB::GetOptions; using DB::GetOptions;
virtual Options GetOptions( Options GetOptions(ColumnFamilyHandle* /*column_family*/) const override {
ColumnFamilyHandle* /*column_family*/) const override {
return options_; return options_;
} }
using DB::GetDBOptions; using DB::GetDBOptions;
virtual DBOptions GetDBOptions() const override { return options_; } DBOptions GetDBOptions() const override { return options_; }
using DB::Flush; using DB::Flush;
virtual Status Flush(const rocksdb::FlushOptions& /*options*/, Status Flush(const rocksdb::FlushOptions& /*options*/,
ColumnFamilyHandle* /*column_family*/) override { ColumnFamilyHandle* /*column_family*/) override {
Status ret; Status ret;
return ret; return ret;
} }
virtual Status Flush( Status Flush(
const rocksdb::FlushOptions& /*options*/, const rocksdb::FlushOptions& /*options*/,
const std::vector<ColumnFamilyHandle*>& /*column_families*/) override { const std::vector<ColumnFamilyHandle*>& /*column_families*/) override {
return Status::OK(); return Status::OK();
} }
virtual Status SyncWAL() override { return Status::OK(); } Status SyncWAL() override { return Status::OK(); }
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
virtual Status DisableFileDeletions() override { return Status::OK(); } Status DisableFileDeletions() override { return Status::OK(); }
virtual Status EnableFileDeletions(bool /*force*/) override { Status EnableFileDeletions(bool /*force*/) override { return Status::OK(); }
return Status::OK(); Status GetLiveFiles(std::vector<std::string>&, uint64_t* /*size*/,
} bool /*flush_memtable*/ = true) override {
virtual Status GetLiveFiles(std::vector<std::string>&, uint64_t* /*size*/,
bool /*flush_memtable*/ = true) override {
return Status::OK(); return Status::OK();
} }
virtual Status GetSortedWalFiles(VectorLogPtr& /*files*/) override { Status GetSortedWalFiles(VectorLogPtr& /*files*/) override {
return Status::OK(); return Status::OK();
} }
virtual Status DeleteFile(std::string /*name*/) override { Status DeleteFile(std::string /*name*/) override { return Status::OK(); }
return Status::OK();
}
virtual Status GetUpdatesSince( Status GetUpdatesSince(
rocksdb::SequenceNumber, rocksdb::SequenceNumber,
std::unique_ptr<rocksdb::TransactionLogIterator>*, std::unique_ptr<rocksdb::TransactionLogIterator>*,
const TransactionLogIterator::ReadOptions& /*read_options*/ = const TransactionLogIterator::ReadOptions& /*read_options*/ =
@ -2698,52 +2674,48 @@ class ModelDB : public DB {
return Status::NotSupported("Not supported in Model DB"); return Status::NotSupported("Not supported in Model DB");
} }
virtual void GetColumnFamilyMetaData( void GetColumnFamilyMetaData(ColumnFamilyHandle* /*column_family*/,
ColumnFamilyHandle* /*column_family*/, ColumnFamilyMetaData* /*metadata*/) override {}
ColumnFamilyMetaData* /*metadata*/) override {}
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE
virtual Status GetDbIdentity(std::string& /*identity*/) const override { Status GetDbIdentity(std::string& /*identity*/) const override {
return Status::OK(); return Status::OK();
} }
virtual SequenceNumber GetLatestSequenceNumber() const override { return 0; } SequenceNumber GetLatestSequenceNumber() const override { return 0; }
virtual bool SetPreserveDeletesSequenceNumber( bool SetPreserveDeletesSequenceNumber(SequenceNumber /*seqnum*/) override {
SequenceNumber /*seqnum*/) override {
return true; return true;
} }
virtual ColumnFamilyHandle* DefaultColumnFamily() const override { ColumnFamilyHandle* DefaultColumnFamily() const override { return nullptr; }
return nullptr;
}
private: private:
class ModelIter : public Iterator { class ModelIter : public Iterator {
public: public:
ModelIter(const KVMap* map, bool owned) ModelIter(const KVMap* map, bool owned)
: map_(map), owned_(owned), iter_(map_->end()) {} : map_(map), owned_(owned), iter_(map_->end()) {}
~ModelIter() { ~ModelIter() override {
if (owned_) delete map_; if (owned_) delete map_;
} }
virtual bool Valid() const override { return iter_ != map_->end(); } bool Valid() const override { return iter_ != map_->end(); }
virtual void SeekToFirst() override { iter_ = map_->begin(); } void SeekToFirst() override { iter_ = map_->begin(); }
virtual void SeekToLast() override { void SeekToLast() override {
if (map_->empty()) { if (map_->empty()) {
iter_ = map_->end(); iter_ = map_->end();
} else { } else {
iter_ = map_->find(map_->rbegin()->first); iter_ = map_->find(map_->rbegin()->first);
} }
} }
virtual void Seek(const Slice& k) override { void Seek(const Slice& k) override {
iter_ = map_->lower_bound(k.ToString()); iter_ = map_->lower_bound(k.ToString());
} }
virtual void SeekForPrev(const Slice& k) override { void SeekForPrev(const Slice& k) override {
iter_ = map_->upper_bound(k.ToString()); iter_ = map_->upper_bound(k.ToString());
Prev(); Prev();
} }
virtual void Next() override { ++iter_; } void Next() override { ++iter_; }
virtual void Prev() override { void Prev() override {
if (iter_ == map_->begin()) { if (iter_ == map_->begin()) {
iter_ = map_->end(); iter_ = map_->end();
return; return;
@ -2751,9 +2723,9 @@ class ModelDB : public DB {
--iter_; --iter_;
} }
virtual Slice key() const override { return iter_->first; } Slice key() const override { return iter_->first; }
virtual Slice value() const override { return iter_->second; } Slice value() const override { return iter_->second; }
virtual Status status() const override { return Status::OK(); } Status status() const override { return Status::OK(); }
private: private:
const KVMap* const map_; const KVMap* const map_;
@ -2821,7 +2793,7 @@ static bool CompareIterators(int step, DB* model, DB* db,
class DBTestRandomized : public DBTest, class DBTestRandomized : public DBTest,
public ::testing::WithParamInterface<int> { public ::testing::WithParamInterface<int> {
public: public:
virtual void SetUp() override { option_config_ = GetParam(); } void SetUp() override { option_config_ = GetParam(); }
static std::vector<int> GenerateOptionConfigs() { static std::vector<int> GenerateOptionConfigs() {
std::vector<int> option_configs; std::vector<int> option_configs;
@ -5043,14 +5015,14 @@ class DelayedMergeOperator : public MergeOperator {
public: public:
explicit DelayedMergeOperator(DBTest* d) : db_test_(d) {} explicit DelayedMergeOperator(DBTest* d) : db_test_(d) {}
virtual bool FullMergeV2(const MergeOperationInput& /*merge_in*/, bool FullMergeV2(const MergeOperationInput& /*merge_in*/,
MergeOperationOutput* merge_out) const override { MergeOperationOutput* merge_out) const override {
db_test_->env_->addon_time_.fetch_add(1000); db_test_->env_->addon_time_.fetch_add(1000);
merge_out->new_value = ""; merge_out->new_value = "";
return true; return true;
} }
virtual const char* Name() const override { return "DelayedMergeOperator"; } const char* Name() const override { return "DelayedMergeOperator"; }
}; };
TEST_F(DBTest, MergeTestTime) { TEST_F(DBTest, MergeTestTime) {
@ -5186,7 +5158,7 @@ TEST_F(DBTest, EmptyCompactedDB) {
TEST_F(DBTest, SuggestCompactRangeTest) { TEST_F(DBTest, SuggestCompactRangeTest) {
class CompactionFilterFactoryGetContext : public CompactionFilterFactory { class CompactionFilterFactoryGetContext : public CompactionFilterFactory {
public: public:
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter( std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& context) override { const CompactionFilter::Context& context) override {
saved_context = context; saved_context = context;
std::unique_ptr<CompactionFilter> empty_filter; std::unique_ptr<CompactionFilter> empty_filter;

@ -30,7 +30,7 @@ class PrefixFullBloomWithReverseComparator
public: public:
PrefixFullBloomWithReverseComparator() PrefixFullBloomWithReverseComparator()
: DBTestBase("/prefix_bloom_reverse") {} : DBTestBase("/prefix_bloom_reverse") {}
virtual void SetUp() override { if_cache_filter_ = GetParam(); } void SetUp() override { if_cache_filter_ = GetParam(); }
bool if_cache_filter_; bool if_cache_filter_;
}; };
@ -515,9 +515,9 @@ TEST_F(DBTest2, WalFilterTest) {
apply_option_at_record_index_(apply_option_for_record_index), apply_option_at_record_index_(apply_option_for_record_index),
current_record_index_(0) {} current_record_index_(0) {}
virtual WalProcessingOption LogRecord( WalProcessingOption LogRecord(const WriteBatch& /*batch*/,
const WriteBatch& /*batch*/, WriteBatch* /*new_batch*/, WriteBatch* /*new_batch*/,
bool* /*batch_changed*/) const override { bool* /*batch_changed*/) const override {
WalFilter::WalProcessingOption option_to_return; WalFilter::WalProcessingOption option_to_return;
if (current_record_index_ == apply_option_at_record_index_) { if (current_record_index_ == apply_option_at_record_index_) {
@ -535,7 +535,7 @@ TEST_F(DBTest2, WalFilterTest) {
return option_to_return; return option_to_return;
} }
virtual const char* Name() const override { return "TestWalFilter"; } const char* Name() const override { return "TestWalFilter"; }
}; };
// Create 3 batches with two keys each // Create 3 batches with two keys each
@ -687,7 +687,7 @@ TEST_F(DBTest2, WalFilterTestWithChangeBatch) {
: new_write_batch_(new_write_batch), : new_write_batch_(new_write_batch),
num_keys_to_add_in_new_batch_(num_keys_to_add_in_new_batch), num_keys_to_add_in_new_batch_(num_keys_to_add_in_new_batch),
num_keys_added_(0) {} num_keys_added_(0) {}
virtual void Put(const Slice& key, const Slice& value) override { void Put(const Slice& key, const Slice& value) override {
if (num_keys_added_ < num_keys_to_add_in_new_batch_) { if (num_keys_added_ < num_keys_to_add_in_new_batch_) {
new_write_batch_->Put(key, value); new_write_batch_->Put(key, value);
++num_keys_added_; ++num_keys_added_;
@ -711,9 +711,9 @@ TEST_F(DBTest2, WalFilterTestWithChangeBatch) {
num_keys_to_add_in_new_batch_(num_keys_to_add_in_new_batch), num_keys_to_add_in_new_batch_(num_keys_to_add_in_new_batch),
current_record_index_(0) {} current_record_index_(0) {}
virtual WalProcessingOption LogRecord(const WriteBatch& batch, WalProcessingOption LogRecord(const WriteBatch& batch,
WriteBatch* new_batch, WriteBatch* new_batch,
bool* batch_changed) const override { bool* batch_changed) const override {
if (current_record_index_ >= change_records_from_index_) { if (current_record_index_ >= change_records_from_index_) {
ChangeBatchHandler handler(new_batch, num_keys_to_add_in_new_batch_); ChangeBatchHandler handler(new_batch, num_keys_to_add_in_new_batch_);
batch.Iterate(&handler); batch.Iterate(&handler);
@ -729,9 +729,7 @@ TEST_F(DBTest2, WalFilterTestWithChangeBatch) {
return WalProcessingOption::kContinueProcessing; return WalProcessingOption::kContinueProcessing;
} }
virtual const char* Name() const override { const char* Name() const override { return "TestWalFilterWithChangeBatch"; }
return "TestWalFilterWithChangeBatch";
}
}; };
std::vector<std::vector<std::string>> batch_keys(3); std::vector<std::vector<std::string>> batch_keys(3);
@ -809,18 +807,17 @@ TEST_F(DBTest2, WalFilterTestWithChangeBatch) {
TEST_F(DBTest2, WalFilterTestWithChangeBatchExtraKeys) { TEST_F(DBTest2, WalFilterTestWithChangeBatchExtraKeys) {
class TestWalFilterWithChangeBatchAddExtraKeys : public WalFilter { class TestWalFilterWithChangeBatchAddExtraKeys : public WalFilter {
public: public:
virtual WalProcessingOption LogRecord(const WriteBatch& batch, WalProcessingOption LogRecord(const WriteBatch& batch, WriteBatch* new_batch,
WriteBatch* new_batch, bool* batch_changed) const override {
bool* batch_changed) const override { *new_batch = batch;
*new_batch = batch; new_batch->Put("key_extra", "value_extra");
new_batch->Put("key_extra", "value_extra"); *batch_changed = true;
*batch_changed = true; return WalProcessingOption::kContinueProcessing;
return WalProcessingOption::kContinueProcessing; }
}
const char* Name() const override {
virtual const char* Name() const override { return "WalFilterTestWithChangeBatchExtraKeys";
return "WalFilterTestWithChangeBatchExtraKeys"; }
}
}; };
std::vector<std::vector<std::string>> batch_keys(3); std::vector<std::vector<std::string>> batch_keys(3);
@ -884,18 +881,19 @@ TEST_F(DBTest2, WalFilterTestWithColumnFamilies) {
// for verification against the keys we expect. // for verification against the keys we expect.
std::map<uint32_t, std::vector<std::string>> cf_wal_keys_; std::map<uint32_t, std::vector<std::string>> cf_wal_keys_;
public: public:
virtual void ColumnFamilyLogNumberMap( void ColumnFamilyLogNumberMap(
const std::map<uint32_t, uint64_t>& cf_lognumber_map, const std::map<uint32_t, uint64_t>& cf_lognumber_map,
const std::map<std::string, uint32_t>& cf_name_id_map) override { const std::map<std::string, uint32_t>& cf_name_id_map) override {
cf_log_number_map_ = cf_lognumber_map; cf_log_number_map_ = cf_lognumber_map;
cf_name_id_map_ = cf_name_id_map; cf_name_id_map_ = cf_name_id_map;
} }
virtual WalProcessingOption LogRecordFound( WalProcessingOption LogRecordFound(unsigned long long log_number,
unsigned long long log_number, const std::string& /*log_file_name*/, const std::string& /*log_file_name*/,
const WriteBatch& batch, WriteBatch* /*new_batch*/, const WriteBatch& batch,
bool* /*batch_changed*/) override { WriteBatch* /*new_batch*/,
class LogRecordBatchHandler : public WriteBatch::Handler { bool* /*batch_changed*/) override {
class LogRecordBatchHandler : public WriteBatch::Handler {
private: private:
const std::map<uint32_t, uint64_t> & cf_log_number_map_; const std::map<uint32_t, uint64_t> & cf_log_number_map_;
std::map<uint32_t, std::vector<std::string>> & cf_wal_keys_; std::map<uint32_t, std::vector<std::string>> & cf_wal_keys_;
@ -908,8 +906,8 @@ TEST_F(DBTest2, WalFilterTestWithColumnFamilies) {
cf_wal_keys_(cf_wal_keys), cf_wal_keys_(cf_wal_keys),
log_number_(current_log_number){} log_number_(current_log_number){}
virtual Status PutCF(uint32_t column_family_id, const Slice& key, Status PutCF(uint32_t column_family_id, const Slice& key,
const Slice& /*value*/) override { const Slice& /*value*/) override {
auto it = cf_log_number_map_.find(column_family_id); auto it = cf_log_number_map_.find(column_family_id);
assert(it != cf_log_number_map_.end()); assert(it != cf_log_number_map_.end());
unsigned long long log_number_for_cf = it->second; unsigned long long log_number_for_cf = it->second;
@ -927,11 +925,11 @@ TEST_F(DBTest2, WalFilterTestWithColumnFamilies) {
batch.Iterate(&handler); batch.Iterate(&handler);
return WalProcessingOption::kContinueProcessing; return WalProcessingOption::kContinueProcessing;
} }
virtual const char* Name() const override { const char* Name() const override {
return "WalFilterTestWithColumnFamilies"; return "WalFilterTestWithColumnFamilies";
} }
const std::map<uint32_t, std::vector<std::string>>& GetColumnFamilyKeys() { const std::map<uint32_t, std::vector<std::string>>& GetColumnFamilyKeys() {
return cf_wal_keys_; return cf_wal_keys_;
@ -1452,7 +1450,7 @@ class PinL0IndexAndFilterBlocksTest
public testing::WithParamInterface<std::tuple<bool, bool>> { public testing::WithParamInterface<std::tuple<bool, bool>> {
public: public:
PinL0IndexAndFilterBlocksTest() : DBTestBase("/db_pin_l0_index_bloom_test") {} PinL0IndexAndFilterBlocksTest() : DBTestBase("/db_pin_l0_index_bloom_test") {}
virtual void SetUp() override { void SetUp() override {
infinite_max_files_ = std::get<0>(GetParam()); infinite_max_files_ = std::get<0>(GetParam());
disallow_preload_ = std::get<1>(GetParam()); disallow_preload_ = std::get<1>(GetParam());
} }
@ -1755,7 +1753,7 @@ class MockPersistentCache : public PersistentCache {
"GetUniqueIdFromFile:FS_IOC_GETVERSION", UniqueIdCallback); "GetUniqueIdFromFile:FS_IOC_GETVERSION", UniqueIdCallback);
} }
virtual ~MockPersistentCache() {} ~MockPersistentCache() override {}
PersistentCache::StatsType Stats() override { PersistentCache::StatsType Stats() override {
return PersistentCache::StatsType(); return PersistentCache::StatsType();
@ -2646,9 +2644,7 @@ TEST_F(DBTest2, ReadCallbackTest) {
class TestReadCallback : public ReadCallback { class TestReadCallback : public ReadCallback {
public: public:
explicit TestReadCallback(SequenceNumber snapshot) : snapshot_(snapshot) {} explicit TestReadCallback(SequenceNumber snapshot) : snapshot_(snapshot) {}
virtual bool IsVisible(SequenceNumber seq) override { bool IsVisible(SequenceNumber seq) override { return seq <= snapshot_; }
return seq <= snapshot_;
}
private: private:
SequenceNumber snapshot_; SequenceNumber snapshot_;

@ -27,7 +27,7 @@ class DBTestUniversalCompactionBase
public: public:
explicit DBTestUniversalCompactionBase( explicit DBTestUniversalCompactionBase(
const std::string& path) : DBTestBase(path) {} const std::string& path) : DBTestBase(path) {}
virtual void SetUp() override { void SetUp() override {
num_levels_ = std::get<0>(GetParam()); num_levels_ = std::get<0>(GetParam());
exclusive_manual_compaction_ = std::get<1>(GetParam()); exclusive_manual_compaction_ = std::get<1>(GetParam());
} }
@ -63,13 +63,13 @@ void VerifyCompactionResult(
class KeepFilter : public CompactionFilter { class KeepFilter : public CompactionFilter {
public: public:
virtual bool Filter(int /*level*/, const Slice& /*key*/, bool Filter(int /*level*/, const Slice& /*key*/, const Slice& /*value*/,
const Slice& /*value*/, std::string* /*new_value*/, std::string* /*new_value*/,
bool* /*value_changed*/) const override { bool* /*value_changed*/) const override {
return false; return false;
} }
virtual const char* Name() const override { return "KeepFilter"; } const char* Name() const override { return "KeepFilter"; }
}; };
class KeepFilterFactory : public CompactionFilterFactory { class KeepFilterFactory : public CompactionFilterFactory {
@ -77,7 +77,7 @@ class KeepFilterFactory : public CompactionFilterFactory {
explicit KeepFilterFactory(bool check_context = false) explicit KeepFilterFactory(bool check_context = false)
: check_context_(check_context) {} : check_context_(check_context) {}
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter( std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& context) override { const CompactionFilter::Context& context) override {
if (check_context_) { if (check_context_) {
EXPECT_EQ(expect_full_compaction_.load(), context.is_full_compaction); EXPECT_EQ(expect_full_compaction_.load(), context.is_full_compaction);
@ -86,7 +86,7 @@ class KeepFilterFactory : public CompactionFilterFactory {
return std::unique_ptr<CompactionFilter>(new KeepFilter()); return std::unique_ptr<CompactionFilter>(new KeepFilter());
} }
virtual const char* Name() const override { return "KeepFilterFactory"; } const char* Name() const override { return "KeepFilterFactory"; }
bool check_context_; bool check_context_;
std::atomic_bool expect_full_compaction_; std::atomic_bool expect_full_compaction_;
std::atomic_bool expect_manual_compaction_; std::atomic_bool expect_manual_compaction_;
@ -95,14 +95,14 @@ class KeepFilterFactory : public CompactionFilterFactory {
class DelayFilter : public CompactionFilter { class DelayFilter : public CompactionFilter {
public: public:
explicit DelayFilter(DBTestBase* d) : db_test(d) {} explicit DelayFilter(DBTestBase* d) : db_test(d) {}
virtual bool Filter(int /*level*/, const Slice& /*key*/, bool Filter(int /*level*/, const Slice& /*key*/, const Slice& /*value*/,
const Slice& /*value*/, std::string* /*new_value*/, std::string* /*new_value*/,
bool* /*value_changed*/) const override { bool* /*value_changed*/) const override {
db_test->env_->addon_time_.fetch_add(1000); db_test->env_->addon_time_.fetch_add(1000);
return true; return true;
} }
virtual const char* Name() const override { return "DelayFilter"; } const char* Name() const override { return "DelayFilter"; }
private: private:
DBTestBase* db_test; DBTestBase* db_test;
@ -111,12 +111,12 @@ class DelayFilter : public CompactionFilter {
class DelayFilterFactory : public CompactionFilterFactory { class DelayFilterFactory : public CompactionFilterFactory {
public: public:
explicit DelayFilterFactory(DBTestBase* d) : db_test(d) {} explicit DelayFilterFactory(DBTestBase* d) : db_test(d) {}
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter( std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& /*context*/) override { const CompactionFilter::Context& /*context*/) override {
return std::unique_ptr<CompactionFilter>(new DelayFilter(db_test)); return std::unique_ptr<CompactionFilter>(new DelayFilter(db_test));
} }
virtual const char* Name() const override { return "DelayFilterFactory"; } const char* Name() const override { return "DelayFilterFactory"; }
private: private:
DBTestBase* db_test; DBTestBase* db_test;

@ -134,7 +134,9 @@ class ExternalSSTFileBasicTest
write_global_seqno, verify_checksums_before_ingest, true_data); write_global_seqno, verify_checksums_before_ingest, true_data);
} }
~ExternalSSTFileBasicTest() { test::DestroyDir(env_, sst_files_dir_); } ~ExternalSSTFileBasicTest() override {
test::DestroyDir(env_, sst_files_dir_);
}
protected: protected:
std::string sst_files_dir_; std::string sst_files_dir_;

@ -283,7 +283,7 @@ class ExternalSSTFileTest
return db_->IngestExternalFile(files, opts); return db_->IngestExternalFile(files, opts);
} }
~ExternalSSTFileTest() { test::DestroyDir(env_, sst_files_dir_); } ~ExternalSSTFileTest() override { test::DestroyDir(env_, sst_files_dir_); }
protected: protected:
int last_file_id_ = 0; int last_file_id_ = 0;
@ -571,7 +571,7 @@ class SstFileWriterCollector : public TablePropertiesCollector {
return Status::OK(); return Status::OK();
} }
virtual UserCollectedProperties GetReadableProperties() const override { UserCollectedProperties GetReadableProperties() const override {
return UserCollectedProperties{}; return UserCollectedProperties{};
} }
@ -585,7 +585,7 @@ class SstFileWriterCollectorFactory : public TablePropertiesCollectorFactory {
public: public:
explicit SstFileWriterCollectorFactory(std::string prefix) explicit SstFileWriterCollectorFactory(std::string prefix)
: prefix_(prefix), num_created_(0) {} : prefix_(prefix), num_created_(0) {}
virtual TablePropertiesCollector* CreateTablePropertiesCollector( TablePropertiesCollector* CreateTablePropertiesCollector(
TablePropertiesCollectorFactory::Context /*context*/) override { TablePropertiesCollectorFactory::Context /*context*/) override {
num_created_++; num_created_++;
return new SstFileWriterCollector(prefix_); return new SstFileWriterCollector(prefix_);

@ -83,7 +83,7 @@ class FaultInjectionTest
env_(nullptr), env_(nullptr),
db_(nullptr) {} db_(nullptr) {}
~FaultInjectionTest() { ~FaultInjectionTest() override {
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); rocksdb::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks();
} }

@ -47,7 +47,7 @@ class FileIndexerTest : public testing::Test {
FileIndexerTest() FileIndexerTest()
: kNumLevels(4), files(new std::vector<FileMetaData*>[kNumLevels]) {} : kNumLevels(4), files(new std::vector<FileMetaData*>[kNumLevels]) {}
~FileIndexerTest() { ~FileIndexerTest() override {
ClearFiles(); ClearFiles();
delete[] files; delete[] files;
} }

@ -46,7 +46,7 @@ class ForwardLevelIterator : public InternalIterator {
pinned_iters_mgr_(nullptr), pinned_iters_mgr_(nullptr),
prefix_extractor_(prefix_extractor) {} prefix_extractor_(prefix_extractor) {}
~ForwardLevelIterator() { ~ForwardLevelIterator() override {
// Reset current pointer // Reset current pointer
if (pinned_iters_mgr_ && pinned_iters_mgr_->PinningEnabled()) { if (pinned_iters_mgr_ && pinned_iters_mgr_->PinningEnabled()) {
pinned_iters_mgr_->PinIterator(file_iter_); pinned_iters_mgr_->PinIterator(file_iter_);

@ -46,22 +46,20 @@ class EventListenerTest : public DBTestBase {
}; };
struct TestPropertiesCollector : public rocksdb::TablePropertiesCollector { struct TestPropertiesCollector : public rocksdb::TablePropertiesCollector {
virtual rocksdb::Status AddUserKey(const rocksdb::Slice& /*key*/, rocksdb::Status AddUserKey(const rocksdb::Slice& /*key*/,
const rocksdb::Slice& /*value*/, const rocksdb::Slice& /*value*/,
rocksdb::EntryType /*type*/, rocksdb::EntryType /*type*/,
rocksdb::SequenceNumber /*seq*/, rocksdb::SequenceNumber /*seq*/,
uint64_t /*file_size*/) override { uint64_t /*file_size*/) override {
return Status::OK(); return Status::OK();
} }
virtual rocksdb::Status Finish( rocksdb::Status Finish(
rocksdb::UserCollectedProperties* properties) override { rocksdb::UserCollectedProperties* properties) override {
properties->insert({"0", "1"}); properties->insert({"0", "1"});
return Status::OK(); return Status::OK();
} }
virtual const char* Name() const override { const char* Name() const override { return "TestTablePropertiesCollector"; }
return "TestTablePropertiesCollector";
}
rocksdb::UserCollectedProperties GetReadableProperties() const override { rocksdb::UserCollectedProperties GetReadableProperties() const override {
rocksdb::UserCollectedProperties ret; rocksdb::UserCollectedProperties ret;
@ -72,7 +70,7 @@ struct TestPropertiesCollector : public rocksdb::TablePropertiesCollector {
class TestPropertiesCollectorFactory : public TablePropertiesCollectorFactory { class TestPropertiesCollectorFactory : public TablePropertiesCollectorFactory {
public: public:
virtual TablePropertiesCollector* CreateTablePropertiesCollector( TablePropertiesCollector* CreateTablePropertiesCollector(
TablePropertiesCollectorFactory::Context /*context*/) override { TablePropertiesCollectorFactory::Context /*context*/) override {
return new TestPropertiesCollector; return new TestPropertiesCollector;
} }
@ -603,7 +601,7 @@ class TableFileCreationListener : public EventListener {
Status NewWritableFile(const std::string& fname, Status NewWritableFile(const std::string& fname,
std::unique_ptr<WritableFile>* result, std::unique_ptr<WritableFile>* result,
const EnvOptions& options) { const EnvOptions& options) override {
if (fname.size() > 4 && fname.substr(fname.size() - 4) == ".sst") { if (fname.size() > 4 && fname.substr(fname.size() - 4) == ".sst") {
if (!status_.ok()) { if (!status_.ok()) {
return status_; return status_;

@ -61,7 +61,7 @@ class LogTest : public ::testing::TestWithParam<int> {
force_eof_position_(0), force_eof_position_(0),
returned_partial_(false) { } returned_partial_(false) { }
virtual Status Read(size_t n, Slice* result, char* scratch) override { Status Read(size_t n, Slice* result, char* scratch) override {
EXPECT_TRUE(!returned_partial_) << "must not Read() after eof/error"; EXPECT_TRUE(!returned_partial_) << "must not Read() after eof/error";
if (force_error_) { if (force_error_) {
@ -100,7 +100,7 @@ class LogTest : public ::testing::TestWithParam<int> {
return Status::OK(); return Status::OK();
} }
virtual Status Skip(uint64_t n) override { Status Skip(uint64_t n) override {
if (n > contents_.size()) { if (n > contents_.size()) {
contents_.clear(); contents_.clear();
return Status::NotFound("in-memory file skipepd past end"); return Status::NotFound("in-memory file skipepd past end");
@ -118,7 +118,7 @@ class LogTest : public ::testing::TestWithParam<int> {
std::string message_; std::string message_;
ReportCollector() : dropped_bytes_(0) { } ReportCollector() : dropped_bytes_(0) { }
virtual void Corruption(size_t bytes, const Status& status) override { void Corruption(size_t bytes, const Status& status) override {
dropped_bytes_ += bytes; dropped_bytes_ += bytes;
message_.append(status.ToString()); message_.append(status.ToString());
} }
@ -661,7 +661,7 @@ class RetriableLogTest : public ::testing::TestWithParam<int> {
std::string message_; std::string message_;
ReportCollector() : dropped_bytes_(0) {} ReportCollector() : dropped_bytes_(0) {}
virtual void Corruption(size_t bytes, const Status& status) override { void Corruption(size_t bytes, const Status& status) override {
dropped_bytes_ += bytes; dropped_bytes_ += bytes;
message_.append(status.ToString()); message_.append(status.ToString());
} }

@ -51,15 +51,13 @@ class DestroyAllCompactionFilter : public CompactionFilter {
public: public:
DestroyAllCompactionFilter() {} DestroyAllCompactionFilter() {}
virtual bool Filter(int /*level*/, const Slice& /*key*/, bool Filter(int /*level*/, const Slice& /*key*/, const Slice& existing_value,
const Slice& existing_value, std::string* /*new_value*/, std::string* /*new_value*/,
bool* /*value_changed*/) const override { bool* /*value_changed*/) const override {
return existing_value.ToString() == "destroy"; return existing_value.ToString() == "destroy";
} }
virtual const char* Name() const override { const char* Name() const override { return "DestroyAllCompactionFilter"; }
return "DestroyAllCompactionFilter";
}
}; };
TEST_F(ManualCompactionTest, CompactTouchesAllKeys) { TEST_F(ManualCompactionTest, CompactTouchesAllKeys) {

@ -289,7 +289,7 @@ class MemTableIterator : public InternalIterator {
} }
} }
~MemTableIterator() { ~MemTableIterator() override {
#ifndef NDEBUG #ifndef NDEBUG
// Assert that the MemTableIterator is never deleted while // Assert that the MemTableIterator is never deleted while
// Pinning is Enabled. // Pinning is Enabled.
@ -303,15 +303,14 @@ class MemTableIterator : public InternalIterator {
} }
#ifndef NDEBUG #ifndef NDEBUG
virtual void SetPinnedItersMgr( void SetPinnedItersMgr(PinnedIteratorsManager* pinned_iters_mgr) override {
PinnedIteratorsManager* pinned_iters_mgr) override {
pinned_iters_mgr_ = pinned_iters_mgr; pinned_iters_mgr_ = pinned_iters_mgr;
} }
PinnedIteratorsManager* pinned_iters_mgr_ = nullptr; PinnedIteratorsManager* pinned_iters_mgr_ = nullptr;
#endif #endif
virtual bool Valid() const override { return valid_; } bool Valid() const override { return valid_; }
virtual void Seek(const Slice& k) override { void Seek(const Slice& k) override {
PERF_TIMER_GUARD(seek_on_memtable_time); PERF_TIMER_GUARD(seek_on_memtable_time);
PERF_COUNTER_ADD(seek_on_memtable_count, 1); PERF_COUNTER_ADD(seek_on_memtable_count, 1);
if (bloom_ != nullptr) { if (bloom_ != nullptr) {
@ -327,7 +326,7 @@ class MemTableIterator : public InternalIterator {
iter_->Seek(k, nullptr); iter_->Seek(k, nullptr);
valid_ = iter_->Valid(); valid_ = iter_->Valid();
} }
virtual void SeekForPrev(const Slice& k) override { void SeekForPrev(const Slice& k) override {
PERF_TIMER_GUARD(seek_on_memtable_time); PERF_TIMER_GUARD(seek_on_memtable_time);
PERF_COUNTER_ADD(seek_on_memtable_count, 1); PERF_COUNTER_ADD(seek_on_memtable_count, 1);
if (bloom_ != nullptr) { if (bloom_ != nullptr) {
@ -349,44 +348,44 @@ class MemTableIterator : public InternalIterator {
Prev(); Prev();
} }
} }
virtual void SeekToFirst() override { void SeekToFirst() override {
iter_->SeekToFirst(); iter_->SeekToFirst();
valid_ = iter_->Valid(); valid_ = iter_->Valid();
} }
virtual void SeekToLast() override { void SeekToLast() override {
iter_->SeekToLast(); iter_->SeekToLast();
valid_ = iter_->Valid(); valid_ = iter_->Valid();
} }
virtual void Next() override { void Next() override {
PERF_COUNTER_ADD(next_on_memtable_count, 1); PERF_COUNTER_ADD(next_on_memtable_count, 1);
assert(Valid()); assert(Valid());
iter_->Next(); iter_->Next();
valid_ = iter_->Valid(); valid_ = iter_->Valid();
} }
virtual void Prev() override { void Prev() override {
PERF_COUNTER_ADD(prev_on_memtable_count, 1); PERF_COUNTER_ADD(prev_on_memtable_count, 1);
assert(Valid()); assert(Valid());
iter_->Prev(); iter_->Prev();
valid_ = iter_->Valid(); valid_ = iter_->Valid();
} }
virtual Slice key() const override { Slice key() const override {
assert(Valid()); assert(Valid());
return GetLengthPrefixedSlice(iter_->key()); return GetLengthPrefixedSlice(iter_->key());
} }
virtual Slice value() const override { Slice value() const override {
assert(Valid()); assert(Valid());
Slice key_slice = GetLengthPrefixedSlice(iter_->key()); Slice key_slice = GetLengthPrefixedSlice(iter_->key());
return GetLengthPrefixedSlice(key_slice.data() + key_slice.size()); return GetLengthPrefixedSlice(key_slice.data() + key_slice.size());
} }
virtual Status status() const override { return Status::OK(); } Status status() const override { return Status::OK(); }
virtual bool IsKeyPinned() const override { bool IsKeyPinned() const override {
// memtable data is always pinned // memtable data is always pinned
return true; return true;
} }
virtual bool IsValuePinned() const override { bool IsValuePinned() const override {
// memtable value is always pinned, except if we allow inplace update. // memtable value is always pinned, except if we allow inplace update.
return value_pinned_; return value_pinned_;
} }

@ -62,7 +62,7 @@ class MemTableListTest : public testing::Test {
} }
} }
~MemTableListTest() { ~MemTableListTest() override {
if (db) { if (db) {
std::vector<ColumnFamilyDescriptor> cf_descs(handles.size()); std::vector<ColumnFamilyDescriptor> cf_descs(handles.size());
for (int i = 0; i != static_cast<int>(handles.size()); ++i) { for (int i = 0; i != static_cast<int>(handles.size()); ++i) {

@ -20,7 +20,7 @@ class MergeHelperTest : public testing::Test {
public: public:
MergeHelperTest() { env_ = Env::Default(); } MergeHelperTest() { env_ = Env::Default(); }
~MergeHelperTest() = default; ~MergeHelperTest() override = default;
Status Run(SequenceNumber stop_before, bool at_bottom, Status Run(SequenceNumber stop_before, bool at_bottom,
SequenceNumber latest_snapshot = 0) { SequenceNumber latest_snapshot = 0) {

@ -38,11 +38,8 @@ class CountMergeOperator : public AssociativeMergeOperator {
mergeOperator_ = MergeOperators::CreateUInt64AddOperator(); mergeOperator_ = MergeOperators::CreateUInt64AddOperator();
} }
virtual bool Merge(const Slice& key, bool Merge(const Slice& key, const Slice* existing_value, const Slice& value,
const Slice* existing_value, std::string* new_value, Logger* logger) const override {
const Slice& value,
std::string* new_value,
Logger* logger) const override {
assert(new_value->empty()); assert(new_value->empty());
++num_merge_operator_calls; ++num_merge_operator_calls;
if (existing_value == nullptr) { if (existing_value == nullptr) {
@ -58,19 +55,17 @@ class CountMergeOperator : public AssociativeMergeOperator {
logger); logger);
} }
virtual bool PartialMergeMulti(const Slice& key, bool PartialMergeMulti(const Slice& key,
const std::deque<Slice>& operand_list, const std::deque<Slice>& operand_list,
std::string* new_value, std::string* new_value,
Logger* logger) const override { Logger* logger) const override {
assert(new_value->empty()); assert(new_value->empty());
++num_partial_merge_calls; ++num_partial_merge_calls;
return mergeOperator_->PartialMergeMulti(key, operand_list, new_value, return mergeOperator_->PartialMergeMulti(key, operand_list, new_value,
logger); logger);
} }
virtual const char* Name() const override { const char* Name() const override { return "UInt64AddOperator"; }
return "UInt64AddOperator";
}
private: private:
std::shared_ptr<MergeOperator> mergeOperator_; std::shared_ptr<MergeOperator> mergeOperator_;
@ -230,7 +225,7 @@ class MergeBasedCounters : public Counters {
} }
// mapped to a rocksdb Merge operation // mapped to a rocksdb Merge operation
virtual bool add(const std::string& key, uint64_t value) override { bool add(const std::string& key, uint64_t value) override {
char encoded[sizeof(uint64_t)]; char encoded[sizeof(uint64_t)];
EncodeFixed64(encoded, value); EncodeFixed64(encoded, value);
Slice slice(encoded, sizeof(uint64_t)); Slice slice(encoded, sizeof(uint64_t));

@ -109,7 +109,7 @@ class PlainTableDBTest : public testing::Test,
public: public:
PlainTableDBTest() : env_(Env::Default()) {} PlainTableDBTest() : env_(Env::Default()) {}
~PlainTableDBTest() { ~PlainTableDBTest() override {
delete db_; delete db_;
EXPECT_OK(DestroyDB(dbname_, Options())); EXPECT_OK(DestroyDB(dbname_, Options()));
} }
@ -290,10 +290,10 @@ class TestPlainTableReader : public PlainTableReader {
EXPECT_EQ(column_family_name, props->column_family_name); EXPECT_EQ(column_family_name, props->column_family_name);
} }
virtual ~TestPlainTableReader() {} ~TestPlainTableReader() override {}
private: private:
virtual bool MatchBloom(uint32_t hash) const override { bool MatchBloom(uint32_t hash) const override {
bool ret = PlainTableReader::MatchBloom(hash); bool ret = PlainTableReader::MatchBloom(hash);
if (*expect_bloom_not_match_) { if (*expect_bloom_not_match_) {
EXPECT_TRUE(!ret); EXPECT_TRUE(!ret);

@ -83,7 +83,7 @@ class TestKeyComparator : public Comparator {
// Compare needs to be aware of the possibility of a and/or b is // Compare needs to be aware of the possibility of a and/or b is
// prefix only // prefix only
virtual int Compare(const Slice& a, const Slice& b) const override { int Compare(const Slice& a, const Slice& b) const override {
const TestKey kkey_a = SliceToTestKey(a); const TestKey kkey_a = SliceToTestKey(a);
const TestKey kkey_b = SliceToTestKey(b); const TestKey kkey_b = SliceToTestKey(b);
const TestKey *key_a = &kkey_a; const TestKey *key_a = &kkey_a;
@ -122,14 +122,12 @@ class TestKeyComparator : public Comparator {
return Compare(TestKeyToSlice(sa, a), TestKeyToSlice(sb, b)) < 0; return Compare(TestKeyToSlice(sa, a), TestKeyToSlice(sb, b)) < 0;
} }
virtual const char* Name() const override { const char* Name() const override { return "TestKeyComparator"; }
return "TestKeyComparator";
}
virtual void FindShortestSeparator(std::string* /*start*/, void FindShortestSeparator(std::string* /*start*/,
const Slice& /*limit*/) const override {} const Slice& /*limit*/) const override {}
virtual void FindShortSuccessor(std::string* /*key*/) const override {} void FindShortSuccessor(std::string* /*key*/) const override {}
}; };
namespace { namespace {
@ -195,27 +193,23 @@ class SamePrefixTransform : public SliceTransform {
explicit SamePrefixTransform(const Slice& prefix) explicit SamePrefixTransform(const Slice& prefix)
: prefix_(prefix), name_("rocksdb.SamePrefix." + prefix.ToString()) {} : prefix_(prefix), name_("rocksdb.SamePrefix." + prefix.ToString()) {}
virtual const char* Name() const override { return name_.c_str(); } const char* Name() const override { return name_.c_str(); }
virtual Slice Transform(const Slice& src) const override { Slice Transform(const Slice& src) const override {
assert(InDomain(src)); assert(InDomain(src));
return prefix_; return prefix_;
} }
virtual bool InDomain(const Slice& src) const override { bool InDomain(const Slice& src) const override {
if (src.size() >= prefix_.size()) { if (src.size() >= prefix_.size()) {
return Slice(src.data(), prefix_.size()) == prefix_; return Slice(src.data(), prefix_.size()) == prefix_;
} }
return false; return false;
} }
virtual bool InRange(const Slice& dst) const override { bool InRange(const Slice& dst) const override { return dst == prefix_; }
return dst == prefix_;
}
virtual bool FullLengthEnabled(size_t* /*len*/) const override { bool FullLengthEnabled(size_t* /*len*/) const override { return false; }
return false;
}
}; };
} // namespace } // namespace
@ -283,9 +277,8 @@ class PrefixTest : public testing::Test {
PrefixTest() : option_config_(kBegin) { PrefixTest() : option_config_(kBegin) {
options.comparator = new TestKeyComparator(); options.comparator = new TestKeyComparator();
} }
~PrefixTest() { ~PrefixTest() override { delete options.comparator; }
delete options.comparator;
}
protected: protected:
enum OptionConfig { enum OptionConfig {
kBegin, kBegin,

@ -336,7 +336,7 @@ class Repairer {
Env* env; Env* env;
std::shared_ptr<Logger> info_log; std::shared_ptr<Logger> info_log;
uint64_t lognum; uint64_t lognum;
virtual void Corruption(size_t bytes, const Status& s) override { void Corruption(size_t bytes, const Status& s) override {
// We print error messages for corruption, but continue repairing. // We print error messages for corruption, but continue repairing.
ROCKS_LOG_ERROR(info_log, "Log #%" PRIu64 ": dropping %d bytes; %s", ROCKS_LOG_ERROR(info_log, "Log #%" PRIu64 ": dropping %d bytes; %s",
lognum, static_cast<int>(bytes), s.ToString().c_str()); lognum, static_cast<int>(bytes), s.ToString().c_str());

@ -28,7 +28,7 @@ namespace rocksdb {
class TablePropertiesTest : public testing::Test, class TablePropertiesTest : public testing::Test,
public testing::WithParamInterface<bool> { public testing::WithParamInterface<bool> {
public: public:
virtual void SetUp() override { backward_mode_ = GetParam(); } void SetUp() override { backward_mode_ = GetParam(); }
bool backward_mode_; bool backward_mode_;
}; };
@ -106,7 +106,7 @@ class RegularKeysStartWithA: public TablePropertiesCollector {
return Status::OK(); return Status::OK();
} }
virtual UserCollectedProperties GetReadableProperties() const override { UserCollectedProperties GetReadableProperties() const override {
return UserCollectedProperties{}; return UserCollectedProperties{};
} }
@ -143,7 +143,7 @@ class RegularKeysStartWithABackwardCompatible
return Status::OK(); return Status::OK();
} }
virtual UserCollectedProperties GetReadableProperties() const override { UserCollectedProperties GetReadableProperties() const override {
return UserCollectedProperties{}; return UserCollectedProperties{};
} }
@ -172,7 +172,7 @@ class RegularKeysStartWithAInternal : public IntTblPropCollector {
return Status::OK(); return Status::OK();
} }
virtual UserCollectedProperties GetReadableProperties() const override { UserCollectedProperties GetReadableProperties() const override {
return UserCollectedProperties{}; return UserCollectedProperties{};
} }
@ -185,7 +185,7 @@ class RegularKeysStartWithAFactory : public IntTblPropCollectorFactory,
public: public:
explicit RegularKeysStartWithAFactory(bool backward_mode) explicit RegularKeysStartWithAFactory(bool backward_mode)
: backward_mode_(backward_mode) {} : backward_mode_(backward_mode) {}
virtual TablePropertiesCollector* CreateTablePropertiesCollector( TablePropertiesCollector* CreateTablePropertiesCollector(
TablePropertiesCollectorFactory::Context context) override { TablePropertiesCollectorFactory::Context context) override {
EXPECT_EQ(kTestColumnFamilyId, context.column_family_id); EXPECT_EQ(kTestColumnFamilyId, context.column_family_id);
if (!backward_mode_) { if (!backward_mode_) {
@ -194,7 +194,7 @@ class RegularKeysStartWithAFactory : public IntTblPropCollectorFactory,
return new RegularKeysStartWithABackwardCompatible(); return new RegularKeysStartWithABackwardCompatible();
} }
} }
virtual IntTblPropCollector* CreateIntTblPropCollector( IntTblPropCollector* CreateIntTblPropCollector(
uint32_t /*column_family_id*/) override { uint32_t /*column_family_id*/) override {
return new RegularKeysStartWithAInternal(); return new RegularKeysStartWithAInternal();
} }
@ -205,7 +205,7 @@ class RegularKeysStartWithAFactory : public IntTblPropCollectorFactory,
class FlushBlockEveryThreePolicy : public FlushBlockPolicy { class FlushBlockEveryThreePolicy : public FlushBlockPolicy {
public: public:
virtual bool Update(const Slice& /*key*/, const Slice& /*value*/) override { bool Update(const Slice& /*key*/, const Slice& /*value*/) override {
return (++count_ % 3U == 0); return (++count_ % 3U == 0);
} }

@ -168,24 +168,23 @@ class HashLinkListRep : public MemTableRep {
int bucket_entries_logging_threshold, int bucket_entries_logging_threshold,
bool if_log_bucket_dist_when_flash); bool if_log_bucket_dist_when_flash);
virtual KeyHandle Allocate(const size_t len, char** buf) override; KeyHandle Allocate(const size_t len, char** buf) override;
virtual void Insert(KeyHandle handle) override; void Insert(KeyHandle handle) override;
virtual bool Contains(const char* key) const override; bool Contains(const char* key) const override;
virtual size_t ApproximateMemoryUsage() override; size_t ApproximateMemoryUsage() override;
virtual void Get(const LookupKey& k, void* callback_args, void Get(const LookupKey& k, void* callback_args,
bool (*callback_func)(void* arg, bool (*callback_func)(void* arg, const char* entry)) override;
const char* entry)) override;
virtual ~HashLinkListRep(); ~HashLinkListRep() override;
virtual MemTableRep::Iterator* GetIterator(Arena* arena = nullptr) override; MemTableRep::Iterator* GetIterator(Arena* arena = nullptr) override;
virtual MemTableRep::Iterator* GetDynamicPrefixIterator( MemTableRep::Iterator* GetDynamicPrefixIterator(
Arena* arena = nullptr) override; Arena* arena = nullptr) override;
private: private:
friend class DynamicIterator; friend class DynamicIterator;
@ -265,36 +264,34 @@ class HashLinkListRep : public MemTableRep {
explicit FullListIterator(MemtableSkipList* list, Allocator* allocator) explicit FullListIterator(MemtableSkipList* list, Allocator* allocator)
: iter_(list), full_list_(list), allocator_(allocator) {} : iter_(list), full_list_(list), allocator_(allocator) {}
virtual ~FullListIterator() { ~FullListIterator() override {}
}
// Returns true iff the iterator is positioned at a valid node. // Returns true iff the iterator is positioned at a valid node.
virtual bool Valid() const override { return iter_.Valid(); } bool Valid() const override { return iter_.Valid(); }
// Returns the key at the current position. // Returns the key at the current position.
// REQUIRES: Valid() // REQUIRES: Valid()
virtual const char* key() const override { const char* key() const override {
assert(Valid()); assert(Valid());
return iter_.key(); return iter_.key();
} }
// Advances to the next position. // Advances to the next position.
// REQUIRES: Valid() // REQUIRES: Valid()
virtual void Next() override { void Next() override {
assert(Valid()); assert(Valid());
iter_.Next(); iter_.Next();
} }
// Advances to the previous position. // Advances to the previous position.
// REQUIRES: Valid() // REQUIRES: Valid()
virtual void Prev() override { void Prev() override {
assert(Valid()); assert(Valid());
iter_.Prev(); iter_.Prev();
} }
// Advance to the first entry with a key >= target // Advance to the first entry with a key >= target
virtual void Seek(const Slice& internal_key, void Seek(const Slice& internal_key, const char* memtable_key) override {
const char* memtable_key) override {
const char* encoded_key = const char* encoded_key =
(memtable_key != nullptr) ? (memtable_key != nullptr) ?
memtable_key : EncodeKey(&tmp_, internal_key); memtable_key : EncodeKey(&tmp_, internal_key);
@ -302,8 +299,8 @@ class HashLinkListRep : public MemTableRep {
} }
// Retreat to the last entry with a key <= target // Retreat to the last entry with a key <= target
virtual void SeekForPrev(const Slice& internal_key, void SeekForPrev(const Slice& internal_key,
const char* memtable_key) override { const char* memtable_key) override {
const char* encoded_key = (memtable_key != nullptr) const char* encoded_key = (memtable_key != nullptr)
? memtable_key ? memtable_key
: EncodeKey(&tmp_, internal_key); : EncodeKey(&tmp_, internal_key);
@ -312,11 +309,12 @@ class HashLinkListRep : public MemTableRep {
// Position at the first entry in collection. // Position at the first entry in collection.
// Final state of iterator is Valid() iff collection is not empty. // Final state of iterator is Valid() iff collection is not empty.
virtual void SeekToFirst() override { iter_.SeekToFirst(); } void SeekToFirst() override { iter_.SeekToFirst(); }
// Position at the last entry in collection. // Position at the last entry in collection.
// Final state of iterator is Valid() iff collection is not empty. // Final state of iterator is Valid() iff collection is not empty.
virtual void SeekToLast() override { iter_.SeekToLast(); } void SeekToLast() override { iter_.SeekToLast(); }
private: private:
MemtableSkipList::Iterator iter_; MemtableSkipList::Iterator iter_;
// To destruct with the iterator. // To destruct with the iterator.
@ -333,43 +331,43 @@ class HashLinkListRep : public MemTableRep {
head_(head), head_(head),
node_(nullptr) {} node_(nullptr) {}
virtual ~LinkListIterator() {} ~LinkListIterator() override {}
// Returns true iff the iterator is positioned at a valid node. // Returns true iff the iterator is positioned at a valid node.
virtual bool Valid() const override { return node_ != nullptr; } bool Valid() const override { return node_ != nullptr; }
// Returns the key at the current position. // Returns the key at the current position.
// REQUIRES: Valid() // REQUIRES: Valid()
virtual const char* key() const override { const char* key() const override {
assert(Valid()); assert(Valid());
return node_->key; return node_->key;
} }
// Advances to the next position. // Advances to the next position.
// REQUIRES: Valid() // REQUIRES: Valid()
virtual void Next() override { void Next() override {
assert(Valid()); assert(Valid());
node_ = node_->Next(); node_ = node_->Next();
} }
// Advances to the previous position. // Advances to the previous position.
// REQUIRES: Valid() // REQUIRES: Valid()
virtual void Prev() override { void Prev() override {
// Prefix iterator does not support total order. // Prefix iterator does not support total order.
// We simply set the iterator to invalid state // We simply set the iterator to invalid state
Reset(nullptr); Reset(nullptr);
} }
// Advance to the first entry with a key >= target // Advance to the first entry with a key >= target
virtual void Seek(const Slice& internal_key, void Seek(const Slice& internal_key,
const char* /*memtable_key*/) override { const char* /*memtable_key*/) override {
node_ = hash_link_list_rep_->FindGreaterOrEqualInBucket(head_, node_ = hash_link_list_rep_->FindGreaterOrEqualInBucket(head_,
internal_key); internal_key);
} }
// Retreat to the last entry with a key <= target // Retreat to the last entry with a key <= target
virtual void SeekForPrev(const Slice& /*internal_key*/, void SeekForPrev(const Slice& /*internal_key*/,
const char* /*memtable_key*/) override { const char* /*memtable_key*/) override {
// Since we do not support Prev() // Since we do not support Prev()
// We simply do not support SeekForPrev // We simply do not support SeekForPrev
Reset(nullptr); Reset(nullptr);
@ -377,7 +375,7 @@ class HashLinkListRep : public MemTableRep {
// Position at the first entry in collection. // Position at the first entry in collection.
// Final state of iterator is Valid() iff collection is not empty. // Final state of iterator is Valid() iff collection is not empty.
virtual void SeekToFirst() override { void SeekToFirst() override {
// Prefix iterator does not support total order. // Prefix iterator does not support total order.
// We simply set the iterator to invalid state // We simply set the iterator to invalid state
Reset(nullptr); Reset(nullptr);
@ -385,7 +383,7 @@ class HashLinkListRep : public MemTableRep {
// Position at the last entry in collection. // Position at the last entry in collection.
// Final state of iterator is Valid() iff collection is not empty. // Final state of iterator is Valid() iff collection is not empty.
virtual void SeekToLast() override { void SeekToLast() override {
// Prefix iterator does not support total order. // Prefix iterator does not support total order.
// We simply set the iterator to invalid state // We simply set the iterator to invalid state
Reset(nullptr); Reset(nullptr);
@ -414,7 +412,7 @@ class HashLinkListRep : public MemTableRep {
memtable_rep_(memtable_rep) {} memtable_rep_(memtable_rep) {}
// Advance to the first entry with a key >= target // Advance to the first entry with a key >= target
virtual void Seek(const Slice& k, const char* memtable_key) override { void Seek(const Slice& k, const char* memtable_key) override {
auto transformed = memtable_rep_.GetPrefix(k); auto transformed = memtable_rep_.GetPrefix(k);
auto* bucket = memtable_rep_.GetBucket(transformed); auto* bucket = memtable_rep_.GetBucket(transformed);
@ -443,21 +441,21 @@ class HashLinkListRep : public MemTableRep {
} }
} }
virtual bool Valid() const override { bool Valid() const override {
if (skip_list_iter_) { if (skip_list_iter_) {
return skip_list_iter_->Valid(); return skip_list_iter_->Valid();
} }
return HashLinkListRep::LinkListIterator::Valid(); return HashLinkListRep::LinkListIterator::Valid();
} }
virtual const char* key() const override { const char* key() const override {
if (skip_list_iter_) { if (skip_list_iter_) {
return skip_list_iter_->key(); return skip_list_iter_->key();
} }
return HashLinkListRep::LinkListIterator::key(); return HashLinkListRep::LinkListIterator::key();
} }
virtual void Next() override { void Next() override {
if (skip_list_iter_) { if (skip_list_iter_) {
skip_list_iter_->Next(); skip_list_iter_->Next();
} else { } else {
@ -476,19 +474,19 @@ class HashLinkListRep : public MemTableRep {
// instantiating an empty bucket over which to iterate. // instantiating an empty bucket over which to iterate.
public: public:
EmptyIterator() { } EmptyIterator() { }
virtual bool Valid() const override { return false; } bool Valid() const override { return false; }
virtual const char* key() const override { const char* key() const override {
assert(false); assert(false);
return nullptr; return nullptr;
} }
virtual void Next() override {} void Next() override {}
virtual void Prev() override {} void Prev() override {}
virtual void Seek(const Slice& /*user_key*/, void Seek(const Slice& /*user_key*/,
const char* /*memtable_key*/) override {} const char* /*memtable_key*/) override {}
virtual void SeekForPrev(const Slice& /*user_key*/, void SeekForPrev(const Slice& /*user_key*/,
const char* /*memtable_key*/) override {} const char* /*memtable_key*/) override {}
virtual void SeekToFirst() override {} void SeekToFirst() override {}
virtual void SeekToLast() override {} void SeekToLast() override {}
private: private:
}; };

@ -28,21 +28,20 @@ class HashSkipListRep : public MemTableRep {
size_t bucket_size, int32_t skiplist_height, size_t bucket_size, int32_t skiplist_height,
int32_t skiplist_branching_factor); int32_t skiplist_branching_factor);
virtual void Insert(KeyHandle handle) override; void Insert(KeyHandle handle) override;
virtual bool Contains(const char* key) const override; bool Contains(const char* key) const override;
virtual size_t ApproximateMemoryUsage() override; size_t ApproximateMemoryUsage() override;
virtual void Get(const LookupKey& k, void* callback_args, void Get(const LookupKey& k, void* callback_args,
bool (*callback_func)(void* arg, bool (*callback_func)(void* arg, const char* entry)) override;
const char* entry)) override;
virtual ~HashSkipListRep(); ~HashSkipListRep() override;
virtual MemTableRep::Iterator* GetIterator(Arena* arena = nullptr) override; MemTableRep::Iterator* GetIterator(Arena* arena = nullptr) override;
virtual MemTableRep::Iterator* GetDynamicPrefixIterator( MemTableRep::Iterator* GetDynamicPrefixIterator(
Arena* arena = nullptr) override; Arena* arena = nullptr) override;
private: private:
@ -85,7 +84,7 @@ class HashSkipListRep : public MemTableRep {
Arena* arena = nullptr) Arena* arena = nullptr)
: list_(list), iter_(list), own_list_(own_list), arena_(arena) {} : list_(list), iter_(list), own_list_(own_list), arena_(arena) {}
virtual ~Iterator() { ~Iterator() override {
// if we own the list, we should also delete it // if we own the list, we should also delete it
if (own_list_) { if (own_list_) {
assert(list_ != nullptr); assert(list_ != nullptr);
@ -94,34 +93,31 @@ class HashSkipListRep : public MemTableRep {
} }
// Returns true iff the iterator is positioned at a valid node. // Returns true iff the iterator is positioned at a valid node.
virtual bool Valid() const override { bool Valid() const override { return list_ != nullptr && iter_.Valid(); }
return list_ != nullptr && iter_.Valid();
}
// Returns the key at the current position. // Returns the key at the current position.
// REQUIRES: Valid() // REQUIRES: Valid()
virtual const char* key() const override { const char* key() const override {
assert(Valid()); assert(Valid());
return iter_.key(); return iter_.key();
} }
// Advances to the next position. // Advances to the next position.
// REQUIRES: Valid() // REQUIRES: Valid()
virtual void Next() override { void Next() override {
assert(Valid()); assert(Valid());
iter_.Next(); iter_.Next();
} }
// Advances to the previous position. // Advances to the previous position.
// REQUIRES: Valid() // REQUIRES: Valid()
virtual void Prev() override { void Prev() override {
assert(Valid()); assert(Valid());
iter_.Prev(); iter_.Prev();
} }
// Advance to the first entry with a key >= target // Advance to the first entry with a key >= target
virtual void Seek(const Slice& internal_key, void Seek(const Slice& internal_key, const char* memtable_key) override {
const char* memtable_key) override {
if (list_ != nullptr) { if (list_ != nullptr) {
const char* encoded_key = const char* encoded_key =
(memtable_key != nullptr) ? (memtable_key != nullptr) ?
@ -131,15 +127,15 @@ class HashSkipListRep : public MemTableRep {
} }
// Retreat to the last entry with a key <= target // Retreat to the last entry with a key <= target
virtual void SeekForPrev(const Slice& /*internal_key*/, void SeekForPrev(const Slice& /*internal_key*/,
const char* /*memtable_key*/) override { const char* /*memtable_key*/) override {
// not supported // not supported
assert(false); assert(false);
} }
// Position at the first entry in collection. // Position at the first entry in collection.
// Final state of iterator is Valid() iff collection is not empty. // Final state of iterator is Valid() iff collection is not empty.
virtual void SeekToFirst() override { void SeekToFirst() override {
if (list_ != nullptr) { if (list_ != nullptr) {
iter_.SeekToFirst(); iter_.SeekToFirst();
} }
@ -147,11 +143,12 @@ class HashSkipListRep : public MemTableRep {
// Position at the last entry in collection. // Position at the last entry in collection.
// Final state of iterator is Valid() iff collection is not empty. // Final state of iterator is Valid() iff collection is not empty.
virtual void SeekToLast() override { void SeekToLast() override {
if (list_ != nullptr) { if (list_ != nullptr) {
iter_.SeekToLast(); iter_.SeekToLast();
} }
} }
protected: protected:
void Reset(Bucket* list) { void Reset(Bucket* list) {
if (own_list_) { if (own_list_) {
@ -181,7 +178,7 @@ class HashSkipListRep : public MemTableRep {
memtable_rep_(memtable_rep) {} memtable_rep_(memtable_rep) {}
// Advance to the first entry with a key >= target // Advance to the first entry with a key >= target
virtual void Seek(const Slice& k, const char* memtable_key) override { void Seek(const Slice& k, const char* memtable_key) override {
auto transformed = memtable_rep_.transform_->Transform(ExtractUserKey(k)); auto transformed = memtable_rep_.transform_->Transform(ExtractUserKey(k));
Reset(memtable_rep_.GetBucket(transformed)); Reset(memtable_rep_.GetBucket(transformed));
HashSkipListRep::Iterator::Seek(k, memtable_key); HashSkipListRep::Iterator::Seek(k, memtable_key);
@ -189,7 +186,7 @@ class HashSkipListRep : public MemTableRep {
// Position at the first entry in collection. // Position at the first entry in collection.
// Final state of iterator is Valid() iff collection is not empty. // Final state of iterator is Valid() iff collection is not empty.
virtual void SeekToFirst() override { void SeekToFirst() override {
// Prefix iterator does not support total order. // Prefix iterator does not support total order.
// We simply set the iterator to invalid state // We simply set the iterator to invalid state
Reset(nullptr); Reset(nullptr);
@ -197,11 +194,12 @@ class HashSkipListRep : public MemTableRep {
// Position at the last entry in collection. // Position at the last entry in collection.
// Final state of iterator is Valid() iff collection is not empty. // Final state of iterator is Valid() iff collection is not empty.
virtual void SeekToLast() override { void SeekToLast() override {
// Prefix iterator does not support total order. // Prefix iterator does not support total order.
// We simply set the iterator to invalid state // We simply set the iterator to invalid state
Reset(nullptr); Reset(nullptr);
} }
private: private:
// the underlying memtable // the underlying memtable
const HashSkipListRep& memtable_rep_; const HashSkipListRep& memtable_rep_;
@ -212,19 +210,19 @@ class HashSkipListRep : public MemTableRep {
// instantiating an empty bucket over which to iterate. // instantiating an empty bucket over which to iterate.
public: public:
EmptyIterator() { } EmptyIterator() { }
virtual bool Valid() const override { return false; } bool Valid() const override { return false; }
virtual const char* key() const override { const char* key() const override {
assert(false); assert(false);
return nullptr; return nullptr;
} }
virtual void Next() override {} void Next() override {}
virtual void Prev() override {} void Prev() override {}
virtual void Seek(const Slice& /*internal_key*/, void Seek(const Slice& /*internal_key*/,
const char* /*memtable_key*/) override {} const char* /*memtable_key*/) override {}
virtual void SeekForPrev(const Slice& /*internal_key*/, void SeekForPrev(const Slice& /*internal_key*/,
const char* /*memtable_key*/) override {} const char* /*memtable_key*/) override {}
virtual void SeekToFirst() override {} void SeekToFirst() override {}
virtual void SeekToLast() override {} void SeekToLast() override {}
private: private:
}; };

@ -27,57 +27,55 @@ public:
transform_(transform), transform_(transform),
lookahead_(lookahead) {} lookahead_(lookahead) {}
virtual KeyHandle Allocate(const size_t len, char** buf) override { KeyHandle Allocate(const size_t len, char** buf) override {
*buf = skip_list_.AllocateKey(len); *buf = skip_list_.AllocateKey(len);
return static_cast<KeyHandle>(*buf); return static_cast<KeyHandle>(*buf);
} }
// Insert key into the list. // Insert key into the list.
// REQUIRES: nothing that compares equal to key is currently in the list. // REQUIRES: nothing that compares equal to key is currently in the list.
virtual void Insert(KeyHandle handle) override { void Insert(KeyHandle handle) override {
skip_list_.Insert(static_cast<char*>(handle)); skip_list_.Insert(static_cast<char*>(handle));
} }
virtual bool InsertKey(KeyHandle handle) override { bool InsertKey(KeyHandle handle) override {
return skip_list_.Insert(static_cast<char*>(handle)); return skip_list_.Insert(static_cast<char*>(handle));
} }
virtual void InsertWithHint(KeyHandle handle, void** hint) override { void InsertWithHint(KeyHandle handle, void** hint) override {
skip_list_.InsertWithHint(static_cast<char*>(handle), hint); skip_list_.InsertWithHint(static_cast<char*>(handle), hint);
} }
virtual bool InsertKeyWithHint(KeyHandle handle, void** hint) override { bool InsertKeyWithHint(KeyHandle handle, void** hint) override {
return skip_list_.InsertWithHint(static_cast<char*>(handle), hint); return skip_list_.InsertWithHint(static_cast<char*>(handle), hint);
} }
virtual void InsertConcurrently(KeyHandle handle) override { void InsertConcurrently(KeyHandle handle) override {
skip_list_.InsertConcurrently(static_cast<char*>(handle)); skip_list_.InsertConcurrently(static_cast<char*>(handle));
} }
virtual bool InsertKeyConcurrently(KeyHandle handle) override { bool InsertKeyConcurrently(KeyHandle handle) override {
return skip_list_.InsertConcurrently(static_cast<char*>(handle)); return skip_list_.InsertConcurrently(static_cast<char*>(handle));
} }
// Returns true iff an entry that compares equal to key is in the list. // Returns true iff an entry that compares equal to key is in the list.
virtual bool Contains(const char* key) const override { bool Contains(const char* key) const override {
return skip_list_.Contains(key); return skip_list_.Contains(key);
} }
virtual size_t ApproximateMemoryUsage() override { size_t ApproximateMemoryUsage() override {
// All memory is allocated through allocator; nothing to report here // All memory is allocated through allocator; nothing to report here
return 0; return 0;
} }
virtual void Get(const LookupKey& k, void* callback_args, void Get(const LookupKey& k, void* callback_args,
bool (*callback_func)(void* arg, bool (*callback_func)(void* arg, const char* entry)) override {
const char* entry)) override { SkipListRep::Iterator iter(&skip_list_);
SkipListRep::Iterator iter(&skip_list_); Slice dummy_slice;
Slice dummy_slice; for (iter.Seek(dummy_slice, k.memtable_key().data());
for (iter.Seek(dummy_slice, k.memtable_key().data()); iter.Valid() && callback_func(callback_args, iter.key()); iter.Next()) {
iter.Valid() && callback_func(callback_args, iter.key()); }
iter.Next()) { }
}
}
uint64_t ApproximateNumEntries(const Slice& start_ikey, uint64_t ApproximateNumEntries(const Slice& start_ikey,
const Slice& end_ikey) override { const Slice& end_ikey) override {
@ -88,7 +86,7 @@ public:
return (end_count >= start_count) ? (end_count - start_count) : 0; return (end_count >= start_count) ? (end_count - start_count) : 0;
} }
virtual ~SkipListRep() override { } ~SkipListRep() override {}
// Iteration over the contents of a skip list // Iteration over the contents of a skip list
class Iterator : public MemTableRep::Iterator { class Iterator : public MemTableRep::Iterator {
@ -101,34 +99,25 @@ public:
const InlineSkipList<const MemTableRep::KeyComparator&>* list) const InlineSkipList<const MemTableRep::KeyComparator&>* list)
: iter_(list) {} : iter_(list) {}
virtual ~Iterator() override { } ~Iterator() override {}
// Returns true iff the iterator is positioned at a valid node. // Returns true iff the iterator is positioned at a valid node.
virtual bool Valid() const override { bool Valid() const override { return iter_.Valid(); }
return iter_.Valid();
}
// Returns the key at the current position. // Returns the key at the current position.
// REQUIRES: Valid() // REQUIRES: Valid()
virtual const char* key() const override { const char* key() const override { return iter_.key(); }
return iter_.key();
}
// Advances to the next position. // Advances to the next position.
// REQUIRES: Valid() // REQUIRES: Valid()
virtual void Next() override { void Next() override { iter_.Next(); }
iter_.Next();
}
// Advances to the previous position. // Advances to the previous position.
// REQUIRES: Valid() // REQUIRES: Valid()
virtual void Prev() override { void Prev() override { iter_.Prev(); }
iter_.Prev();
}
// Advance to the first entry with a key >= target // Advance to the first entry with a key >= target
virtual void Seek(const Slice& user_key, const char* memtable_key) void Seek(const Slice& user_key, const char* memtable_key) override {
override {
if (memtable_key != nullptr) { if (memtable_key != nullptr) {
iter_.Seek(memtable_key); iter_.Seek(memtable_key);
} else { } else {
@ -137,8 +126,7 @@ public:
} }
// Retreat to the last entry with a key <= target // Retreat to the last entry with a key <= target
virtual void SeekForPrev(const Slice& user_key, void SeekForPrev(const Slice& user_key, const char* memtable_key) override {
const char* memtable_key) override {
if (memtable_key != nullptr) { if (memtable_key != nullptr) {
iter_.SeekForPrev(memtable_key); iter_.SeekForPrev(memtable_key);
} else { } else {
@ -148,15 +136,12 @@ public:
// Position at the first entry in list. // Position at the first entry in list.
// Final state of iterator is Valid() iff list is not empty. // Final state of iterator is Valid() iff list is not empty.
virtual void SeekToFirst() override { void SeekToFirst() override { iter_.SeekToFirst(); }
iter_.SeekToFirst();
}
// Position at the last entry in list. // Position at the last entry in list.
// Final state of iterator is Valid() iff list is not empty. // Final state of iterator is Valid() iff list is not empty.
virtual void SeekToLast() override { void SeekToLast() override { iter_.SeekToLast(); }
iter_.SeekToLast();
}
protected: protected:
std::string tmp_; // For passing to EncodeKey std::string tmp_; // For passing to EncodeKey
}; };
@ -170,18 +155,16 @@ public:
explicit LookaheadIterator(const SkipListRep& rep) : explicit LookaheadIterator(const SkipListRep& rep) :
rep_(rep), iter_(&rep_.skip_list_), prev_(iter_) {} rep_(rep), iter_(&rep_.skip_list_), prev_(iter_) {}
virtual ~LookaheadIterator() override {} ~LookaheadIterator() override {}
virtual bool Valid() const override { bool Valid() const override { return iter_.Valid(); }
return iter_.Valid();
}
virtual const char *key() const override { const char* key() const override {
assert(Valid()); assert(Valid());
return iter_.key(); return iter_.key();
} }
virtual void Next() override { void Next() override {
assert(Valid()); assert(Valid());
bool advance_prev = true; bool advance_prev = true;
@ -206,14 +189,13 @@ public:
iter_.Next(); iter_.Next();
} }
virtual void Prev() override { void Prev() override {
assert(Valid()); assert(Valid());
iter_.Prev(); iter_.Prev();
prev_ = iter_; prev_ = iter_;
} }
virtual void Seek(const Slice& internal_key, const char *memtable_key) void Seek(const Slice& internal_key, const char* memtable_key) override {
override {
const char *encoded_key = const char *encoded_key =
(memtable_key != nullptr) ? (memtable_key != nullptr) ?
memtable_key : EncodeKey(&tmp_, internal_key); memtable_key : EncodeKey(&tmp_, internal_key);
@ -236,8 +218,8 @@ public:
prev_ = iter_; prev_ = iter_;
} }
virtual void SeekForPrev(const Slice& internal_key, void SeekForPrev(const Slice& internal_key,
const char* memtable_key) override { const char* memtable_key) override {
const char* encoded_key = (memtable_key != nullptr) const char* encoded_key = (memtable_key != nullptr)
? memtable_key ? memtable_key
: EncodeKey(&tmp_, internal_key); : EncodeKey(&tmp_, internal_key);
@ -245,12 +227,12 @@ public:
prev_ = iter_; prev_ = iter_;
} }
virtual void SeekToFirst() override { void SeekToFirst() override {
iter_.SeekToFirst(); iter_.SeekToFirst();
prev_ = iter_; prev_ = iter_;
} }
virtual void SeekToLast() override { void SeekToLast() override {
iter_.SeekToLast(); iter_.SeekToLast();
prev_ = iter_; prev_ = iter_;
} }
@ -264,7 +246,7 @@ public:
InlineSkipList<const MemTableRep::KeyComparator&>::Iterator prev_; InlineSkipList<const MemTableRep::KeyComparator&>::Iterator prev_;
}; };
virtual MemTableRep::Iterator* GetIterator(Arena* arena = nullptr) override { MemTableRep::Iterator* GetIterator(Arena* arena = nullptr) override {
if (lookahead_ > 0) { if (lookahead_ > 0) {
void *mem = void *mem =
arena ? arena->AllocateAligned(sizeof(SkipListRep::LookaheadIterator)) arena ? arena->AllocateAligned(sizeof(SkipListRep::LookaheadIterator))

@ -31,20 +31,19 @@ class VectorRep : public MemTableRep {
// single buffer and pass that in as the parameter to Insert) // single buffer and pass that in as the parameter to Insert)
// REQUIRES: nothing that compares equal to key is currently in the // REQUIRES: nothing that compares equal to key is currently in the
// collection. // collection.
virtual void Insert(KeyHandle handle) override; void Insert(KeyHandle handle) override;
// Returns true iff an entry that compares equal to key is in the collection. // Returns true iff an entry that compares equal to key is in the collection.
virtual bool Contains(const char* key) const override; bool Contains(const char* key) const override;
virtual void MarkReadOnly() override; void MarkReadOnly() override;
virtual size_t ApproximateMemoryUsage() override; size_t ApproximateMemoryUsage() override;
virtual void Get(const LookupKey& k, void* callback_args, void Get(const LookupKey& k, void* callback_args,
bool (*callback_func)(void* arg, bool (*callback_func)(void* arg, const char* entry)) override;
const char* entry)) override;
virtual ~VectorRep() override { } ~VectorRep() override {}
class Iterator : public MemTableRep::Iterator { class Iterator : public MemTableRep::Iterator {
class VectorRep* vrep_; class VectorRep* vrep_;
@ -62,41 +61,40 @@ class VectorRep : public MemTableRep {
// Initialize an iterator over the specified collection. // Initialize an iterator over the specified collection.
// The returned iterator is not valid. // The returned iterator is not valid.
// explicit Iterator(const MemTableRep* collection); // explicit Iterator(const MemTableRep* collection);
virtual ~Iterator() override { }; ~Iterator() override{};
// Returns true iff the iterator is positioned at a valid node. // Returns true iff the iterator is positioned at a valid node.
virtual bool Valid() const override; bool Valid() const override;
// Returns the key at the current position. // Returns the key at the current position.
// REQUIRES: Valid() // REQUIRES: Valid()
virtual const char* key() const override; const char* key() const override;
// Advances to the next position. // Advances to the next position.
// REQUIRES: Valid() // REQUIRES: Valid()
virtual void Next() override; void Next() override;
// Advances to the previous position. // Advances to the previous position.
// REQUIRES: Valid() // REQUIRES: Valid()
virtual void Prev() override; void Prev() override;
// Advance to the first entry with a key >= target // Advance to the first entry with a key >= target
virtual void Seek(const Slice& user_key, const char* memtable_key) override; void Seek(const Slice& user_key, const char* memtable_key) override;
// Advance to the first entry with a key <= target // Advance to the first entry with a key <= target
virtual void SeekForPrev(const Slice& user_key, void SeekForPrev(const Slice& user_key, const char* memtable_key) override;
const char* memtable_key) override;
// Position at the first entry in collection. // Position at the first entry in collection.
// Final state of iterator is Valid() iff collection is not empty. // Final state of iterator is Valid() iff collection is not empty.
virtual void SeekToFirst() override; void SeekToFirst() override;
// Position at the last entry in collection. // Position at the last entry in collection.
// Final state of iterator is Valid() iff collection is not empty. // Final state of iterator is Valid() iff collection is not empty.
virtual void SeekToLast() override; void SeekToLast() override;
}; };
// Return an iterator over the keys in this representation. // Return an iterator over the keys in this representation.
virtual MemTableRep::Iterator* GetIterator(Arena* arena) override; MemTableRep::Iterator* GetIterator(Arena* arena) override;
private: private:
friend class Iterator; friend class Iterator;

@ -21,18 +21,16 @@ namespace rocksdb {
// For testing: emit an array with one hash value per key // For testing: emit an array with one hash value per key
class TestHashFilter : public FilterPolicy { class TestHashFilter : public FilterPolicy {
public: public:
virtual const char* Name() const override { return "TestHashFilter"; } const char* Name() const override { return "TestHashFilter"; }
virtual void CreateFilter(const Slice* keys, int n, void CreateFilter(const Slice* keys, int n, std::string* dst) const override {
std::string* dst) const override {
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
uint32_t h = Hash(keys[i].data(), keys[i].size(), 1); uint32_t h = Hash(keys[i].data(), keys[i].size(), 1);
PutFixed32(dst, h); PutFixed32(dst, h);
} }
} }
virtual bool KeyMayMatch(const Slice& key, bool KeyMayMatch(const Slice& key, const Slice& filter) const override {
const Slice& filter) const override {
uint32_t h = Hash(key.data(), key.size(), 1); uint32_t h = Hash(key.data(), key.size(), 1);
for (unsigned int i = 0; i + 4 <= filter.size(); i += 4) { for (unsigned int i = 0; i + 4 <= filter.size(); i += 4) {
if (h == DecodeFixed32(filter.data() + i)) { if (h == DecodeFixed32(filter.data() + i)) {
@ -146,7 +144,7 @@ class BlockBasedFilterBlockTest : public testing::Test {
table_options_.filter_policy.reset(NewBloomFilterPolicy(10)); table_options_.filter_policy.reset(NewBloomFilterPolicy(10));
} }
~BlockBasedFilterBlockTest() {} ~BlockBasedFilterBlockTest() override {}
}; };
TEST_F(BlockBasedFilterBlockTest, BlockBasedEmptyBuilder) { TEST_F(BlockBasedFilterBlockTest, BlockBasedEmptyBuilder) {

@ -210,14 +210,14 @@ class BlockBasedTableBuilder::BlockBasedTablePropertiesCollector
whole_key_filtering_(whole_key_filtering), whole_key_filtering_(whole_key_filtering),
prefix_filtering_(prefix_filtering) {} prefix_filtering_(prefix_filtering) {}
virtual Status InternalAdd(const Slice& /*key*/, const Slice& /*value*/, Status InternalAdd(const Slice& /*key*/, const Slice& /*value*/,
uint64_t /*file_size*/) override { uint64_t /*file_size*/) override {
// Intentionally left blank. Have no interest in collecting stats for // Intentionally left blank. Have no interest in collecting stats for
// individual key/value pairs. // individual key/value pairs.
return Status::OK(); return Status::OK();
} }
virtual Status Finish(UserCollectedProperties* properties) override { Status Finish(UserCollectedProperties* properties) override {
std::string val; std::string val;
PutFixed32(&val, static_cast<uint32_t>(index_type_)); PutFixed32(&val, static_cast<uint32_t>(index_type_));
properties->insert({BlockBasedTablePropertyNames::kIndexType, val}); properties->insert({BlockBasedTablePropertyNames::kIndexType, val});
@ -229,11 +229,11 @@ class BlockBasedTableBuilder::BlockBasedTablePropertiesCollector
} }
// The name of the properties collector can be used for debugging purpose. // The name of the properties collector can be used for debugging purpose.
virtual const char* Name() const override { const char* Name() const override {
return "BlockBasedTablePropertiesCollector"; return "BlockBasedTablePropertiesCollector";
} }
virtual UserCollectedProperties GetReadableProperties() const override { UserCollectedProperties GetReadableProperties() const override {
// Intentionally left blank. // Intentionally left blank.
return UserCollectedProperties(); return UserCollectedProperties();
} }

@ -259,7 +259,7 @@ class PartitionIndexReader : public IndexReader, public Cleanable {
} }
// return a two-level iterator: first level is on the partition index // return a two-level iterator: first level is on the partition index
virtual InternalIteratorBase<BlockHandle>* NewIterator( InternalIteratorBase<BlockHandle>* NewIterator(
IndexBlockIter* /*iter*/ = nullptr, bool /*dont_care*/ = true, IndexBlockIter* /*iter*/ = nullptr, bool /*dont_care*/ = true,
bool fill_cache = true) override { bool fill_cache = true) override {
Statistics* kNullStats = nullptr; Statistics* kNullStats = nullptr;
@ -294,7 +294,7 @@ class PartitionIndexReader : public IndexReader, public Cleanable {
// in its destructor. // in its destructor.
} }
virtual void CacheDependencies(bool pin) override { void CacheDependencies(bool pin) override {
// Before read partitions, prefetch them to avoid lots of IOs // Before read partitions, prefetch them to avoid lots of IOs
auto rep = table_->rep_; auto rep = table_->rep_;
IndexBlockIter biter; IndexBlockIter biter;
@ -362,12 +362,10 @@ class PartitionIndexReader : public IndexReader, public Cleanable {
} }
} }
virtual size_t size() const override { return index_block_->size(); } size_t size() const override { return index_block_->size(); }
virtual size_t usable_size() const override { size_t usable_size() const override { return index_block_->usable_size(); }
return index_block_->usable_size();
}
virtual size_t ApproximateMemoryUsage() const override { size_t ApproximateMemoryUsage() const override {
assert(index_block_); assert(index_block_);
size_t usage = index_block_->ApproximateMemoryUsage(); size_t usage = index_block_->ApproximateMemoryUsage();
#ifdef ROCKSDB_MALLOC_USABLE_SIZE #ifdef ROCKSDB_MALLOC_USABLE_SIZE
@ -436,7 +434,7 @@ class BinarySearchIndexReader : public IndexReader {
return s; return s;
} }
virtual InternalIteratorBase<BlockHandle>* NewIterator( InternalIteratorBase<BlockHandle>* NewIterator(
IndexBlockIter* iter = nullptr, bool /*dont_care*/ = true, IndexBlockIter* iter = nullptr, bool /*dont_care*/ = true,
bool /*dont_care*/ = true) override { bool /*dont_care*/ = true) override {
Statistics* kNullStats = nullptr; Statistics* kNullStats = nullptr;
@ -447,12 +445,10 @@ class BinarySearchIndexReader : public IndexReader {
index_key_includes_seq_, index_value_is_full_); index_key_includes_seq_, index_value_is_full_);
} }
virtual size_t size() const override { return index_block_->size(); } size_t size() const override { return index_block_->size(); }
virtual size_t usable_size() const override { size_t usable_size() const override { return index_block_->usable_size(); }
return index_block_->usable_size();
}
virtual size_t ApproximateMemoryUsage() const override { size_t ApproximateMemoryUsage() const override {
assert(index_block_); assert(index_block_);
size_t usage = index_block_->ApproximateMemoryUsage(); size_t usage = index_block_->ApproximateMemoryUsage();
#ifdef ROCKSDB_MALLOC_USABLE_SIZE #ifdef ROCKSDB_MALLOC_USABLE_SIZE
@ -566,7 +562,7 @@ class HashIndexReader : public IndexReader {
return Status::OK(); return Status::OK();
} }
virtual InternalIteratorBase<BlockHandle>* NewIterator( InternalIteratorBase<BlockHandle>* NewIterator(
IndexBlockIter* iter = nullptr, bool total_order_seek = true, IndexBlockIter* iter = nullptr, bool total_order_seek = true,
bool /*dont_care*/ = true) override { bool /*dont_care*/ = true) override {
Statistics* kNullStats = nullptr; Statistics* kNullStats = nullptr;
@ -578,12 +574,10 @@ class HashIndexReader : public IndexReader {
false /* block_contents_pinned */, prefix_index_.get()); false /* block_contents_pinned */, prefix_index_.get());
} }
virtual size_t size() const override { return index_block_->size(); } size_t size() const override { return index_block_->size(); }
virtual size_t usable_size() const override { size_t usable_size() const override { return index_block_->usable_size(); }
return index_block_->usable_size();
}
virtual size_t ApproximateMemoryUsage() const override { size_t ApproximateMemoryUsage() const override {
assert(index_block_); assert(index_block_);
size_t usage = index_block_->ApproximateMemoryUsage(); size_t usage = index_block_->ApproximateMemoryUsage();
usage += prefixes_contents_.usable_size(); usage += prefixes_contents_.usable_size();
@ -610,7 +604,7 @@ class HashIndexReader : public IndexReader {
assert(index_block_ != nullptr); assert(index_block_ != nullptr);
} }
~HashIndexReader() {} ~HashIndexReader() override {}
std::unique_ptr<Block> index_block_; std::unique_ptr<Block> index_block_;
std::unique_ptr<BlockPrefixIndex> prefix_index_; std::unique_ptr<BlockPrefixIndex> prefix_index_;

@ -197,7 +197,7 @@ void CuckooTableReader::Prepare(const Slice& key) {
class CuckooTableIterator : public InternalIterator { class CuckooTableIterator : public InternalIterator {
public: public:
explicit CuckooTableIterator(CuckooTableReader* reader); explicit CuckooTableIterator(CuckooTableReader* reader);
~CuckooTableIterator() {} ~CuckooTableIterator() override {}
bool Valid() const override; bool Valid() const override;
void SeekToFirst() override; void SeekToFirst() override;
void SeekToLast() override; void SeekToLast() override;

@ -30,8 +30,7 @@ class FlushBlockBySizePolicy : public FlushBlockPolicy {
align_(align), align_(align),
data_block_builder_(data_block_builder) {} data_block_builder_(data_block_builder) {}
virtual bool Update(const Slice& key, bool Update(const Slice& key, const Slice& value) override {
const Slice& value) override {
// it makes no sense to flush when the data block is empty // it makes no sense to flush when the data block is empty
if (data_block_builder_.empty()) { if (data_block_builder_.empty()) {
return false; return false;

@ -20,12 +20,12 @@ class TestFilterBitsBuilder : public FilterBitsBuilder {
explicit TestFilterBitsBuilder() {} explicit TestFilterBitsBuilder() {}
// Add Key to filter // Add Key to filter
virtual void AddKey(const Slice& key) override { void AddKey(const Slice& key) override {
hash_entries_.push_back(Hash(key.data(), key.size(), 1)); hash_entries_.push_back(Hash(key.data(), key.size(), 1));
} }
// Generate the filter using the keys that are added // Generate the filter using the keys that are added
virtual Slice Finish(std::unique_ptr<const char[]>* buf) override { Slice Finish(std::unique_ptr<const char[]>* buf) override {
uint32_t len = static_cast<uint32_t>(hash_entries_.size()) * 4; uint32_t len = static_cast<uint32_t>(hash_entries_.size()) * 4;
char* data = new char[len]; char* data = new char[len];
for (size_t i = 0; i < hash_entries_.size(); i++) { for (size_t i = 0; i < hash_entries_.size(); i++) {
@ -45,7 +45,7 @@ class TestFilterBitsReader : public FilterBitsReader {
explicit TestFilterBitsReader(const Slice& contents) explicit TestFilterBitsReader(const Slice& contents)
: data_(contents.data()), len_(static_cast<uint32_t>(contents.size())) {} : data_(contents.data()), len_(static_cast<uint32_t>(contents.size())) {}
virtual bool MayMatch(const Slice& entry) override { bool MayMatch(const Slice& entry) override {
uint32_t h = Hash(entry.data(), entry.size(), 1); uint32_t h = Hash(entry.data(), entry.size(), 1);
for (size_t i = 0; i + 4 <= len_; i += 4) { for (size_t i = 0; i + 4 <= len_; i += 4) {
if (h == DecodeFixed32(data_ + i)) { if (h == DecodeFixed32(data_ + i)) {
@ -63,18 +63,16 @@ class TestFilterBitsReader : public FilterBitsReader {
class TestHashFilter : public FilterPolicy { class TestHashFilter : public FilterPolicy {
public: public:
virtual const char* Name() const override { return "TestHashFilter"; } const char* Name() const override { return "TestHashFilter"; }
virtual void CreateFilter(const Slice* keys, int n, void CreateFilter(const Slice* keys, int n, std::string* dst) const override {
std::string* dst) const override {
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
uint32_t h = Hash(keys[i].data(), keys[i].size(), 1); uint32_t h = Hash(keys[i].data(), keys[i].size(), 1);
PutFixed32(dst, h); PutFixed32(dst, h);
} }
} }
virtual bool KeyMayMatch(const Slice& key, bool KeyMayMatch(const Slice& key, const Slice& filter) const override {
const Slice& filter) const override {
uint32_t h = Hash(key.data(), key.size(), 1); uint32_t h = Hash(key.data(), key.size(), 1);
for (unsigned int i = 0; i + 4 <= filter.size(); i += 4) { for (unsigned int i = 0; i + 4 <= filter.size(); i += 4) {
if (h == DecodeFixed32(filter.data() + i)) { if (h == DecodeFixed32(filter.data() + i)) {
@ -84,12 +82,11 @@ class TestHashFilter : public FilterPolicy {
return false; return false;
} }
virtual FilterBitsBuilder* GetFilterBitsBuilder() const override { FilterBitsBuilder* GetFilterBitsBuilder() const override {
return new TestFilterBitsBuilder(); return new TestFilterBitsBuilder();
} }
virtual FilterBitsReader* GetFilterBitsReader(const Slice& contents) FilterBitsReader* GetFilterBitsReader(const Slice& contents) const override {
const override {
return new TestFilterBitsReader(contents); return new TestFilterBitsReader(contents);
} }
}; };
@ -145,7 +142,7 @@ class FullFilterBlockTest : public testing::Test {
table_options_.filter_policy.reset(NewBloomFilterPolicy(10, false)); table_options_.filter_policy.reset(NewBloomFilterPolicy(10, false));
} }
~FullFilterBlockTest() {} ~FullFilterBlockTest() override {}
}; };
TEST_F(FullFilterBlockTest, EmptyBuilder) { TEST_F(FullFilterBlockTest, EmptyBuilder) {

@ -110,13 +110,13 @@ namespace {
class EmptyIterator : public Iterator { class EmptyIterator : public Iterator {
public: public:
explicit EmptyIterator(const Status& s) : status_(s) { } explicit EmptyIterator(const Status& s) : status_(s) { }
virtual bool Valid() const override { return false; } bool Valid() const override { return false; }
virtual void Seek(const Slice& /*target*/) override {} void Seek(const Slice& /*target*/) override {}
virtual void SeekForPrev(const Slice& /*target*/) override {} void SeekForPrev(const Slice& /*target*/) override {}
virtual void SeekToFirst() override {} void SeekToFirst() override {}
virtual void SeekToLast() override {} void SeekToLast() override {}
virtual void Next() override { assert(false); } void Next() override { assert(false); }
virtual void Prev() override { assert(false); } void Prev() override { assert(false); }
Slice key() const override { Slice key() const override {
assert(false); assert(false);
return Slice(); return Slice();
@ -125,7 +125,7 @@ class EmptyIterator : public Iterator {
assert(false); assert(false);
return Slice(); return Slice();
} }
virtual Status status() const override { return status_; } Status status() const override { return status_; }
private: private:
Status status_; Status status_;
@ -135,13 +135,13 @@ template <class TValue = Slice>
class EmptyInternalIterator : public InternalIteratorBase<TValue> { class EmptyInternalIterator : public InternalIteratorBase<TValue> {
public: public:
explicit EmptyInternalIterator(const Status& s) : status_(s) {} explicit EmptyInternalIterator(const Status& s) : status_(s) {}
virtual bool Valid() const override { return false; } bool Valid() const override { return false; }
virtual void Seek(const Slice& /*target*/) override {} void Seek(const Slice& /*target*/) override {}
virtual void SeekForPrev(const Slice& /*target*/) override {} void SeekForPrev(const Slice& /*target*/) override {}
virtual void SeekToFirst() override {} void SeekToFirst() override {}
virtual void SeekToLast() override {} void SeekToLast() override {}
virtual void Next() override { assert(false); } void Next() override { assert(false); }
virtual void Prev() override { assert(false); } void Prev() override { assert(false); }
Slice key() const override { Slice key() const override {
assert(false); assert(false);
return Slice(); return Slice();
@ -150,7 +150,7 @@ class EmptyInternalIterator : public InternalIteratorBase<TValue> {
assert(false); assert(false);
return TValue(); return TValue();
} }
virtual Status status() const override { return status_; } Status status() const override { return status_; }
private: private:
Status status_; Status status_;

@ -19,7 +19,7 @@ class MergerTest : public testing::Test {
rnd_(3), rnd_(3),
merging_iterator_(nullptr), merging_iterator_(nullptr),
single_iterator_(nullptr) {} single_iterator_(nullptr) {}
~MergerTest() = default; ~MergerTest() override = default;
std::vector<std::string> GenerateStrings(size_t len, int string_len) { std::vector<std::string> GenerateStrings(size_t len, int string_len) {
std::vector<std::string> ret; std::vector<std::string> ret;

@ -83,19 +83,17 @@ class MergingIterator : public InternalIterator {
} }
} }
virtual ~MergingIterator() { ~MergingIterator() override {
for (auto& child : children_) { for (auto& child : children_) {
child.DeleteIter(is_arena_mode_); child.DeleteIter(is_arena_mode_);
} }
} }
virtual bool Valid() const override { bool Valid() const override { return current_ != nullptr && status_.ok(); }
return current_ != nullptr && status_.ok();
}
virtual Status status() const override { return status_; } Status status() const override { return status_; }
virtual void SeekToFirst() override { void SeekToFirst() override {
ClearHeaps(); ClearHeaps();
status_ = Status::OK(); status_ = Status::OK();
for (auto& child : children_) { for (auto& child : children_) {
@ -111,7 +109,7 @@ class MergingIterator : public InternalIterator {
current_ = CurrentForward(); current_ = CurrentForward();
} }
virtual void SeekToLast() override { void SeekToLast() override {
ClearHeaps(); ClearHeaps();
InitMaxHeap(); InitMaxHeap();
status_ = Status::OK(); status_ = Status::OK();
@ -128,7 +126,7 @@ class MergingIterator : public InternalIterator {
current_ = CurrentReverse(); current_ = CurrentReverse();
} }
virtual void Seek(const Slice& target) override { void Seek(const Slice& target) override {
ClearHeaps(); ClearHeaps();
status_ = Status::OK(); status_ = Status::OK();
for (auto& child : children_) { for (auto& child : children_) {
@ -153,7 +151,7 @@ class MergingIterator : public InternalIterator {
} }
} }
virtual void SeekForPrev(const Slice& target) override { void SeekForPrev(const Slice& target) override {
ClearHeaps(); ClearHeaps();
InitMaxHeap(); InitMaxHeap();
status_ = Status::OK(); status_ = Status::OK();
@ -180,7 +178,7 @@ class MergingIterator : public InternalIterator {
} }
} }
virtual void Next() override { void Next() override {
assert(Valid()); assert(Valid());
// Ensure that all children are positioned after key(). // Ensure that all children are positioned after key().
@ -214,7 +212,7 @@ class MergingIterator : public InternalIterator {
current_ = CurrentForward(); current_ = CurrentForward();
} }
virtual void Prev() override { void Prev() override {
assert(Valid()); assert(Valid());
// Ensure that all children are positioned before key(). // Ensure that all children are positioned before key().
// If we are moving in the reverse direction, it is already // If we are moving in the reverse direction, it is already
@ -273,31 +271,30 @@ class MergingIterator : public InternalIterator {
current_ = CurrentReverse(); current_ = CurrentReverse();
} }
virtual Slice key() const override { Slice key() const override {
assert(Valid()); assert(Valid());
return current_->key(); return current_->key();
} }
virtual Slice value() const override { Slice value() const override {
assert(Valid()); assert(Valid());
return current_->value(); return current_->value();
} }
virtual void SetPinnedItersMgr( void SetPinnedItersMgr(PinnedIteratorsManager* pinned_iters_mgr) override {
PinnedIteratorsManager* pinned_iters_mgr) override {
pinned_iters_mgr_ = pinned_iters_mgr; pinned_iters_mgr_ = pinned_iters_mgr;
for (auto& child : children_) { for (auto& child : children_) {
child.SetPinnedItersMgr(pinned_iters_mgr); child.SetPinnedItersMgr(pinned_iters_mgr);
} }
} }
virtual bool IsKeyPinned() const override { bool IsKeyPinned() const override {
assert(Valid()); assert(Valid());
return pinned_iters_mgr_ && pinned_iters_mgr_->PinningEnabled() && return pinned_iters_mgr_ && pinned_iters_mgr_->PinningEnabled() &&
current_->IsKeyPinned(); current_->IsKeyPinned();
} }
virtual bool IsValuePinned() const override { bool IsValuePinned() const override {
assert(Valid()); assert(Valid());
return pinned_iters_mgr_ && pinned_iters_mgr_->PinningEnabled() && return pinned_iters_mgr_ && pinned_iters_mgr_->PinningEnabled() &&
current_->IsValuePinned(); current_->IsValuePinned();

@ -27,7 +27,7 @@ class MockedBlockBasedTable : public BlockBasedTable {
rep->cache_key_prefix_size = 10; rep->cache_key_prefix_size = 10;
} }
virtual CachableEntry<FilterBlockReader> GetFilter( CachableEntry<FilterBlockReader> GetFilter(
FilePrefetchBuffer*, const BlockHandle& filter_blk_handle, FilePrefetchBuffer*, const BlockHandle& filter_blk_handle,
const bool /* unused */, bool /* unused */, GetContext* /* unused */, const bool /* unused */, bool /* unused */, GetContext* /* unused */,
const SliceTransform* prefix_extractor) const override { const SliceTransform* prefix_extractor) const override {
@ -38,7 +38,7 @@ class MockedBlockBasedTable : public BlockBasedTable {
return {obj, nullptr}; return {obj, nullptr};
} }
virtual FilterBlockReader* ReadFilter( FilterBlockReader* ReadFilter(
FilePrefetchBuffer*, const BlockHandle& filter_blk_handle, FilePrefetchBuffer*, const BlockHandle& filter_blk_handle,
const bool /* unused */, const bool /* unused */,
const SliceTransform* prefix_extractor) const override { const SliceTransform* prefix_extractor) const override {
@ -67,7 +67,7 @@ class PartitionedFilterBlockTest
} }
std::shared_ptr<Cache> cache_; std::shared_ptr<Cache> cache_;
~PartitionedFilterBlockTest() {} ~PartitionedFilterBlockTest() override {}
const std::string keys[4] = {"afoo", "bar", "box", "hello"}; const std::string keys[4] = {"afoo", "bar", "box", "hello"};
const std::string missing_keys[2] = {"missing", "other"}; const std::string missing_keys[2] = {"missing", "other"};

@ -54,7 +54,7 @@ inline uint32_t GetFixed32Element(const char* base, size_t offset) {
class PlainTableIterator : public InternalIterator { class PlainTableIterator : public InternalIterator {
public: public:
explicit PlainTableIterator(PlainTableReader* table, bool use_prefix_seek); explicit PlainTableIterator(PlainTableReader* table, bool use_prefix_seek);
~PlainTableIterator(); ~PlainTableIterator() override;
bool Valid() const override; bool Valid() const override;

@ -65,17 +65,17 @@ namespace {
// DummyPropertiesCollector used to test BlockBasedTableProperties // DummyPropertiesCollector used to test BlockBasedTableProperties
class DummyPropertiesCollector : public TablePropertiesCollector { class DummyPropertiesCollector : public TablePropertiesCollector {
public: public:
const char* Name() const { return ""; } const char* Name() const override { return ""; }
Status Finish(UserCollectedProperties* /*properties*/) { Status Finish(UserCollectedProperties* /*properties*/) override {
return Status::OK(); return Status::OK();
} }
Status Add(const Slice& /*user_key*/, const Slice& /*value*/) { Status Add(const Slice& /*user_key*/, const Slice& /*value*/) override {
return Status::OK(); return Status::OK();
} }
virtual UserCollectedProperties GetReadableProperties() const { UserCollectedProperties GetReadableProperties() const override {
return UserCollectedProperties{}; return UserCollectedProperties{};
} }
}; };
@ -83,21 +83,21 @@ class DummyPropertiesCollector : public TablePropertiesCollector {
class DummyPropertiesCollectorFactory1 class DummyPropertiesCollectorFactory1
: public TablePropertiesCollectorFactory { : public TablePropertiesCollectorFactory {
public: public:
virtual TablePropertiesCollector* CreateTablePropertiesCollector( TablePropertiesCollector* CreateTablePropertiesCollector(
TablePropertiesCollectorFactory::Context /*context*/) { TablePropertiesCollectorFactory::Context /*context*/) override {
return new DummyPropertiesCollector(); return new DummyPropertiesCollector();
} }
const char* Name() const { return "DummyPropertiesCollector1"; } const char* Name() const override { return "DummyPropertiesCollector1"; }
}; };
class DummyPropertiesCollectorFactory2 class DummyPropertiesCollectorFactory2
: public TablePropertiesCollectorFactory { : public TablePropertiesCollectorFactory {
public: public:
virtual TablePropertiesCollector* CreateTablePropertiesCollector( TablePropertiesCollector* CreateTablePropertiesCollector(
TablePropertiesCollectorFactory::Context /*context*/) { TablePropertiesCollectorFactory::Context /*context*/) override {
return new DummyPropertiesCollector(); return new DummyPropertiesCollector();
} }
const char* Name() const { return "DummyPropertiesCollector2"; } const char* Name() const override { return "DummyPropertiesCollector2"; }
}; };
// Return reverse of "key". // Return reverse of "key".
@ -110,23 +110,23 @@ std::string Reverse(const Slice& key) {
class ReverseKeyComparator : public Comparator { class ReverseKeyComparator : public Comparator {
public: public:
virtual const char* Name() const override { const char* Name() const override {
return "rocksdb.ReverseBytewiseComparator"; return "rocksdb.ReverseBytewiseComparator";
} }
virtual int Compare(const Slice& a, const Slice& b) const override { int Compare(const Slice& a, const Slice& b) const override {
return BytewiseComparator()->Compare(Reverse(a), Reverse(b)); return BytewiseComparator()->Compare(Reverse(a), Reverse(b));
} }
virtual void FindShortestSeparator(std::string* start, void FindShortestSeparator(std::string* start,
const Slice& limit) const override { const Slice& limit) const override {
std::string s = Reverse(*start); std::string s = Reverse(*start);
std::string l = Reverse(limit); std::string l = Reverse(limit);
BytewiseComparator()->FindShortestSeparator(&s, l); BytewiseComparator()->FindShortestSeparator(&s, l);
*start = Reverse(s); *start = Reverse(s);
} }
virtual void FindShortSuccessor(std::string* key) const override { void FindShortSuccessor(std::string* key) const override {
std::string s = Reverse(*key); std::string s = Reverse(*key);
BytewiseComparator()->FindShortSuccessor(&s); BytewiseComparator()->FindShortSuccessor(&s);
*key = Reverse(s); *key = Reverse(s);
@ -212,15 +212,13 @@ class BlockConstructor: public Constructor {
: Constructor(cmp), : Constructor(cmp),
comparator_(cmp), comparator_(cmp),
block_(nullptr) { } block_(nullptr) { }
~BlockConstructor() { ~BlockConstructor() override { delete block_; }
delete block_; Status FinishImpl(const Options& /*options*/,
} const ImmutableCFOptions& /*ioptions*/,
virtual Status FinishImpl( const MutableCFOptions& /*moptions*/,
const Options& /*options*/, const ImmutableCFOptions& /*ioptions*/, const BlockBasedTableOptions& table_options,
const MutableCFOptions& /*moptions*/, const InternalKeyComparator& /*internal_comparator*/,
const BlockBasedTableOptions& table_options, const stl_wrappers::KVMap& kv_map) override {
const InternalKeyComparator& /*internal_comparator*/,
const stl_wrappers::KVMap& kv_map) override {
delete block_; delete block_;
block_ = nullptr; block_ = nullptr;
BlockBuilder builder(table_options.block_restart_interval); BlockBuilder builder(table_options.block_restart_interval);
@ -235,7 +233,7 @@ class BlockConstructor: public Constructor {
block_ = new Block(std::move(contents), kDisableGlobalSequenceNumber); block_ = new Block(std::move(contents), kDisableGlobalSequenceNumber);
return Status::OK(); return Status::OK();
} }
virtual InternalIterator* NewIterator( InternalIterator* NewIterator(
const SliceTransform* /*prefix_extractor*/) const override { const SliceTransform* /*prefix_extractor*/) const override {
return block_->NewIterator<DataBlockIter>(comparator_, comparator_); return block_->NewIterator<DataBlockIter>(comparator_, comparator_);
} }
@ -254,32 +252,32 @@ class KeyConvertingIterator : public InternalIterator {
explicit KeyConvertingIterator(InternalIterator* iter, explicit KeyConvertingIterator(InternalIterator* iter,
bool arena_mode = false) bool arena_mode = false)
: iter_(iter), arena_mode_(arena_mode) {} : iter_(iter), arena_mode_(arena_mode) {}
virtual ~KeyConvertingIterator() { ~KeyConvertingIterator() override {
if (arena_mode_) { if (arena_mode_) {
iter_->~InternalIterator(); iter_->~InternalIterator();
} else { } else {
delete iter_; delete iter_;
} }
} }
virtual bool Valid() const override { return iter_->Valid() && status_.ok(); } bool Valid() const override { return iter_->Valid() && status_.ok(); }
virtual void Seek(const Slice& target) override { void Seek(const Slice& target) override {
ParsedInternalKey ikey(target, kMaxSequenceNumber, kTypeValue); ParsedInternalKey ikey(target, kMaxSequenceNumber, kTypeValue);
std::string encoded; std::string encoded;
AppendInternalKey(&encoded, ikey); AppendInternalKey(&encoded, ikey);
iter_->Seek(encoded); iter_->Seek(encoded);
} }
virtual void SeekForPrev(const Slice& target) override { void SeekForPrev(const Slice& target) override {
ParsedInternalKey ikey(target, kMaxSequenceNumber, kTypeValue); ParsedInternalKey ikey(target, kMaxSequenceNumber, kTypeValue);
std::string encoded; std::string encoded;
AppendInternalKey(&encoded, ikey); AppendInternalKey(&encoded, ikey);
iter_->SeekForPrev(encoded); iter_->SeekForPrev(encoded);
} }
virtual void SeekToFirst() override { iter_->SeekToFirst(); } void SeekToFirst() override { iter_->SeekToFirst(); }
virtual void SeekToLast() override { iter_->SeekToLast(); } void SeekToLast() override { iter_->SeekToLast(); }
virtual void Next() override { iter_->Next(); } void Next() override { iter_->Next(); }
virtual void Prev() override { iter_->Prev(); } void Prev() override { iter_->Prev(); }
virtual Slice key() const override { Slice key() const override {
assert(Valid()); assert(Valid());
ParsedInternalKey parsed_key; ParsedInternalKey parsed_key;
if (!ParseInternalKey(iter_->key(), &parsed_key)) { if (!ParseInternalKey(iter_->key(), &parsed_key)) {
@ -289,8 +287,8 @@ class KeyConvertingIterator : public InternalIterator {
return parsed_key.user_key; return parsed_key.user_key;
} }
virtual Slice value() const override { return iter_->value(); } Slice value() const override { return iter_->value(); }
virtual Status status() const override { Status status() const override {
return status_.ok() ? iter_->status() : status_; return status_.ok() ? iter_->status() : status_;
} }
@ -312,14 +310,13 @@ class TableConstructor: public Constructor {
: Constructor(cmp), : Constructor(cmp),
convert_to_internal_key_(convert_to_internal_key), convert_to_internal_key_(convert_to_internal_key),
level_(level) {} level_(level) {}
~TableConstructor() { Reset(); } ~TableConstructor() override { Reset(); }
virtual Status FinishImpl(const Options& options, Status FinishImpl(const Options& options, const ImmutableCFOptions& ioptions,
const ImmutableCFOptions& ioptions, const MutableCFOptions& moptions,
const MutableCFOptions& moptions, const BlockBasedTableOptions& /*table_options*/,
const BlockBasedTableOptions& /*table_options*/, const InternalKeyComparator& internal_comparator,
const InternalKeyComparator& internal_comparator, const stl_wrappers::KVMap& kv_map) override {
const stl_wrappers::KVMap& kv_map) override {
Reset(); Reset();
soptions.use_mmap_reads = ioptions.allow_mmap_reads; soptions.use_mmap_reads = ioptions.allow_mmap_reads;
file_writer_.reset(test::GetWritableFileWriter(new test::StringSink(), file_writer_.reset(test::GetWritableFileWriter(new test::StringSink(),
@ -368,7 +365,7 @@ class TableConstructor: public Constructor {
&table_reader_); &table_reader_);
} }
virtual InternalIterator* NewIterator( InternalIterator* NewIterator(
const SliceTransform* prefix_extractor) const override { const SliceTransform* prefix_extractor) const override {
ReadOptions ro; ReadOptions ro;
InternalIterator* iter = table_reader_->NewIterator(ro, prefix_extractor); InternalIterator* iter = table_reader_->NewIterator(ro, prefix_extractor);
@ -401,7 +398,7 @@ class TableConstructor: public Constructor {
virtual TableReader* GetTableReader() { return table_reader_.get(); } virtual TableReader* GetTableReader() { return table_reader_.get(); }
virtual bool AnywayDeleteIterator() const override { bool AnywayDeleteIterator() const override {
return convert_to_internal_key_; return convert_to_internal_key_;
} }
@ -449,15 +446,12 @@ class MemTableConstructor: public Constructor {
wb, kMaxSequenceNumber, 0 /* column_family_id */); wb, kMaxSequenceNumber, 0 /* column_family_id */);
memtable_->Ref(); memtable_->Ref();
} }
~MemTableConstructor() { ~MemTableConstructor() override { delete memtable_->Unref(); }
delete memtable_->Unref(); Status FinishImpl(const Options&, const ImmutableCFOptions& ioptions,
} const MutableCFOptions& /*moptions*/,
virtual Status FinishImpl( const BlockBasedTableOptions& /*table_options*/,
const Options&, const ImmutableCFOptions& ioptions, const InternalKeyComparator& /*internal_comparator*/,
const MutableCFOptions& /*moptions*/, const stl_wrappers::KVMap& kv_map) override {
const BlockBasedTableOptions& /*table_options*/,
const InternalKeyComparator& /*internal_comparator*/,
const stl_wrappers::KVMap& kv_map) override {
delete memtable_->Unref(); delete memtable_->Unref();
ImmutableCFOptions mem_ioptions(ioptions); ImmutableCFOptions mem_ioptions(ioptions);
memtable_ = new MemTable(internal_comparator_, mem_ioptions, memtable_ = new MemTable(internal_comparator_, mem_ioptions,
@ -471,15 +465,15 @@ class MemTableConstructor: public Constructor {
} }
return Status::OK(); return Status::OK();
} }
virtual InternalIterator* NewIterator( InternalIterator* NewIterator(
const SliceTransform* /*prefix_extractor*/) const override { const SliceTransform* /*prefix_extractor*/) const override {
return new KeyConvertingIterator( return new KeyConvertingIterator(
memtable_->NewIterator(ReadOptions(), &arena_), true); memtable_->NewIterator(ReadOptions(), &arena_), true);
} }
virtual bool AnywayDeleteIterator() const override { return true; } bool AnywayDeleteIterator() const override { return true; }
virtual bool IsArenaMode() const override { return true; } bool IsArenaMode() const override { return true; }
private: private:
mutable Arena arena_; mutable Arena arena_;
@ -493,18 +487,16 @@ class MemTableConstructor: public Constructor {
class InternalIteratorFromIterator : public InternalIterator { class InternalIteratorFromIterator : public InternalIterator {
public: public:
explicit InternalIteratorFromIterator(Iterator* it) : it_(it) {} explicit InternalIteratorFromIterator(Iterator* it) : it_(it) {}
virtual bool Valid() const override { return it_->Valid(); } bool Valid() const override { return it_->Valid(); }
virtual void Seek(const Slice& target) override { it_->Seek(target); } void Seek(const Slice& target) override { it_->Seek(target); }
virtual void SeekForPrev(const Slice& target) override { void SeekForPrev(const Slice& target) override { it_->SeekForPrev(target); }
it_->SeekForPrev(target); void SeekToFirst() override { it_->SeekToFirst(); }
} void SeekToLast() override { it_->SeekToLast(); }
virtual void SeekToFirst() override { it_->SeekToFirst(); } void Next() override { it_->Next(); }
virtual void SeekToLast() override { it_->SeekToLast(); } void Prev() override { it_->Prev(); }
virtual void Next() override { it_->Next(); }
virtual void Prev() override { it_->Prev(); }
Slice key() const override { return it_->key(); } Slice key() const override { return it_->key(); }
Slice value() const override { return it_->value(); } Slice value() const override { return it_->value(); }
virtual Status status() const override { return it_->status(); } Status status() const override { return it_->status(); }
private: private:
std::unique_ptr<Iterator> it_; std::unique_ptr<Iterator> it_;
@ -518,15 +510,13 @@ class DBConstructor: public Constructor {
db_ = nullptr; db_ = nullptr;
NewDB(); NewDB();
} }
~DBConstructor() { ~DBConstructor() override { delete db_; }
delete db_; Status FinishImpl(const Options& /*options*/,
} const ImmutableCFOptions& /*ioptions*/,
virtual Status FinishImpl( const MutableCFOptions& /*moptions*/,
const Options& /*options*/, const ImmutableCFOptions& /*ioptions*/, const BlockBasedTableOptions& /*table_options*/,
const MutableCFOptions& /*moptions*/, const InternalKeyComparator& /*internal_comparator*/,
const BlockBasedTableOptions& /*table_options*/, const stl_wrappers::KVMap& kv_map) override {
const InternalKeyComparator& /*internal_comparator*/,
const stl_wrappers::KVMap& kv_map) override {
delete db_; delete db_;
db_ = nullptr; db_ = nullptr;
NewDB(); NewDB();
@ -538,12 +528,12 @@ class DBConstructor: public Constructor {
return Status::OK(); return Status::OK();
} }
virtual InternalIterator* NewIterator( InternalIterator* NewIterator(
const SliceTransform* /*prefix_extractor*/) const override { const SliceTransform* /*prefix_extractor*/) const override {
return new InternalIteratorFromIterator(db_->NewIterator(ReadOptions())); return new InternalIteratorFromIterator(db_->NewIterator(ReadOptions()));
} }
virtual DB* db() const override { return db_; } DB* db() const override { return db_; }
private: private:
void NewDB() { void NewDB() {
@ -679,9 +669,9 @@ class FixedOrLessPrefixTransform : public SliceTransform {
prefix_len_(prefix_len) { prefix_len_(prefix_len) {
} }
virtual const char* Name() const override { return "rocksdb.FixedPrefix"; } const char* Name() const override { return "rocksdb.FixedPrefix"; }
virtual Slice Transform(const Slice& src) const override { Slice Transform(const Slice& src) const override {
assert(InDomain(src)); assert(InDomain(src));
if (src.size() < prefix_len_) { if (src.size() < prefix_len_) {
return src; return src;
@ -689,14 +679,12 @@ class FixedOrLessPrefixTransform : public SliceTransform {
return Slice(src.data(), prefix_len_); return Slice(src.data(), prefix_len_);
} }
virtual bool InDomain(const Slice& /*src*/) const override { return true; } bool InDomain(const Slice& /*src*/) const override { return true; }
virtual bool InRange(const Slice& dst) const override { bool InRange(const Slice& dst) const override {
return (dst.size() <= prefix_len_); return (dst.size() <= prefix_len_);
} }
virtual bool FullLengthEnabled(size_t* /*len*/) const override { bool FullLengthEnabled(size_t* /*len*/) const override { return false; }
return false;
}
}; };
class HarnessTest : public testing::Test { class HarnessTest : public testing::Test {
@ -805,7 +793,7 @@ class HarnessTest : public testing::Test {
moptions_ = MutableCFOptions(options_); moptions_ = MutableCFOptions(options_);
} }
~HarnessTest() { delete constructor_; } ~HarnessTest() override { delete constructor_; }
void Add(const std::string& key, const std::string& value) { void Add(const std::string& key, const std::string& value) {
constructor_->Add(key, value); constructor_->Add(key, value);
@ -2287,10 +2275,10 @@ class MockCache : public LRUCache {
double high_pri_pool_ratio) double high_pri_pool_ratio)
: LRUCache(capacity, num_shard_bits, strict_capacity_limit, : LRUCache(capacity, num_shard_bits, strict_capacity_limit,
high_pri_pool_ratio) {} high_pri_pool_ratio) {}
virtual Status Insert(const Slice& key, void* value, size_t charge, Status Insert(const Slice& key, void* value, size_t charge,
void (*deleter)(const Slice& key, void* value), void (*deleter)(const Slice& key, void* value),
Handle** handle = nullptr, Handle** handle = nullptr,
Priority priority = Priority::LOW) override { Priority priority = Priority::LOW) override {
// Replace the deleter with our own so that we keep track of data blocks // Replace the deleter with our own so that we keep track of data blocks
// erased from the cache // erased from the cache
deleters_[key.ToString()] = deleter; deleters_[key.ToString()] = deleter;
@ -2298,8 +2286,7 @@ class MockCache : public LRUCache {
priority); priority);
} }
// This is called by the application right after inserting a data block // This is called by the application right after inserting a data block
virtual void TEST_mark_as_data_block(const Slice& key, void TEST_mark_as_data_block(const Slice& key, size_t charge) override {
size_t charge) override {
marked_data_in_cache_[key.ToString()] = charge; marked_data_in_cache_[key.ToString()] = charge;
marked_size_ += charge; marked_size_ += charge;
} }
@ -2487,7 +2474,7 @@ TEST_P(BlockBasedTableTest, BlockCacheLeak) {
namespace { namespace {
class CustomMemoryAllocator : public MemoryAllocator { class CustomMemoryAllocator : public MemoryAllocator {
public: public:
virtual const char* Name() const override { return "CustomMemoryAllocator"; } const char* Name() const override { return "CustomMemoryAllocator"; }
void* Allocate(size_t size) override { void* Allocate(size_t size) override {
++numAllocations; ++numAllocations;
@ -3165,7 +3152,7 @@ TEST_P(IndexBlockRestartIntervalTest, IndexBlockRestartInterval) {
class PrefixTest : public testing::Test { class PrefixTest : public testing::Test {
public: public:
PrefixTest() : testing::Test() {} PrefixTest() : testing::Test() {}
~PrefixTest() {} ~PrefixTest() override {}
}; };
namespace { namespace {

@ -25,29 +25,29 @@ class TwoLevelIndexIterator : public InternalIteratorBase<BlockHandle> {
TwoLevelIteratorState* state, TwoLevelIteratorState* state,
InternalIteratorBase<BlockHandle>* first_level_iter); InternalIteratorBase<BlockHandle>* first_level_iter);
virtual ~TwoLevelIndexIterator() { ~TwoLevelIndexIterator() override {
first_level_iter_.DeleteIter(false /* is_arena_mode */); first_level_iter_.DeleteIter(false /* is_arena_mode */);
second_level_iter_.DeleteIter(false /* is_arena_mode */); second_level_iter_.DeleteIter(false /* is_arena_mode */);
delete state_; delete state_;
} }
virtual void Seek(const Slice& target) override; void Seek(const Slice& target) override;
virtual void SeekForPrev(const Slice& target) override; void SeekForPrev(const Slice& target) override;
virtual void SeekToFirst() override; void SeekToFirst() override;
virtual void SeekToLast() override; void SeekToLast() override;
virtual void Next() override; void Next() override;
virtual void Prev() override; void Prev() override;
virtual bool Valid() const override { return second_level_iter_.Valid(); } bool Valid() const override { return second_level_iter_.Valid(); }
virtual Slice key() const override { Slice key() const override {
assert(Valid()); assert(Valid());
return second_level_iter_.key(); return second_level_iter_.key();
} }
virtual BlockHandle value() const override { BlockHandle value() const override {
assert(Valid()); assert(Valid());
return second_level_iter_.value(); return second_level_iter_.value();
} }
virtual Status status() const override { Status status() const override {
if (!first_level_iter_.status().ok()) { if (!first_level_iter_.status().ok()) {
assert(second_level_iter_.iter() == nullptr); assert(second_level_iter_.iter() == nullptr);
return first_level_iter_.status(); return first_level_iter_.status();
@ -58,10 +58,10 @@ class TwoLevelIndexIterator : public InternalIteratorBase<BlockHandle> {
return status_; return status_;
} }
} }
virtual void SetPinnedItersMgr( void SetPinnedItersMgr(
PinnedIteratorsManager* /*pinned_iters_mgr*/) override {} PinnedIteratorsManager* /*pinned_iters_mgr*/) override {}
virtual bool IsKeyPinned() const override { return false; } bool IsKeyPinned() const override { return false; }
virtual bool IsValuePinned() const override { return false; } bool IsValuePinned() const override { return false; }
private: private:
void SaveError(const Status& s) { void SaveError(const Status& s) {

@ -1205,7 +1205,7 @@ class ReportFileOpEnv : public EnvWrapper {
ReportFileOpCounters* counters) ReportFileOpCounters* counters)
: target_(std::move(target)), counters_(counters) {} : target_(std::move(target)), counters_(counters) {}
virtual Status Read(size_t n, Slice* result, char* scratch) override { Status Read(size_t n, Slice* result, char* scratch) override {
counters_->read_counter_.fetch_add(1, std::memory_order_relaxed); counters_->read_counter_.fetch_add(1, std::memory_order_relaxed);
Status rv = target_->Read(n, result, scratch); Status rv = target_->Read(n, result, scratch);
counters_->bytes_read_.fetch_add(result->size(), counters_->bytes_read_.fetch_add(result->size(),
@ -1213,7 +1213,7 @@ class ReportFileOpEnv : public EnvWrapper {
return rv; return rv;
} }
virtual Status Skip(uint64_t n) override { return target_->Skip(n); } Status Skip(uint64_t n) override { return target_->Skip(n); }
}; };
Status s = target()->NewSequentialFile(f, r, soptions); Status s = target()->NewSequentialFile(f, r, soptions);
@ -1236,8 +1236,8 @@ class ReportFileOpEnv : public EnvWrapper {
CountingFile(unique_ptr<RandomAccessFile>&& target, CountingFile(unique_ptr<RandomAccessFile>&& target,
ReportFileOpCounters* counters) ReportFileOpCounters* counters)
: target_(std::move(target)), counters_(counters) {} : target_(std::move(target)), counters_(counters) {}
virtual Status Read(uint64_t offset, size_t n, Slice* result, Status Read(uint64_t offset, size_t n, Slice* result,
char* scratch) const override { char* scratch) const override {
counters_->read_counter_.fetch_add(1, std::memory_order_relaxed); counters_->read_counter_.fetch_add(1, std::memory_order_relaxed);
Status rv = target_->Read(offset, n, result, scratch); Status rv = target_->Read(offset, n, result, scratch);
counters_->bytes_read_.fetch_add(result->size(), counters_->bytes_read_.fetch_add(result->size(),
@ -2050,16 +2050,17 @@ class Benchmark {
no_auto_recovery_(false), no_auto_recovery_(false),
recovery_complete_(false) {} recovery_complete_(false) {}
~ErrorHandlerListener() {} ~ErrorHandlerListener() override {}
void OnErrorRecoveryBegin(BackgroundErrorReason /*reason*/, void OnErrorRecoveryBegin(BackgroundErrorReason /*reason*/,
Status /*bg_error*/, bool* auto_recovery) { Status /*bg_error*/,
bool* auto_recovery) override {
if (*auto_recovery && no_auto_recovery_) { if (*auto_recovery && no_auto_recovery_) {
*auto_recovery = false; *auto_recovery = false;
} }
} }
void OnErrorRecoveryCompleted(Status /*old_bg_error*/) { void OnErrorRecoveryCompleted(Status /*old_bg_error*/) override {
InstrumentedMutexLock l(&mutex_); InstrumentedMutexLock l(&mutex_);
recovery_complete_ = true; recovery_complete_ = true;
cv_.SignalAll(); cv_.SignalAll();
@ -2310,13 +2311,13 @@ class Benchmark {
class KeepFilter : public CompactionFilter { class KeepFilter : public CompactionFilter {
public: public:
virtual bool Filter(int /*level*/, const Slice& /*key*/, bool Filter(int /*level*/, const Slice& /*key*/, const Slice& /*value*/,
const Slice& /*value*/, std::string* /*new_value*/, std::string* /*new_value*/,
bool* /*value_changed*/) const override { bool* /*value_changed*/) const override {
return false; return false;
} }
virtual const char* Name() const override { return "KeepFilter"; } const char* Name() const override { return "KeepFilter"; }
}; };
std::shared_ptr<Cache> NewCache(int64_t capacity) { std::shared_ptr<Cache> NewCache(int64_t capacity) {

@ -1869,7 +1869,7 @@ void ChangeCompactionStyleCommand::DoCommand() {
namespace { namespace {
struct StdErrReporter : public log::Reader::Reporter { struct StdErrReporter : public log::Reader::Reporter {
virtual void Corruption(size_t /*bytes*/, const Status& s) override { void Corruption(size_t /*bytes*/, const Status& s) override {
std::cerr << "Corruption detected in log file " << s.ToString() << "\n"; std::cerr << "Corruption detected in log file " << s.ToString() << "\n";
} }
}; };
@ -1894,74 +1894,71 @@ class InMemoryHandler : public WriteBatch::Handler {
} }
} }
virtual Status PutCF(uint32_t cf, const Slice& key, Status PutCF(uint32_t cf, const Slice& key, const Slice& value) override {
const Slice& value) override {
row_ << "PUT(" << cf << ") : "; row_ << "PUT(" << cf << ") : ";
commonPutMerge(key, value); commonPutMerge(key, value);
return Status::OK(); return Status::OK();
} }
virtual Status MergeCF(uint32_t cf, const Slice& key, Status MergeCF(uint32_t cf, const Slice& key, const Slice& value) override {
const Slice& value) override {
row_ << "MERGE(" << cf << ") : "; row_ << "MERGE(" << cf << ") : ";
commonPutMerge(key, value); commonPutMerge(key, value);
return Status::OK(); return Status::OK();
} }
virtual Status MarkNoop(bool) Status MarkNoop(bool) override {
override {
row_ << "NOOP "; row_ << "NOOP ";
return Status::OK(); return Status::OK();
} }
virtual Status DeleteCF(uint32_t cf, const Slice& key) override { Status DeleteCF(uint32_t cf, const Slice& key) override {
row_ << "DELETE(" << cf << ") : "; row_ << "DELETE(" << cf << ") : ";
row_ << LDBCommand::StringToHex(key.ToString()) << " "; row_ << LDBCommand::StringToHex(key.ToString()) << " ";
return Status::OK(); return Status::OK();
} }
virtual Status SingleDeleteCF(uint32_t cf, const Slice& key) override { Status SingleDeleteCF(uint32_t cf, const Slice& key) override {
row_ << "SINGLE_DELETE(" << cf << ") : "; row_ << "SINGLE_DELETE(" << cf << ") : ";
row_ << LDBCommand::StringToHex(key.ToString()) << " "; row_ << LDBCommand::StringToHex(key.ToString()) << " ";
return Status::OK(); return Status::OK();
} }
virtual Status DeleteRangeCF(uint32_t cf, const Slice& begin_key, Status DeleteRangeCF(uint32_t cf, const Slice& begin_key,
const Slice& end_key) override { const Slice& end_key) override {
row_ << "DELETE_RANGE(" << cf << ") : "; row_ << "DELETE_RANGE(" << cf << ") : ";
row_ << LDBCommand::StringToHex(begin_key.ToString()) << " "; row_ << LDBCommand::StringToHex(begin_key.ToString()) << " ";
row_ << LDBCommand::StringToHex(end_key.ToString()) << " "; row_ << LDBCommand::StringToHex(end_key.ToString()) << " ";
return Status::OK(); return Status::OK();
} }
virtual Status MarkBeginPrepare(bool unprepare) override { Status MarkBeginPrepare(bool unprepare) override {
row_ << "BEGIN_PREPARE("; row_ << "BEGIN_PREPARE(";
row_ << (unprepare ? "true" : "false") << ") "; row_ << (unprepare ? "true" : "false") << ") ";
return Status::OK(); return Status::OK();
} }
virtual Status MarkEndPrepare(const Slice& xid) override { Status MarkEndPrepare(const Slice& xid) override {
row_ << "END_PREPARE("; row_ << "END_PREPARE(";
row_ << LDBCommand::StringToHex(xid.ToString()) << ") "; row_ << LDBCommand::StringToHex(xid.ToString()) << ") ";
return Status::OK(); return Status::OK();
} }
virtual Status MarkRollback(const Slice& xid) override { Status MarkRollback(const Slice& xid) override {
row_ << "ROLLBACK("; row_ << "ROLLBACK(";
row_ << LDBCommand::StringToHex(xid.ToString()) << ") "; row_ << LDBCommand::StringToHex(xid.ToString()) << ") ";
return Status::OK(); return Status::OK();
} }
virtual Status MarkCommit(const Slice& xid) override { Status MarkCommit(const Slice& xid) override {
row_ << "COMMIT("; row_ << "COMMIT(";
row_ << LDBCommand::StringToHex(xid.ToString()) << ") "; row_ << LDBCommand::StringToHex(xid.ToString()) << ") ";
return Status::OK(); return Status::OK();
} }
virtual ~InMemoryHandler() {} ~InMemoryHandler() override {}
protected: protected:
virtual bool WriteAfterCommit() const override { return write_after_commit_; } bool WriteAfterCommit() const override { return write_after_commit_; }
private: private:
std::stringstream& row_; std::stringstream& row_;

@ -89,7 +89,7 @@ class SSTDumpToolTest : public testing::Test {
public: public:
SSTDumpToolTest() { testDir_ = test::TmpDir(); } SSTDumpToolTest() { testDir_ = test::TmpDir(); }
~SSTDumpToolTest() {} ~SSTDumpToolTest() override {}
std::string MakeFilePath(const std::string& file_name) const { std::string MakeFilePath(const std::string& file_name) const {
std::string path(testDir_); std::string path(testDir_);

@ -50,7 +50,7 @@ class TraceAnalyzerTest : public testing::Test {
dbname_ = test_path_ + "/db"; dbname_ = test_path_ + "/db";
} }
~TraceAnalyzerTest() {} ~TraceAnalyzerTest() override {}
void GenerateTrace(std::string trace_path) { void GenerateTrace(std::string trace_path) {
Options options; Options options;

@ -28,13 +28,13 @@ namespace {
class NoSleepEnv : public EnvWrapper { class NoSleepEnv : public EnvWrapper {
public: public:
NoSleepEnv(Env* base) : EnvWrapper(base) {} NoSleepEnv(Env* base) : EnvWrapper(base) {}
virtual void SleepForMicroseconds(int micros) override { void SleepForMicroseconds(int micros) override {
fake_time_ += static_cast<uint64_t>(micros); fake_time_ += static_cast<uint64_t>(micros);
} }
virtual uint64_t NowNanos() override { return fake_time_ * 1000; } uint64_t NowNanos() override { return fake_time_ * 1000; }
virtual uint64_t NowMicros() override { return fake_time_; } uint64_t NowMicros() override { return fake_time_; }
private: private:
uint64_t fake_time_ = 6666666666; uint64_t fake_time_ = 6666666666;

@ -172,9 +172,9 @@ class FullFilterBitsReader : public FilterBitsReader {
} }
} }
~FullFilterBitsReader() {} ~FullFilterBitsReader() override {}
virtual bool MayMatch(const Slice& entry) override { bool MayMatch(const Slice& entry) override {
if (data_len_ <= 5) { // remain same with original filter if (data_len_ <= 5) { // remain same with original filter
return false; return false;
} }
@ -274,15 +274,11 @@ class BloomFilterPolicy : public FilterPolicy {
initialize(); initialize();
} }
~BloomFilterPolicy() { ~BloomFilterPolicy() override {}
}
virtual const char* Name() const override { const char* Name() const override { return "rocksdb.BuiltinBloomFilter"; }
return "rocksdb.BuiltinBloomFilter";
}
virtual void CreateFilter(const Slice* keys, int n, void CreateFilter(const Slice* keys, int n, std::string* dst) const override {
std::string* dst) const override {
// Compute bloom filter size (in both bits and bytes) // Compute bloom filter size (in both bits and bytes)
size_t bits = n * bits_per_key_; size_t bits = n * bits_per_key_;
@ -310,8 +306,7 @@ class BloomFilterPolicy : public FilterPolicy {
} }
} }
virtual bool KeyMayMatch(const Slice& key, bool KeyMayMatch(const Slice& key, const Slice& bloom_filter) const override {
const Slice& bloom_filter) const override {
const size_t len = bloom_filter.size(); const size_t len = bloom_filter.size();
if (len < 2) return false; if (len < 2) return false;
@ -337,7 +332,7 @@ class BloomFilterPolicy : public FilterPolicy {
return true; return true;
} }
virtual FilterBitsBuilder* GetFilterBitsBuilder() const override { FilterBitsBuilder* GetFilterBitsBuilder() const override {
if (use_block_based_builder_) { if (use_block_based_builder_) {
return nullptr; return nullptr;
} }
@ -345,8 +340,7 @@ class BloomFilterPolicy : public FilterPolicy {
return new FullFilterBitsBuilder(bits_per_key_, num_probes_); return new FullFilterBitsBuilder(bits_per_key_, num_probes_);
} }
virtual FilterBitsReader* GetFilterBitsReader(const Slice& contents) FilterBitsReader* GetFilterBitsReader(const Slice& contents) const override {
const override {
return new FullFilterBitsReader(contents); return new FullFilterBitsReader(contents);
} }

@ -63,9 +63,7 @@ class BloomTest : public testing::Test {
BloomTest() : policy_( BloomTest() : policy_(
NewBloomFilterPolicy(FLAGS_bits_per_key)) {} NewBloomFilterPolicy(FLAGS_bits_per_key)) {}
~BloomTest() { ~BloomTest() override { delete policy_; }
delete policy_;
}
void Reset() { void Reset() {
keys_.clear(); keys_.clear();
@ -192,9 +190,7 @@ class FullBloomTest : public testing::Test {
Reset(); Reset();
} }
~FullBloomTest() { ~FullBloomTest() override { delete policy_; }
delete policy_;
}
FullFilterBitsBuilder* GetFullFilterBitsBuilder() { FullFilterBitsBuilder* GetFullFilterBitsBuilder() {
return dynamic_cast<FullFilterBitsBuilder*>(bits_builder_.get()); return dynamic_cast<FullFilterBitsBuilder*>(bits_builder_.get());

@ -22,20 +22,16 @@ class BytewiseComparatorImpl : public Comparator {
public: public:
BytewiseComparatorImpl() { } BytewiseComparatorImpl() { }
virtual const char* Name() const override { const char* Name() const override { return "leveldb.BytewiseComparator"; }
return "leveldb.BytewiseComparator";
}
virtual int Compare(const Slice& a, const Slice& b) const override { int Compare(const Slice& a, const Slice& b) const override {
return a.compare(b); return a.compare(b);
} }
virtual bool Equal(const Slice& a, const Slice& b) const override { bool Equal(const Slice& a, const Slice& b) const override { return a == b; }
return a == b;
}
virtual void FindShortestSeparator(std::string* start, void FindShortestSeparator(std::string* start,
const Slice& limit) const override { const Slice& limit) const override {
// Find length of common prefix // Find length of common prefix
size_t min_length = std::min(start->size(), limit.size()); size_t min_length = std::min(start->size(), limit.size());
size_t diff_index = 0; size_t diff_index = 0;
@ -85,7 +81,7 @@ class BytewiseComparatorImpl : public Comparator {
} }
} }
virtual void FindShortSuccessor(std::string* key) const override { void FindShortSuccessor(std::string* key) const override {
// Find first character that can be incremented // Find first character that can be incremented
size_t n = key->size(); size_t n = key->size();
for (size_t i = 0; i < n; i++) { for (size_t i = 0; i < n; i++) {
@ -99,8 +95,8 @@ class BytewiseComparatorImpl : public Comparator {
// *key is a run of 0xffs. Leave it alone. // *key is a run of 0xffs. Leave it alone.
} }
virtual bool IsSameLengthImmediateSuccessor(const Slice& s, bool IsSameLengthImmediateSuccessor(const Slice& s,
const Slice& t) const override { const Slice& t) const override {
if (s.size() != t.size() || s.size() == 0) { if (s.size() != t.size() || s.size() == 0) {
return false; return false;
} }
@ -125,7 +121,7 @@ class BytewiseComparatorImpl : public Comparator {
} }
} }
virtual bool CanKeysWithDifferentByteContentsBeEqual() const override { bool CanKeysWithDifferentByteContentsBeEqual() const override {
return false; return false;
} }
}; };
@ -134,11 +130,11 @@ class ReverseBytewiseComparatorImpl : public BytewiseComparatorImpl {
public: public:
ReverseBytewiseComparatorImpl() { } ReverseBytewiseComparatorImpl() { }
virtual const char* Name() const override { const char* Name() const override {
return "rocksdb.ReverseBytewiseComparator"; return "rocksdb.ReverseBytewiseComparator";
} }
virtual int Compare(const Slice& a, const Slice& b) const override { int Compare(const Slice& a, const Slice& b) const override {
return -a.compare(b); return -a.compare(b);
} }
@ -193,7 +189,7 @@ class ReverseBytewiseComparatorImpl : public BytewiseComparatorImpl {
// Don't do anything for simplicity. // Don't do anything for simplicity.
} }
virtual bool CanKeysWithDifferentByteContentsBeEqual() const override { bool CanKeysWithDifferentByteContentsBeEqual() const override {
return false; return false;
} }
}; };

@ -38,7 +38,7 @@ class DeleteSchedulerTest : public testing::Test {
} }
} }
~DeleteSchedulerTest() { ~DeleteSchedulerTest() override {
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); rocksdb::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->LoadDependency({}); rocksdb::SyncPoint::GetInstance()->LoadDependency({});
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks();

@ -15,7 +15,7 @@ class EventLoggerTest : public testing::Test {};
class StringLogger : public Logger { class StringLogger : public Logger {
public: public:
using Logger::Logv; using Logger::Logv;
virtual void Logv(const char* format, va_list ap) override { void Logv(const char* format, va_list ap) override {
vsnprintf(buffer_, sizeof(buffer_), format, ap); vsnprintf(buffer_, sizeof(buffer_), format, ap);
} }
char* buffer() { return buffer_; } char* buffer() { return buffer_; }

@ -595,96 +595,93 @@ class ReadaheadRandomAccessFile : public RandomAccessFile {
ReadaheadRandomAccessFile& operator=(const ReadaheadRandomAccessFile&) = delete; ReadaheadRandomAccessFile& operator=(const ReadaheadRandomAccessFile&) = delete;
virtual Status Read(uint64_t offset, size_t n, Slice* result, Status Read(uint64_t offset, size_t n, Slice* result,
char* scratch) const override { char* scratch) const override {
if (n + alignment_ >= readahead_size_) {
if (n + alignment_ >= readahead_size_) { return file_->Read(offset, n, result, scratch);
return file_->Read(offset, n, result, scratch); }
}
std::unique_lock<std::mutex> lk(lock_);
std::unique_lock<std::mutex> lk(lock_);
size_t cached_len = 0;
size_t cached_len = 0; // Check if there is a cache hit, means that [offset, offset + n) is either
// Check if there is a cache hit, means that [offset, offset + n) is either // completely or partially in the buffer
// completely or partially in the buffer // If it's completely cached, including end of file case when offset + n is
// If it's completely cached, including end of file case when offset + n is // greater than EOF, return
// greater than EOF, return if (TryReadFromCache(offset, n, &cached_len, scratch) &&
if (TryReadFromCache(offset, n, &cached_len, scratch) && (cached_len == n ||
(cached_len == n || // End of file
// End of file buffer_.CurrentSize() < readahead_size_)) {
buffer_.CurrentSize() < readahead_size_)) { *result = Slice(scratch, cached_len);
*result = Slice(scratch, cached_len); return Status::OK();
return Status::OK(); }
} size_t advanced_offset = static_cast<size_t>(offset + cached_len);
size_t advanced_offset = static_cast<size_t>(offset + cached_len); // In the case of cache hit advanced_offset is already aligned, means that
// In the case of cache hit advanced_offset is already aligned, means that // chunk_offset equals to advanced_offset
// chunk_offset equals to advanced_offset size_t chunk_offset = TruncateToPageBoundary(alignment_, advanced_offset);
size_t chunk_offset = TruncateToPageBoundary(alignment_, advanced_offset); Slice readahead_result;
Slice readahead_result;
Status s = ReadIntoBuffer(chunk_offset, readahead_size_);
Status s = ReadIntoBuffer(chunk_offset, readahead_size_); if (s.ok()) {
if (s.ok()) { // In the case of cache miss, i.e. when cached_len equals 0, an offset can
// In the case of cache miss, i.e. when cached_len equals 0, an offset can // exceed the file end position, so the following check is required
// exceed the file end position, so the following check is required if (advanced_offset < chunk_offset + buffer_.CurrentSize()) {
if (advanced_offset < chunk_offset + buffer_.CurrentSize()) { // In the case of cache miss, the first chunk_padding bytes in buffer_
// In the case of cache miss, the first chunk_padding bytes in buffer_ // are
// are // stored for alignment only and must be skipped
// stored for alignment only and must be skipped size_t chunk_padding = advanced_offset - chunk_offset;
size_t chunk_padding = advanced_offset - chunk_offset; auto remaining_len =
auto remaining_len = std::min(buffer_.CurrentSize() - chunk_padding, n - cached_len);
std::min(buffer_.CurrentSize() - chunk_padding, n - cached_len); memcpy(scratch + cached_len, buffer_.BufferStart() + chunk_padding,
memcpy(scratch + cached_len, buffer_.BufferStart() + chunk_padding, remaining_len);
remaining_len); *result = Slice(scratch, cached_len + remaining_len);
*result = Slice(scratch, cached_len + remaining_len); } else {
} else { *result = Slice(scratch, cached_len);
*result = Slice(scratch, cached_len); }
} }
} return s;
return s; }
}
Status Prefetch(uint64_t offset, size_t n) override {
virtual Status Prefetch(uint64_t offset, size_t n) override { if (n < readahead_size_) {
if (n < readahead_size_) { // Don't allow smaller prefetches than the configured `readahead_size_`.
// Don't allow smaller prefetches than the configured `readahead_size_`. // `Read()` assumes a smaller prefetch buffer indicates EOF was reached.
// `Read()` assumes a smaller prefetch buffer indicates EOF was reached. return Status::OK();
return Status::OK(); }
} size_t offset_ = static_cast<size_t>(offset);
size_t offset_ = static_cast<size_t>(offset); size_t prefetch_offset = TruncateToPageBoundary(alignment_, offset_);
size_t prefetch_offset = TruncateToPageBoundary(alignment_, offset_); if (prefetch_offset == buffer_offset_) {
if (prefetch_offset == buffer_offset_) { return Status::OK();
return Status::OK(); }
} return ReadIntoBuffer(prefetch_offset,
return ReadIntoBuffer(prefetch_offset, Roundup(offset_ + n, alignment_) - prefetch_offset);
Roundup(offset_ + n, alignment_) - prefetch_offset); }
}
size_t GetUniqueId(char* id, size_t max_size) const override {
virtual size_t GetUniqueId(char* id, size_t max_size) const override { return file_->GetUniqueId(id, max_size);
return file_->GetUniqueId(id, max_size); }
}
void Hint(AccessPattern pattern) override { file_->Hint(pattern); }
virtual void Hint(AccessPattern pattern) override { file_->Hint(pattern); }
Status InvalidateCache(size_t offset, size_t length) override {
virtual Status InvalidateCache(size_t offset, size_t length) override { return file_->InvalidateCache(offset, length);
return file_->InvalidateCache(offset, length); }
}
bool use_direct_io() const override { return file_->use_direct_io(); }
virtual bool use_direct_io() const override {
return file_->use_direct_io(); private:
} bool TryReadFromCache(uint64_t offset, size_t n, size_t* cached_len,
char* scratch) const {
private: if (offset < buffer_offset_ ||
bool TryReadFromCache(uint64_t offset, size_t n, size_t* cached_len, offset >= buffer_offset_ + buffer_.CurrentSize()) {
char* scratch) const { *cached_len = 0;
if (offset < buffer_offset_ || return false;
offset >= buffer_offset_ + buffer_.CurrentSize()) { }
*cached_len = 0; uint64_t offset_in_buffer = offset - buffer_offset_;
return false; *cached_len = std::min(
} buffer_.CurrentSize() - static_cast<size_t>(offset_in_buffer), n);
uint64_t offset_in_buffer = offset - buffer_offset_; memcpy(scratch, buffer_.BufferStart() + offset_in_buffer, *cached_len);
*cached_len = std::min( return true;
buffer_.CurrentSize() - static_cast<size_t>(offset_in_buffer), n);
memcpy(scratch, buffer_.BufferStart() + offset_in_buffer, *cached_len);
return true;
} }
Status ReadIntoBuffer(uint64_t offset, size_t n) const { Status ReadIntoBuffer(uint64_t offset, size_t n) const {

@ -20,13 +20,13 @@ TEST_F(WritableFileWriterTest, RangeSync) {
class FakeWF : public WritableFile { class FakeWF : public WritableFile {
public: public:
explicit FakeWF() : size_(0), last_synced_(0) {} explicit FakeWF() : size_(0), last_synced_(0) {}
~FakeWF() {} ~FakeWF() override {}
Status Append(const Slice& data) override { Status Append(const Slice& data) override {
size_ += data.size(); size_ += data.size();
return Status::OK(); return Status::OK();
} }
virtual Status Truncate(uint64_t /*size*/) override { return Status::OK(); } Status Truncate(uint64_t /*size*/) override { return Status::OK(); }
Status Close() override { Status Close() override {
EXPECT_GE(size_, last_synced_ + kMb); EXPECT_GE(size_, last_synced_ + kMb);
EXPECT_LT(size_, last_synced_ + 2 * kMb); EXPECT_LT(size_, last_synced_ + 2 * kMb);
@ -97,7 +97,7 @@ TEST_F(WritableFileWriterTest, IncrementalBuffer) {
: file_data_(_file_data), : file_data_(_file_data),
use_direct_io_(_use_direct_io), use_direct_io_(_use_direct_io),
no_flush_(_no_flush) {} no_flush_(_no_flush) {}
~FakeWF() {} ~FakeWF() override {}
Status Append(const Slice& data) override { Status Append(const Slice& data) override {
file_data_->append(data.data(), data.size()); file_data_->append(data.data(), data.size());
@ -113,7 +113,7 @@ TEST_F(WritableFileWriterTest, IncrementalBuffer) {
return Status::OK(); return Status::OK();
} }
virtual Status Truncate(uint64_t size) override { Status Truncate(uint64_t size) override {
file_data_->resize(size); file_data_->resize(size);
return Status::OK(); return Status::OK();
} }
@ -183,7 +183,7 @@ TEST_F(WritableFileWriterTest, AppendStatusReturn) {
public: public:
explicit FakeWF() : use_direct_io_(false), io_error_(false) {} explicit FakeWF() : use_direct_io_(false), io_error_(false) {}
virtual bool use_direct_io() const override { return use_direct_io_; } bool use_direct_io() const override { return use_direct_io_; }
Status Append(const Slice& /*data*/) override { Status Append(const Slice& /*data*/) override {
if (io_error_) { if (io_error_) {
return Status::IOError("Fake IO error"); return Status::IOError("Fake IO error");
@ -226,7 +226,7 @@ class ReadaheadRandomAccessFileTest
static std::vector<size_t> GetReadaheadSizeList() { static std::vector<size_t> GetReadaheadSizeList() {
return {1lu << 12, 1lu << 16}; return {1lu << 12, 1lu << 16};
} }
virtual void SetUp() override { void SetUp() override {
readahead_size_ = GetParam(); readahead_size_ = GetParam();
scratch_.reset(new char[2 * readahead_size_]); scratch_.reset(new char[2 * readahead_size_]);
ResetSourceStr(); ResetSourceStr();

@ -25,8 +25,7 @@ class LockTest : public testing::Test {
current_ = this; current_ = this;
} }
~LockTest() { ~LockTest() override {}
}
Status LockFile(FileLock** db_lock) { Status LockFile(FileLock** db_lock) {
return env_->LockFile(file_, db_lock); return env_->LockFile(file_, db_lock);

@ -32,27 +32,27 @@ class FixedPrefixTransform : public SliceTransform {
// the class implementation itself. // the class implementation itself.
name_("rocksdb.FixedPrefix." + ToString(prefix_len_)) {} name_("rocksdb.FixedPrefix." + ToString(prefix_len_)) {}
virtual const char* Name() const override { return name_.c_str(); } const char* Name() const override { return name_.c_str(); }
virtual Slice Transform(const Slice& src) const override { Slice Transform(const Slice& src) const override {
assert(InDomain(src)); assert(InDomain(src));
return Slice(src.data(), prefix_len_); return Slice(src.data(), prefix_len_);
} }
virtual bool InDomain(const Slice& src) const override { bool InDomain(const Slice& src) const override {
return (src.size() >= prefix_len_); return (src.size() >= prefix_len_);
} }
virtual bool InRange(const Slice& dst) const override { bool InRange(const Slice& dst) const override {
return (dst.size() == prefix_len_); return (dst.size() == prefix_len_);
} }
virtual bool FullLengthEnabled(size_t* len) const override { bool FullLengthEnabled(size_t* len) const override {
*len = prefix_len_; *len = prefix_len_;
return true; return true;
} }
virtual bool SameResultWhenAppended(const Slice& prefix) const override { bool SameResultWhenAppended(const Slice& prefix) const override {
return InDomain(prefix); return InDomain(prefix);
} }
}; };
@ -72,25 +72,25 @@ class CappedPrefixTransform : public SliceTransform {
// the class implementation itself. // the class implementation itself.
name_("rocksdb.CappedPrefix." + ToString(cap_len_)) {} name_("rocksdb.CappedPrefix." + ToString(cap_len_)) {}
virtual const char* Name() const override { return name_.c_str(); } const char* Name() const override { return name_.c_str(); }
virtual Slice Transform(const Slice& src) const override { Slice Transform(const Slice& src) const override {
assert(InDomain(src)); assert(InDomain(src));
return Slice(src.data(), std::min(cap_len_, src.size())); return Slice(src.data(), std::min(cap_len_, src.size()));
} }
virtual bool InDomain(const Slice& /*src*/) const override { return true; } bool InDomain(const Slice& /*src*/) const override { return true; }
virtual bool InRange(const Slice& dst) const override { bool InRange(const Slice& dst) const override {
return (dst.size() <= cap_len_); return (dst.size() <= cap_len_);
} }
virtual bool FullLengthEnabled(size_t* len) const override { bool FullLengthEnabled(size_t* len) const override {
*len = cap_len_; *len = cap_len_;
return true; return true;
} }
virtual bool SameResultWhenAppended(const Slice& prefix) const override { bool SameResultWhenAppended(const Slice& prefix) const override {
return prefix.size() >= cap_len_; return prefix.size() >= cap_len_;
} }
}; };
@ -99,15 +99,15 @@ class NoopTransform : public SliceTransform {
public: public:
explicit NoopTransform() { } explicit NoopTransform() { }
virtual const char* Name() const override { return "rocksdb.Noop"; } const char* Name() const override { return "rocksdb.Noop"; }
virtual Slice Transform(const Slice& src) const override { return src; } Slice Transform(const Slice& src) const override { return src; }
virtual bool InDomain(const Slice& /*src*/) const override { return true; } bool InDomain(const Slice& /*src*/) const override { return true; }
virtual bool InRange(const Slice& /*dst*/) const override { return true; } bool InRange(const Slice& /*dst*/) const override { return true; }
virtual bool SameResultWhenAppended(const Slice& /*prefix*/) const override { bool SameResultWhenAppended(const Slice& /*prefix*/) const override {
return false; return false;
} }
}; };

@ -57,7 +57,7 @@ class SliceTransformDBTest : public testing::Test {
EXPECT_OK(DestroyDB(dbname_, last_options_)); EXPECT_OK(DestroyDB(dbname_, last_options_));
} }
~SliceTransformDBTest() { ~SliceTransformDBTest() override {
delete db_; delete db_;
EXPECT_OK(DestroyDB(dbname_, last_options_)); EXPECT_OK(DestroyDB(dbname_, last_options_));
} }

@ -87,11 +87,9 @@ class Uint64ComparatorImpl : public Comparator {
public: public:
Uint64ComparatorImpl() {} Uint64ComparatorImpl() {}
virtual const char* Name() const override { const char* Name() const override { return "rocksdb.Uint64Comparator"; }
return "rocksdb.Uint64Comparator";
}
virtual int Compare(const Slice& a, const Slice& b) const override { int Compare(const Slice& a, const Slice& b) const override {
assert(a.size() == sizeof(uint64_t) && b.size() == sizeof(uint64_t)); assert(a.size() == sizeof(uint64_t) && b.size() == sizeof(uint64_t));
const uint64_t* left = reinterpret_cast<const uint64_t*>(a.data()); const uint64_t* left = reinterpret_cast<const uint64_t*>(a.data());
const uint64_t* right = reinterpret_cast<const uint64_t*>(b.data()); const uint64_t* right = reinterpret_cast<const uint64_t*>(b.data());
@ -108,14 +106,12 @@ class Uint64ComparatorImpl : public Comparator {
} }
} }
virtual void FindShortestSeparator(std::string* /*start*/, void FindShortestSeparator(std::string* /*start*/,
const Slice& /*limit*/) const override { const Slice& /*limit*/) const override {
return; return;
} }
virtual void FindShortSuccessor(std::string* /*key*/) const override { void FindShortSuccessor(std::string* /*key*/) const override { return; }
return;
}
}; };
} // namespace } // namespace

@ -92,7 +92,7 @@ class BackupEngineImpl : public BackupEngine {
public: public:
BackupEngineImpl(Env* db_env, const BackupableDBOptions& options, BackupEngineImpl(Env* db_env, const BackupableDBOptions& options,
bool read_only = false); bool read_only = false);
~BackupEngineImpl(); ~BackupEngineImpl() override;
Status CreateNewBackupWithMetadata(DB* db, const std::string& app_metadata, Status CreateNewBackupWithMetadata(DB* db, const std::string& app_metadata,
bool flush_before_backup = false, bool flush_before_backup = false,
std::function<void()> progress_callback = std::function<void()> progress_callback =
@ -118,7 +118,7 @@ class BackupEngineImpl : public BackupEngine {
restore_options); restore_options);
} }
virtual Status VerifyBackup(BackupID backup_id) override; Status VerifyBackup(BackupID backup_id) override;
Status Initialize(); Status Initialize();
@ -1853,34 +1853,33 @@ class BackupEngineReadOnlyImpl : public BackupEngineReadOnly {
BackupEngineReadOnlyImpl(Env* db_env, const BackupableDBOptions& options) BackupEngineReadOnlyImpl(Env* db_env, const BackupableDBOptions& options)
: backup_engine_(new BackupEngineImpl(db_env, options, true)) {} : backup_engine_(new BackupEngineImpl(db_env, options, true)) {}
virtual ~BackupEngineReadOnlyImpl() {} ~BackupEngineReadOnlyImpl() override {}
// The returned BackupInfos are in chronological order, which means the // The returned BackupInfos are in chronological order, which means the
// latest backup comes last. // latest backup comes last.
virtual void GetBackupInfo(std::vector<BackupInfo>* backup_info) override { void GetBackupInfo(std::vector<BackupInfo>* backup_info) override {
backup_engine_->GetBackupInfo(backup_info); backup_engine_->GetBackupInfo(backup_info);
} }
virtual void GetCorruptedBackups( void GetCorruptedBackups(std::vector<BackupID>* corrupt_backup_ids) override {
std::vector<BackupID>* corrupt_backup_ids) override {
backup_engine_->GetCorruptedBackups(corrupt_backup_ids); backup_engine_->GetCorruptedBackups(corrupt_backup_ids);
} }
virtual Status RestoreDBFromBackup( Status RestoreDBFromBackup(
BackupID backup_id, const std::string& db_dir, const std::string& wal_dir, BackupID backup_id, const std::string& db_dir, const std::string& wal_dir,
const RestoreOptions& restore_options = RestoreOptions()) override { const RestoreOptions& restore_options = RestoreOptions()) override {
return backup_engine_->RestoreDBFromBackup(backup_id, db_dir, wal_dir, return backup_engine_->RestoreDBFromBackup(backup_id, db_dir, wal_dir,
restore_options); restore_options);
} }
virtual Status RestoreDBFromLatestBackup( Status RestoreDBFromLatestBackup(
const std::string& db_dir, const std::string& wal_dir, const std::string& db_dir, const std::string& wal_dir,
const RestoreOptions& restore_options = RestoreOptions()) override { const RestoreOptions& restore_options = RestoreOptions()) override {
return backup_engine_->RestoreDBFromLatestBackup(db_dir, wal_dir, return backup_engine_->RestoreDBFromLatestBackup(db_dir, wal_dir,
restore_options); restore_options);
} }
virtual Status VerifyBackup(BackupID backup_id) override { Status VerifyBackup(BackupID backup_id) override {
return backup_engine_->VerifyBackup(backup_id); return backup_engine_->VerifyBackup(backup_id);
} }

@ -44,51 +44,42 @@ class DummyDB : public StackableDB {
: StackableDB(nullptr), options_(options), dbname_(dbname), : StackableDB(nullptr), options_(options), dbname_(dbname),
deletions_enabled_(true), sequence_number_(0) {} deletions_enabled_(true), sequence_number_(0) {}
virtual SequenceNumber GetLatestSequenceNumber() const override { SequenceNumber GetLatestSequenceNumber() const override {
return ++sequence_number_; return ++sequence_number_;
} }
virtual const std::string& GetName() const override { const std::string& GetName() const override { return dbname_; }
return dbname_;
}
virtual Env* GetEnv() const override { Env* GetEnv() const override { return options_.env; }
return options_.env;
}
using DB::GetOptions; using DB::GetOptions;
virtual Options GetOptions( Options GetOptions(ColumnFamilyHandle* /*column_family*/) const override {
ColumnFamilyHandle* /*column_family*/) const override {
return options_; return options_;
} }
virtual DBOptions GetDBOptions() const override { DBOptions GetDBOptions() const override { return DBOptions(options_); }
return DBOptions(options_);
}
virtual Status EnableFileDeletions(bool /*force*/) override { Status EnableFileDeletions(bool /*force*/) override {
EXPECT_TRUE(!deletions_enabled_); EXPECT_TRUE(!deletions_enabled_);
deletions_enabled_ = true; deletions_enabled_ = true;
return Status::OK(); return Status::OK();
} }
virtual Status DisableFileDeletions() override { Status DisableFileDeletions() override {
EXPECT_TRUE(deletions_enabled_); EXPECT_TRUE(deletions_enabled_);
deletions_enabled_ = false; deletions_enabled_ = false;
return Status::OK(); return Status::OK();
} }
virtual Status GetLiveFiles(std::vector<std::string>& vec, uint64_t* mfs, Status GetLiveFiles(std::vector<std::string>& vec, uint64_t* mfs,
bool /*flush_memtable*/ = true) override { bool /*flush_memtable*/ = true) override {
EXPECT_TRUE(!deletions_enabled_); EXPECT_TRUE(!deletions_enabled_);
vec = live_files_; vec = live_files_;
*mfs = 100; *mfs = 100;
return Status::OK(); return Status::OK();
} }
virtual ColumnFamilyHandle* DefaultColumnFamily() const override { ColumnFamilyHandle* DefaultColumnFamily() const override { return nullptr; }
return nullptr;
}
class DummyLogFile : public LogFile { class DummyLogFile : public LogFile {
public: public:
@ -96,36 +87,32 @@ class DummyDB : public StackableDB {
DummyLogFile(const std::string& path, bool alive = true) DummyLogFile(const std::string& path, bool alive = true)
: path_(path), alive_(alive) {} : path_(path), alive_(alive) {}
virtual std::string PathName() const override { std::string PathName() const override { return path_; }
return path_;
}
virtual uint64_t LogNumber() const override { uint64_t LogNumber() const override {
// what business do you have calling this method? // what business do you have calling this method?
ADD_FAILURE(); ADD_FAILURE();
return 0; return 0;
} }
virtual WalFileType Type() const override { WalFileType Type() const override {
return alive_ ? kAliveLogFile : kArchivedLogFile; return alive_ ? kAliveLogFile : kArchivedLogFile;
} }
virtual SequenceNumber StartSequence() const override { SequenceNumber StartSequence() const override {
// this seqnum guarantees the dummy file will be included in the backup // this seqnum guarantees the dummy file will be included in the backup
// as long as it is alive. // as long as it is alive.
return kMaxSequenceNumber; return kMaxSequenceNumber;
} }
virtual uint64_t SizeFileBytes() const override { uint64_t SizeFileBytes() const override { return 0; }
return 0;
}
private: private:
std::string path_; std::string path_;
bool alive_; bool alive_;
}; // DummyLogFile }; // DummyLogFile
virtual Status GetSortedWalFiles(VectorLogPtr& files) override { Status GetSortedWalFiles(VectorLogPtr& files) override {
EXPECT_TRUE(!deletions_enabled_); EXPECT_TRUE(!deletions_enabled_);
files.resize(wal_files_.size()); files.resize(wal_files_.size());
for (size_t i = 0; i < files.size(); ++i) { for (size_t i = 0; i < files.size(); ++i) {
@ -136,7 +123,7 @@ class DummyDB : public StackableDB {
} }
// To avoid FlushWAL called on stacked db which is nullptr // To avoid FlushWAL called on stacked db which is nullptr
virtual Status FlushWAL(bool /*sync*/) override { return Status::OK(); } Status FlushWAL(bool /*sync*/) override { return Status::OK(); }
std::vector<std::string> live_files_; std::vector<std::string> live_files_;
// pair<filename, alive?> // pair<filename, alive?>
@ -156,7 +143,7 @@ class TestEnv : public EnvWrapper {
public: public:
explicit DummySequentialFile(bool fail_reads) explicit DummySequentialFile(bool fail_reads)
: SequentialFile(), rnd_(5), fail_reads_(fail_reads) {} : SequentialFile(), rnd_(5), fail_reads_(fail_reads) {}
virtual Status Read(size_t n, Slice* result, char* scratch) override { Status Read(size_t n, Slice* result, char* scratch) override {
if (fail_reads_) { if (fail_reads_) {
return Status::IOError(); return Status::IOError();
} }
@ -169,10 +156,11 @@ class TestEnv : public EnvWrapper {
return Status::OK(); return Status::OK();
} }
virtual Status Skip(uint64_t n) override { Status Skip(uint64_t n) override {
size_left = (n > size_left) ? size_left - n : 0; size_left = (n > size_left) ? size_left - n : 0;
return Status::OK(); return Status::OK();
} }
private: private:
size_t size_left = 200; size_t size_left = 200;
Random rnd_; Random rnd_;
@ -217,9 +205,9 @@ class TestEnv : public EnvWrapper {
return s; return s;
} }
virtual Status NewRandomAccessFile(const std::string& fname, Status NewRandomAccessFile(const std::string& fname,
unique_ptr<RandomAccessFile>* result, unique_ptr<RandomAccessFile>* result,
const EnvOptions& options) override { const EnvOptions& options) override {
MutexLock l(&mutex_); MutexLock l(&mutex_);
Status s = EnvWrapper::NewRandomAccessFile(fname, result, options); Status s = EnvWrapper::NewRandomAccessFile(fname, result, options);
if (s.ok()) { if (s.ok()) {
@ -231,7 +219,7 @@ class TestEnv : public EnvWrapper {
return s; return s;
} }
virtual Status DeleteFile(const std::string& fname) override { Status DeleteFile(const std::string& fname) override {
MutexLock l(&mutex_); MutexLock l(&mutex_);
if (fail_delete_files_) { if (fail_delete_files_) {
return Status::IOError(); return Status::IOError();
@ -241,7 +229,7 @@ class TestEnv : public EnvWrapper {
return EnvWrapper::DeleteFile(fname); return EnvWrapper::DeleteFile(fname);
} }
virtual Status DeleteDir(const std::string& dirname) override { Status DeleteDir(const std::string& dirname) override {
MutexLock l(&mutex_); MutexLock l(&mutex_);
if (fail_delete_files_) { if (fail_delete_files_) {
return Status::IOError(); return Status::IOError();
@ -336,8 +324,8 @@ class TestEnv : public EnvWrapper {
} }
void SetNewDirectoryFailure(bool fail) { new_directory_failure_ = fail; } void SetNewDirectoryFailure(bool fail) { new_directory_failure_ = fail; }
virtual Status NewDirectory(const std::string& name, Status NewDirectory(const std::string& name,
std::unique_ptr<Directory>* result) override { std::unique_ptr<Directory>* result) override {
if (new_directory_failure_) { if (new_directory_failure_) {
return Status::IOError("SimulatedFailure"); return Status::IOError("SimulatedFailure");
} }

@ -22,24 +22,21 @@ class BlobIndexCompactionFilter : public CompactionFilter {
current_time_(current_time), current_time_(current_time),
statistics_(statistics) {} statistics_(statistics) {}
virtual ~BlobIndexCompactionFilter() { ~BlobIndexCompactionFilter() override {
RecordTick(statistics_, BLOB_DB_BLOB_INDEX_EXPIRED_COUNT, expired_count_); RecordTick(statistics_, BLOB_DB_BLOB_INDEX_EXPIRED_COUNT, expired_count_);
RecordTick(statistics_, BLOB_DB_BLOB_INDEX_EXPIRED_SIZE, expired_size_); RecordTick(statistics_, BLOB_DB_BLOB_INDEX_EXPIRED_SIZE, expired_size_);
RecordTick(statistics_, BLOB_DB_BLOB_INDEX_EVICTED_COUNT, evicted_count_); RecordTick(statistics_, BLOB_DB_BLOB_INDEX_EVICTED_COUNT, evicted_count_);
RecordTick(statistics_, BLOB_DB_BLOB_INDEX_EVICTED_SIZE, evicted_size_); RecordTick(statistics_, BLOB_DB_BLOB_INDEX_EVICTED_SIZE, evicted_size_);
} }
virtual const char* Name() const override { const char* Name() const override { return "BlobIndexCompactionFilter"; }
return "BlobIndexCompactionFilter";
}
// Filter expired blob indexes regardless of snapshots. // Filter expired blob indexes regardless of snapshots.
virtual bool IgnoreSnapshots() const override { return true; } bool IgnoreSnapshots() const override { return true; }
virtual Decision FilterV2(int /*level*/, const Slice& key, Decision FilterV2(int /*level*/, const Slice& key, ValueType value_type,
ValueType value_type, const Slice& value, const Slice& value, std::string* /*new_value*/,
std::string* /*new_value*/, std::string* /*skip_until*/) const override {
std::string* /*skip_until*/) const override {
if (value_type != kBlobIndex) { if (value_type != kBlobIndex) {
return Decision::kKeep; return Decision::kKeep;
} }

@ -568,8 +568,8 @@ class BlobDBImpl::BlobInserter : public WriteBatch::Handler {
WriteBatch* batch() { return &batch_; } WriteBatch* batch() { return &batch_; }
virtual Status PutCF(uint32_t column_family_id, const Slice& key, Status PutCF(uint32_t column_family_id, const Slice& key,
const Slice& value) override { const Slice& value) override {
if (column_family_id != default_cf_id_) { if (column_family_id != default_cf_id_) {
return Status::NotSupported( return Status::NotSupported(
"Blob DB doesn't support non-default column family."); "Blob DB doesn't support non-default column family.");
@ -579,8 +579,7 @@ class BlobDBImpl::BlobInserter : public WriteBatch::Handler {
return s; return s;
} }
virtual Status DeleteCF(uint32_t column_family_id, Status DeleteCF(uint32_t column_family_id, const Slice& key) override {
const Slice& key) override {
if (column_family_id != default_cf_id_) { if (column_family_id != default_cf_id_) {
return Status::NotSupported( return Status::NotSupported(
"Blob DB doesn't support non-default column family."); "Blob DB doesn't support non-default column family.");
@ -600,17 +599,17 @@ class BlobDBImpl::BlobInserter : public WriteBatch::Handler {
return s; return s;
} }
virtual Status SingleDeleteCF(uint32_t /*column_family_id*/, Status SingleDeleteCF(uint32_t /*column_family_id*/,
const Slice& /*key*/) override { const Slice& /*key*/) override {
return Status::NotSupported("Not supported operation in blob db."); return Status::NotSupported("Not supported operation in blob db.");
} }
virtual Status MergeCF(uint32_t /*column_family_id*/, const Slice& /*key*/, Status MergeCF(uint32_t /*column_family_id*/, const Slice& /*key*/,
const Slice& /*value*/) override { const Slice& /*value*/) override {
return Status::NotSupported("Not supported operation in blob db."); return Status::NotSupported("Not supported operation in blob db.");
} }
virtual void LogData(const Slice& blob) override { batch_.PutLogData(blob); } void LogData(const Slice& blob) override { batch_.PutLogData(blob); }
}; };
Status BlobDBImpl::Write(const WriteOptions& options, WriteBatch* updates) { Status BlobDBImpl::Write(const WriteOptions& options, WriteBatch* updates) {
@ -1405,7 +1404,7 @@ class BlobDBImpl::GarbageCollectionWriteCallback : public WriteCallback {
SequenceNumber upper_bound) SequenceNumber upper_bound)
: cfd_(cfd), key_(key), upper_bound_(upper_bound) {} : cfd_(cfd), key_(key), upper_bound_(upper_bound) {}
virtual Status Callback(DB* db) override { Status Callback(DB* db) override {
auto* db_impl = reinterpret_cast<DBImpl*>(db); auto* db_impl = reinterpret_cast<DBImpl*>(db);
auto* sv = db_impl->GetAndRefSuperVersion(cfd_); auto* sv = db_impl->GetAndRefSuperVersion(cfd_);
SequenceNumber latest_seq = 0; SequenceNumber latest_seq = 0;
@ -1432,7 +1431,7 @@ class BlobDBImpl::GarbageCollectionWriteCallback : public WriteCallback {
return s; return s;
} }
virtual bool AllowWriteBatching() override { return false; } bool AllowWriteBatching() override { return false; }
private: private:
ColumnFamilyData* cfd_; ColumnFamilyData* cfd_;

@ -48,7 +48,7 @@ class BlobDBTest : public testing::Test {
assert(s.ok()); assert(s.ok());
} }
~BlobDBTest() { ~BlobDBTest() override {
SyncPoint::GetInstance()->ClearAllCallBacks(); SyncPoint::GetInstance()->ClearAllCallBacks();
Destroy(); Destroy();
} }
@ -1234,12 +1234,12 @@ TEST_F(BlobDBTest, InlineSmallValues) {
TEST_F(BlobDBTest, CompactionFilterNotSupported) { TEST_F(BlobDBTest, CompactionFilterNotSupported) {
class TestCompactionFilter : public CompactionFilter { class TestCompactionFilter : public CompactionFilter {
virtual const char *Name() const { return "TestCompactionFilter"; } const char *Name() const override { return "TestCompactionFilter"; }
}; };
class TestCompactionFilterFactory : public CompactionFilterFactory { class TestCompactionFilterFactory : public CompactionFilterFactory {
virtual const char *Name() const { return "TestCompactionFilterFactory"; } const char *Name() const override { return "TestCompactionFilterFactory"; }
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter( std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context & /*context*/) { const CompactionFilter::Context & /*context*/) override {
return std::unique_ptr<CompactionFilter>(new TestCompactionFilter()); return std::unique_ptr<CompactionFilter>(new TestCompactionFilter());
} }
}; };

@ -99,15 +99,13 @@ public:
: purge_ttl_on_expiration_(purge_ttl_on_expiration), : purge_ttl_on_expiration_(purge_ttl_on_expiration),
gc_grace_period_in_seconds_(gc_grace_period_in_seconds) {} gc_grace_period_in_seconds_(gc_grace_period_in_seconds) {}
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter( std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& /*context*/) override { const CompactionFilter::Context& /*context*/) override {
return std::unique_ptr<CompactionFilter>(new CassandraCompactionFilter( return std::unique_ptr<CompactionFilter>(new CassandraCompactionFilter(
purge_ttl_on_expiration_, gc_grace_period_in_seconds_)); purge_ttl_on_expiration_, gc_grace_period_in_seconds_));
} }
virtual const char* Name() const override { const char* Name() const override { return "TestCompactionFilterFactory"; }
return "TestCompactionFilterFactory";
}
private: private:
bool purge_ttl_on_expiration_; bool purge_ttl_on_expiration_;

@ -66,7 +66,7 @@ class CheckpointTest : public testing::Test {
Reopen(options); Reopen(options);
} }
~CheckpointTest() { ~CheckpointTest() override {
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); rocksdb::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->LoadDependency({}); rocksdb::SyncPoint::GetInstance()->LoadDependency({});
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks(); rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks();

@ -17,121 +17,118 @@ class TimedEnv : public EnvWrapper {
public: public:
explicit TimedEnv(Env* base_env) : EnvWrapper(base_env) {} explicit TimedEnv(Env* base_env) : EnvWrapper(base_env) {}
virtual Status NewSequentialFile(const std::string& fname, Status NewSequentialFile(const std::string& fname,
std::unique_ptr<SequentialFile>* result, std::unique_ptr<SequentialFile>* result,
const EnvOptions& options) override { const EnvOptions& options) override {
PERF_TIMER_GUARD(env_new_sequential_file_nanos); PERF_TIMER_GUARD(env_new_sequential_file_nanos);
return EnvWrapper::NewSequentialFile(fname, result, options); return EnvWrapper::NewSequentialFile(fname, result, options);
} }
virtual Status NewRandomAccessFile(const std::string& fname, Status NewRandomAccessFile(const std::string& fname,
std::unique_ptr<RandomAccessFile>* result, std::unique_ptr<RandomAccessFile>* result,
const EnvOptions& options) override { const EnvOptions& options) override {
PERF_TIMER_GUARD(env_new_random_access_file_nanos); PERF_TIMER_GUARD(env_new_random_access_file_nanos);
return EnvWrapper::NewRandomAccessFile(fname, result, options); return EnvWrapper::NewRandomAccessFile(fname, result, options);
} }
virtual Status NewWritableFile(const std::string& fname, Status NewWritableFile(const std::string& fname,
std::unique_ptr<WritableFile>* result, std::unique_ptr<WritableFile>* result,
const EnvOptions& options) override { const EnvOptions& options) override {
PERF_TIMER_GUARD(env_new_writable_file_nanos); PERF_TIMER_GUARD(env_new_writable_file_nanos);
return EnvWrapper::NewWritableFile(fname, result, options); return EnvWrapper::NewWritableFile(fname, result, options);
} }
virtual Status ReuseWritableFile(const std::string& fname, Status ReuseWritableFile(const std::string& fname,
const std::string& old_fname, const std::string& old_fname,
std::unique_ptr<WritableFile>* result, std::unique_ptr<WritableFile>* result,
const EnvOptions& options) override { const EnvOptions& options) override {
PERF_TIMER_GUARD(env_reuse_writable_file_nanos); PERF_TIMER_GUARD(env_reuse_writable_file_nanos);
return EnvWrapper::ReuseWritableFile(fname, old_fname, result, options); return EnvWrapper::ReuseWritableFile(fname, old_fname, result, options);
} }
virtual Status NewRandomRWFile(const std::string& fname, Status NewRandomRWFile(const std::string& fname,
std::unique_ptr<RandomRWFile>* result, std::unique_ptr<RandomRWFile>* result,
const EnvOptions& options) override { const EnvOptions& options) override {
PERF_TIMER_GUARD(env_new_random_rw_file_nanos); PERF_TIMER_GUARD(env_new_random_rw_file_nanos);
return EnvWrapper::NewRandomRWFile(fname, result, options); return EnvWrapper::NewRandomRWFile(fname, result, options);
} }
virtual Status NewDirectory(const std::string& name, Status NewDirectory(const std::string& name,
std::unique_ptr<Directory>* result) override { std::unique_ptr<Directory>* result) override {
PERF_TIMER_GUARD(env_new_directory_nanos); PERF_TIMER_GUARD(env_new_directory_nanos);
return EnvWrapper::NewDirectory(name, result); return EnvWrapper::NewDirectory(name, result);
} }
virtual Status FileExists(const std::string& fname) override { Status FileExists(const std::string& fname) override {
PERF_TIMER_GUARD(env_file_exists_nanos); PERF_TIMER_GUARD(env_file_exists_nanos);
return EnvWrapper::FileExists(fname); return EnvWrapper::FileExists(fname);
} }
virtual Status GetChildren(const std::string& dir, Status GetChildren(const std::string& dir,
std::vector<std::string>* result) override { std::vector<std::string>* result) override {
PERF_TIMER_GUARD(env_get_children_nanos); PERF_TIMER_GUARD(env_get_children_nanos);
return EnvWrapper::GetChildren(dir, result); return EnvWrapper::GetChildren(dir, result);
} }
virtual Status GetChildrenFileAttributes( Status GetChildrenFileAttributes(
const std::string& dir, std::vector<FileAttributes>* result) override { const std::string& dir, std::vector<FileAttributes>* result) override {
PERF_TIMER_GUARD(env_get_children_file_attributes_nanos); PERF_TIMER_GUARD(env_get_children_file_attributes_nanos);
return EnvWrapper::GetChildrenFileAttributes(dir, result); return EnvWrapper::GetChildrenFileAttributes(dir, result);
} }
virtual Status DeleteFile(const std::string& fname) override { Status DeleteFile(const std::string& fname) override {
PERF_TIMER_GUARD(env_delete_file_nanos); PERF_TIMER_GUARD(env_delete_file_nanos);
return EnvWrapper::DeleteFile(fname); return EnvWrapper::DeleteFile(fname);
} }
virtual Status CreateDir(const std::string& dirname) override { Status CreateDir(const std::string& dirname) override {
PERF_TIMER_GUARD(env_create_dir_nanos); PERF_TIMER_GUARD(env_create_dir_nanos);
return EnvWrapper::CreateDir(dirname); return EnvWrapper::CreateDir(dirname);
} }
virtual Status CreateDirIfMissing(const std::string& dirname) override { Status CreateDirIfMissing(const std::string& dirname) override {
PERF_TIMER_GUARD(env_create_dir_if_missing_nanos); PERF_TIMER_GUARD(env_create_dir_if_missing_nanos);
return EnvWrapper::CreateDirIfMissing(dirname); return EnvWrapper::CreateDirIfMissing(dirname);
} }
virtual Status DeleteDir(const std::string& dirname) override { Status DeleteDir(const std::string& dirname) override {
PERF_TIMER_GUARD(env_delete_dir_nanos); PERF_TIMER_GUARD(env_delete_dir_nanos);
return EnvWrapper::DeleteDir(dirname); return EnvWrapper::DeleteDir(dirname);
} }
virtual Status GetFileSize(const std::string& fname, Status GetFileSize(const std::string& fname, uint64_t* file_size) override {
uint64_t* file_size) override {
PERF_TIMER_GUARD(env_get_file_size_nanos); PERF_TIMER_GUARD(env_get_file_size_nanos);
return EnvWrapper::GetFileSize(fname, file_size); return EnvWrapper::GetFileSize(fname, file_size);
} }
virtual Status GetFileModificationTime(const std::string& fname, Status GetFileModificationTime(const std::string& fname,
uint64_t* file_mtime) override { uint64_t* file_mtime) override {
PERF_TIMER_GUARD(env_get_file_modification_time_nanos); PERF_TIMER_GUARD(env_get_file_modification_time_nanos);
return EnvWrapper::GetFileModificationTime(fname, file_mtime); return EnvWrapper::GetFileModificationTime(fname, file_mtime);
} }
virtual Status RenameFile(const std::string& src, Status RenameFile(const std::string& src, const std::string& dst) override {
const std::string& dst) override {
PERF_TIMER_GUARD(env_rename_file_nanos); PERF_TIMER_GUARD(env_rename_file_nanos);
return EnvWrapper::RenameFile(src, dst); return EnvWrapper::RenameFile(src, dst);
} }
virtual Status LinkFile(const std::string& src, Status LinkFile(const std::string& src, const std::string& dst) override {
const std::string& dst) override {
PERF_TIMER_GUARD(env_link_file_nanos); PERF_TIMER_GUARD(env_link_file_nanos);
return EnvWrapper::LinkFile(src, dst); return EnvWrapper::LinkFile(src, dst);
} }
virtual Status LockFile(const std::string& fname, FileLock** lock) override { Status LockFile(const std::string& fname, FileLock** lock) override {
PERF_TIMER_GUARD(env_lock_file_nanos); PERF_TIMER_GUARD(env_lock_file_nanos);
return EnvWrapper::LockFile(fname, lock); return EnvWrapper::LockFile(fname, lock);
} }
virtual Status UnlockFile(FileLock* lock) override { Status UnlockFile(FileLock* lock) override {
PERF_TIMER_GUARD(env_unlock_file_nanos); PERF_TIMER_GUARD(env_unlock_file_nanos);
return EnvWrapper::UnlockFile(lock); return EnvWrapper::UnlockFile(lock);
} }
virtual Status NewLogger(const std::string& fname, Status NewLogger(const std::string& fname,
std::shared_ptr<Logger>* result) override { std::shared_ptr<Logger>* result) override {
PERF_TIMER_GUARD(env_new_logger_nanos); PERF_TIMER_GUARD(env_new_logger_nanos);
return EnvWrapper::NewLogger(fname, result); return EnvWrapper::NewLogger(fname, result);
} }

@ -19,8 +19,8 @@ namespace { // anonymous namespace
// Slice::compare // Slice::compare
class MaxOperator : public MergeOperator { class MaxOperator : public MergeOperator {
public: public:
virtual bool FullMergeV2(const MergeOperationInput& merge_in, bool FullMergeV2(const MergeOperationInput& merge_in,
MergeOperationOutput* merge_out) const override { MergeOperationOutput* merge_out) const override {
Slice& max = merge_out->existing_operand; Slice& max = merge_out->existing_operand;
if (merge_in.existing_value) { if (merge_in.existing_value) {
max = Slice(merge_in.existing_value->data(), max = Slice(merge_in.existing_value->data(),
@ -38,9 +38,9 @@ class MaxOperator : public MergeOperator {
return true; return true;
} }
virtual bool PartialMerge(const Slice& /*key*/, const Slice& left_operand, bool PartialMerge(const Slice& /*key*/, const Slice& left_operand,
const Slice& right_operand, std::string* new_value, const Slice& right_operand, std::string* new_value,
Logger* /*logger*/) const override { Logger* /*logger*/) const override {
if (left_operand.compare(right_operand) >= 0) { if (left_operand.compare(right_operand) >= 0) {
new_value->assign(left_operand.data(), left_operand.size()); new_value->assign(left_operand.data(), left_operand.size());
} else { } else {
@ -49,10 +49,10 @@ class MaxOperator : public MergeOperator {
return true; return true;
} }
virtual bool PartialMergeMulti(const Slice& /*key*/, bool PartialMergeMulti(const Slice& /*key*/,
const std::deque<Slice>& operand_list, const std::deque<Slice>& operand_list,
std::string* new_value, std::string* new_value,
Logger* /*logger*/) const override { Logger* /*logger*/) const override {
Slice max; Slice max;
for (const auto& operand : operand_list) { for (const auto& operand : operand_list) {
if (max.compare(operand) < 0) { if (max.compare(operand) < 0) {
@ -64,7 +64,7 @@ class MaxOperator : public MergeOperator {
return true; return true;
} }
virtual const char* Name() const override { return "MaxOperator"; } const char* Name() const override { return "MaxOperator"; }
}; };
} // end of anonymous namespace } // end of anonymous namespace

@ -22,10 +22,9 @@ namespace { // anonymous namespace
// From the client-perspective, semantics are the same. // From the client-perspective, semantics are the same.
class PutOperator : public MergeOperator { class PutOperator : public MergeOperator {
public: public:
virtual bool FullMerge(const Slice& /*key*/, const Slice* /*existing_value*/, bool FullMerge(const Slice& /*key*/, const Slice* /*existing_value*/,
const std::deque<std::string>& operand_sequence, const std::deque<std::string>& operand_sequence,
std::string* new_value, std::string* new_value, Logger* /*logger*/) const override {
Logger* /*logger*/) const override {
// Put basically only looks at the current/latest value // Put basically only looks at the current/latest value
assert(!operand_sequence.empty()); assert(!operand_sequence.empty());
assert(new_value != nullptr); assert(new_value != nullptr);
@ -33,38 +32,36 @@ class PutOperator : public MergeOperator {
return true; return true;
} }
virtual bool PartialMerge(const Slice& /*key*/, const Slice& /*left_operand*/, bool PartialMerge(const Slice& /*key*/, const Slice& /*left_operand*/,
const Slice& right_operand, std::string* new_value, const Slice& right_operand, std::string* new_value,
Logger* /*logger*/) const override { Logger* /*logger*/) const override {
new_value->assign(right_operand.data(), right_operand.size()); new_value->assign(right_operand.data(), right_operand.size());
return true; return true;
} }
using MergeOperator::PartialMergeMulti; using MergeOperator::PartialMergeMulti;
virtual bool PartialMergeMulti(const Slice& /*key*/, bool PartialMergeMulti(const Slice& /*key*/,
const std::deque<Slice>& operand_list, const std::deque<Slice>& operand_list,
std::string* new_value, std::string* new_value,
Logger* /*logger*/) const override { Logger* /*logger*/) const override {
new_value->assign(operand_list.back().data(), operand_list.back().size()); new_value->assign(operand_list.back().data(), operand_list.back().size());
return true; return true;
} }
virtual const char* Name() const override { const char* Name() const override { return "PutOperator"; }
return "PutOperator";
}
}; };
class PutOperatorV2 : public PutOperator { class PutOperatorV2 : public PutOperator {
virtual bool FullMerge(const Slice& /*key*/, const Slice* /*existing_value*/, bool FullMerge(const Slice& /*key*/, const Slice* /*existing_value*/,
const std::deque<std::string>& /*operand_sequence*/, const std::deque<std::string>& /*operand_sequence*/,
std::string* /*new_value*/, std::string* /*new_value*/,
Logger* /*logger*/) const override { Logger* /*logger*/) const override {
assert(false); assert(false);
return false; return false;
} }
virtual bool FullMergeV2(const MergeOperationInput& merge_in, bool FullMergeV2(const MergeOperationInput& merge_in,
MergeOperationOutput* merge_out) const override { MergeOperationOutput* merge_out) const override {
// Put basically only looks at the current/latest value // Put basically only looks at the current/latest value
assert(!merge_in.operand_list.empty()); assert(!merge_in.operand_list.empty());
merge_out->existing_operand = merge_in.operand_list.back(); merge_out->existing_operand = merge_in.operand_list.back();

@ -20,9 +20,9 @@ namespace { // anonymous namespace
// Implemented as an AssociativeMergeOperator for simplicity and example. // Implemented as an AssociativeMergeOperator for simplicity and example.
class UInt64AddOperator : public AssociativeMergeOperator { class UInt64AddOperator : public AssociativeMergeOperator {
public: public:
virtual bool Merge(const Slice& /*key*/, const Slice* existing_value, bool Merge(const Slice& /*key*/, const Slice* existing_value,
const Slice& value, std::string* new_value, const Slice& value, std::string* new_value,
Logger* logger) const override { Logger* logger) const override {
uint64_t orig_value = 0; uint64_t orig_value = 0;
if (existing_value){ if (existing_value){
orig_value = DecodeInteger(*existing_value, logger); orig_value = DecodeInteger(*existing_value, logger);
@ -36,9 +36,7 @@ class UInt64AddOperator : public AssociativeMergeOperator {
return true; // Return true always since corruption will be treated as 0 return true; // Return true always since corruption will be treated as 0
} }
virtual const char* Name() const override { const char* Name() const override { return "UInt64AddOperator"; }
return "UInt64AddOperator";
}
private: private:
// Takes the string and decodes it into a uint64_t // Takes the string and decodes it into a uint64_t

@ -98,11 +98,11 @@ namespace {
class DummyTableFactory : public TableFactory { class DummyTableFactory : public TableFactory {
public: public:
DummyTableFactory() {} DummyTableFactory() {}
virtual ~DummyTableFactory() {} ~DummyTableFactory() override {}
virtual const char* Name() const override { return "DummyTableFactory"; } const char* Name() const override { return "DummyTableFactory"; }
virtual Status NewTableReader( Status NewTableReader(
const TableReaderOptions& /*table_reader_options*/, const TableReaderOptions& /*table_reader_options*/,
std::unique_ptr<RandomAccessFileReader>&& /*file*/, std::unique_ptr<RandomAccessFileReader>&& /*file*/,
uint64_t /*file_size*/, std::unique_ptr<TableReader>* /*table_reader*/, uint64_t /*file_size*/, std::unique_ptr<TableReader>* /*table_reader*/,
@ -110,20 +110,20 @@ class DummyTableFactory : public TableFactory {
return Status::NotSupported(); return Status::NotSupported();
} }
virtual TableBuilder* NewTableBuilder( TableBuilder* NewTableBuilder(
const TableBuilderOptions& /*table_builder_options*/, const TableBuilderOptions& /*table_builder_options*/,
uint32_t /*column_family_id*/, uint32_t /*column_family_id*/,
WritableFileWriter* /*file*/) const override { WritableFileWriter* /*file*/) const override {
return nullptr; return nullptr;
} }
virtual Status SanitizeOptions( Status SanitizeOptions(
const DBOptions& /*db_opts*/, const DBOptions& /*db_opts*/,
const ColumnFamilyOptions& /*cf_opts*/) const override { const ColumnFamilyOptions& /*cf_opts*/) const override {
return Status::NotSupported(); return Status::NotSupported();
} }
virtual std::string GetPrintableTableOptions() const override { return ""; } std::string GetPrintableTableOptions() const override { return ""; }
Status GetOptionString(std::string* /*opt_string*/, Status GetOptionString(std::string* /*opt_string*/,
const std::string& /*delimiter*/) const override { const std::string& /*delimiter*/) const override {
@ -134,39 +134,39 @@ class DummyTableFactory : public TableFactory {
class DummyMergeOperator : public MergeOperator { class DummyMergeOperator : public MergeOperator {
public: public:
DummyMergeOperator() {} DummyMergeOperator() {}
virtual ~DummyMergeOperator() {} ~DummyMergeOperator() override {}
virtual bool FullMergeV2(const MergeOperationInput& /*merge_in*/, bool FullMergeV2(const MergeOperationInput& /*merge_in*/,
MergeOperationOutput* /*merge_out*/) const override { MergeOperationOutput* /*merge_out*/) const override {
return false; return false;
} }
virtual bool PartialMergeMulti(const Slice& /*key*/, bool PartialMergeMulti(const Slice& /*key*/,
const std::deque<Slice>& /*operand_list*/, const std::deque<Slice>& /*operand_list*/,
std::string* /*new_value*/, std::string* /*new_value*/,
Logger* /*logger*/) const override { Logger* /*logger*/) const override {
return false; return false;
} }
virtual const char* Name() const override { return "DummyMergeOperator"; } const char* Name() const override { return "DummyMergeOperator"; }
}; };
class DummySliceTransform : public SliceTransform { class DummySliceTransform : public SliceTransform {
public: public:
DummySliceTransform() {} DummySliceTransform() {}
virtual ~DummySliceTransform() {} ~DummySliceTransform() override {}
// Return the name of this transformation. // Return the name of this transformation.
virtual const char* Name() const { return "DummySliceTransform"; } const char* Name() const override { return "DummySliceTransform"; }
// transform a src in domain to a dst in the range // transform a src in domain to a dst in the range
virtual Slice Transform(const Slice& src) const { return src; } Slice Transform(const Slice& src) const override { return src; }
// determine whether this is a valid src upon the function applies // determine whether this is a valid src upon the function applies
virtual bool InDomain(const Slice& /*src*/) const { return false; } bool InDomain(const Slice& /*src*/) const override { return false; }
// determine whether dst=Transform(src) for some src // determine whether dst=Transform(src) for some src
virtual bool InRange(const Slice& /*dst*/) const { return false; } bool InRange(const Slice& /*dst*/) const override { return false; }
}; };
} // namespace } // namespace

@ -20,7 +20,7 @@
namespace rocksdb { namespace rocksdb {
struct HashTableTest : public testing::Test { struct HashTableTest : public testing::Test {
~HashTableTest() { map_.Clear(&HashTableTest::ClearNode); } ~HashTableTest() override { map_.Clear(&HashTableTest::ClearNode); }
struct Node { struct Node {
Node() {} Node() {}
@ -49,7 +49,9 @@ struct HashTableTest : public testing::Test {
}; };
struct EvictableHashTableTest : public testing::Test { struct EvictableHashTableTest : public testing::Test {
~EvictableHashTableTest() { map_.Clear(&EvictableHashTableTest::ClearNode); } ~EvictableHashTableTest() override {
map_.Clear(&EvictableHashTableTest::ClearNode);
}
struct Node : LRUElement<Node> { struct Node : LRUElement<Node> {
Node() {} Node() {}

@ -160,18 +160,16 @@ class SimCacheImpl : public SimCache {
hit_times_(0), hit_times_(0),
stats_(nullptr) {} stats_(nullptr) {}
virtual ~SimCacheImpl() {} ~SimCacheImpl() override {}
virtual void SetCapacity(size_t capacity) override { void SetCapacity(size_t capacity) override { cache_->SetCapacity(capacity); }
cache_->SetCapacity(capacity);
}
virtual void SetStrictCapacityLimit(bool strict_capacity_limit) override { void SetStrictCapacityLimit(bool strict_capacity_limit) override {
cache_->SetStrictCapacityLimit(strict_capacity_limit); cache_->SetStrictCapacityLimit(strict_capacity_limit);
} }
virtual Status Insert(const Slice& key, void* value, size_t charge, Status Insert(const Slice& key, void* value, size_t charge,
void (*deleter)(const Slice& key, void* value), void (*deleter)(const Slice& key, void* value), Handle** handle,
Handle** handle, Priority priority) override { Priority priority) override {
// The handle and value passed in are for real cache, so we pass nullptr // The handle and value passed in are for real cache, so we pass nullptr
// to key_only_cache_ for both instead. Also, the deleter function pointer // to key_only_cache_ for both instead. Also, the deleter function pointer
// will be called by user to perform some external operation which should // will be called by user to perform some external operation which should
@ -191,7 +189,7 @@ class SimCacheImpl : public SimCache {
return cache_->Insert(key, value, charge, deleter, handle, priority); return cache_->Insert(key, value, charge, deleter, handle, priority);
} }
virtual Handle* Lookup(const Slice& key, Statistics* stats) override { Handle* Lookup(const Slice& key, Statistics* stats) override {
Handle* h = key_only_cache_->Lookup(key); Handle* h = key_only_cache_->Lookup(key);
if (h != nullptr) { if (h != nullptr) {
key_only_cache_->Release(h); key_only_cache_->Release(h);
@ -207,79 +205,75 @@ class SimCacheImpl : public SimCache {
return cache_->Lookup(key, stats); return cache_->Lookup(key, stats);
} }
virtual bool Ref(Handle* handle) override { return cache_->Ref(handle); } bool Ref(Handle* handle) override { return cache_->Ref(handle); }
virtual bool Release(Handle* handle, bool force_erase = false) override { bool Release(Handle* handle, bool force_erase = false) override {
return cache_->Release(handle, force_erase); return cache_->Release(handle, force_erase);
} }
virtual void Erase(const Slice& key) override { void Erase(const Slice& key) override {
cache_->Erase(key); cache_->Erase(key);
key_only_cache_->Erase(key); key_only_cache_->Erase(key);
} }
virtual void* Value(Handle* handle) override { return cache_->Value(handle); } void* Value(Handle* handle) override { return cache_->Value(handle); }
virtual uint64_t NewId() override { return cache_->NewId(); } uint64_t NewId() override { return cache_->NewId(); }
virtual size_t GetCapacity() const override { return cache_->GetCapacity(); } size_t GetCapacity() const override { return cache_->GetCapacity(); }
virtual bool HasStrictCapacityLimit() const override { bool HasStrictCapacityLimit() const override {
return cache_->HasStrictCapacityLimit(); return cache_->HasStrictCapacityLimit();
} }
virtual size_t GetUsage() const override { return cache_->GetUsage(); } size_t GetUsage() const override { return cache_->GetUsage(); }
virtual size_t GetUsage(Handle* handle) const override { size_t GetUsage(Handle* handle) const override {
return cache_->GetUsage(handle); return cache_->GetUsage(handle);
} }
virtual size_t GetPinnedUsage() const override { size_t GetPinnedUsage() const override { return cache_->GetPinnedUsage(); }
return cache_->GetPinnedUsage();
}
virtual void DisownData() override { void DisownData() override {
cache_->DisownData(); cache_->DisownData();
key_only_cache_->DisownData(); key_only_cache_->DisownData();
} }
virtual void ApplyToAllCacheEntries(void (*callback)(void*, size_t), void ApplyToAllCacheEntries(void (*callback)(void*, size_t),
bool thread_safe) override { bool thread_safe) override {
// only apply to _cache since key_only_cache doesn't hold value // only apply to _cache since key_only_cache doesn't hold value
cache_->ApplyToAllCacheEntries(callback, thread_safe); cache_->ApplyToAllCacheEntries(callback, thread_safe);
} }
virtual void EraseUnRefEntries() override { void EraseUnRefEntries() override {
cache_->EraseUnRefEntries(); cache_->EraseUnRefEntries();
key_only_cache_->EraseUnRefEntries(); key_only_cache_->EraseUnRefEntries();
} }
virtual size_t GetSimCapacity() const override { size_t GetSimCapacity() const override {
return key_only_cache_->GetCapacity(); return key_only_cache_->GetCapacity();
} }
virtual size_t GetSimUsage() const override { size_t GetSimUsage() const override { return key_only_cache_->GetUsage(); }
return key_only_cache_->GetUsage(); void SetSimCapacity(size_t capacity) override {
}
virtual void SetSimCapacity(size_t capacity) override {
key_only_cache_->SetCapacity(capacity); key_only_cache_->SetCapacity(capacity);
} }
virtual uint64_t get_miss_counter() const override { uint64_t get_miss_counter() const override {
return miss_times_.load(std::memory_order_relaxed); return miss_times_.load(std::memory_order_relaxed);
} }
virtual uint64_t get_hit_counter() const override { uint64_t get_hit_counter() const override {
return hit_times_.load(std::memory_order_relaxed); return hit_times_.load(std::memory_order_relaxed);
} }
virtual void reset_counter() override { void reset_counter() override {
miss_times_.store(0, std::memory_order_relaxed); miss_times_.store(0, std::memory_order_relaxed);
hit_times_.store(0, std::memory_order_relaxed); hit_times_.store(0, std::memory_order_relaxed);
SetTickerCount(stats_, SIM_BLOCK_CACHE_HIT, 0); SetTickerCount(stats_, SIM_BLOCK_CACHE_HIT, 0);
SetTickerCount(stats_, SIM_BLOCK_CACHE_MISS, 0); SetTickerCount(stats_, SIM_BLOCK_CACHE_MISS, 0);
} }
virtual std::string ToString() const override { std::string ToString() const override {
std::string res; std::string res;
res.append("SimCache MISSes: " + std::to_string(get_miss_counter()) + "\n"); res.append("SimCache MISSes: " + std::to_string(get_miss_counter()) + "\n");
res.append("SimCache HITs: " + std::to_string(get_hit_counter()) + "\n"); res.append("SimCache HITs: " + std::to_string(get_hit_counter()) + "\n");
@ -291,7 +285,7 @@ class SimCacheImpl : public SimCache {
return res; return res;
} }
virtual std::string GetPrintableOptions() const override { std::string GetPrintableOptions() const override {
std::string ret; std::string ret;
ret.reserve(20000); ret.reserve(20000);
ret.append(" cache_options:\n"); ret.append(" cache_options:\n");
@ -301,18 +295,15 @@ class SimCacheImpl : public SimCache {
return ret; return ret;
} }
virtual Status StartActivityLogging(const std::string& activity_log_file, Status StartActivityLogging(const std::string& activity_log_file, Env* env,
Env* env, uint64_t max_logging_size = 0) override {
uint64_t max_logging_size = 0) override {
return cache_activity_logger_.StartLogging(activity_log_file, env, return cache_activity_logger_.StartLogging(activity_log_file, env,
max_logging_size); max_logging_size);
} }
virtual void StopActivityLogging() override { void StopActivityLogging() override { cache_activity_logger_.StopLogging(); }
cache_activity_logger_.StopLogging();
}
virtual Status GetActivityLoggingStatus() override { Status GetActivityLoggingStatus() override {
return cache_activity_logger_.bg_status(); return cache_activity_logger_.bg_status();
} }

@ -37,7 +37,7 @@ class OptimisticTransactionTest : public testing::Test {
DestroyDB(dbname, options); DestroyDB(dbname, options);
Open(); Open();
} }
~OptimisticTransactionTest() { ~OptimisticTransactionTest() override {
delete txn_db; delete txn_db;
DestroyDB(dbname, options); DestroyDB(dbname, options);
} }

@ -459,18 +459,17 @@ Status PessimisticTransaction::LockBatch(WriteBatch* batch,
} }
} }
virtual Status PutCF(uint32_t column_family_id, const Slice& key, Status PutCF(uint32_t column_family_id, const Slice& key,
const Slice& /* unused */) override { const Slice& /* unused */) override {
RecordKey(column_family_id, key); RecordKey(column_family_id, key);
return Status::OK(); return Status::OK();
} }
virtual Status MergeCF(uint32_t column_family_id, const Slice& key, Status MergeCF(uint32_t column_family_id, const Slice& key,
const Slice& /* unused */) override { const Slice& /* unused */) override {
RecordKey(column_family_id, key); RecordKey(column_family_id, key);
return Status::OK(); return Status::OK();
} }
virtual Status DeleteCF(uint32_t column_family_id, Status DeleteCF(uint32_t column_family_id, const Slice& key) override {
const Slice& key) override {
RecordKey(column_family_id, key); RecordKey(column_family_id, key);
return Status::OK(); return Status::OK();
} }

@ -19,7 +19,7 @@ namespace rocksdb {
class TransactionDBMutexImpl : public TransactionDBMutex { class TransactionDBMutexImpl : public TransactionDBMutex {
public: public:
TransactionDBMutexImpl() {} TransactionDBMutexImpl() {}
~TransactionDBMutexImpl() {} ~TransactionDBMutexImpl() override {}
Status Lock() override; Status Lock() override;
@ -36,7 +36,7 @@ class TransactionDBMutexImpl : public TransactionDBMutex {
class TransactionDBCondVarImpl : public TransactionDBCondVar { class TransactionDBCondVarImpl : public TransactionDBCondVar {
public: public:
TransactionDBCondVarImpl() {} TransactionDBCondVarImpl() {}
~TransactionDBCondVarImpl() {} ~TransactionDBCondVarImpl() override {}
Status Wait(std::shared_ptr<TransactionDBMutex> mutex) override; Status Wait(std::shared_ptr<TransactionDBMutex> mutex) override;

@ -4791,7 +4791,7 @@ TEST_P(TransactionTest, SetSnapshotOnNextOperationWithNotification) {
explicit Notifier(const Snapshot** snapshot_ptr) explicit Notifier(const Snapshot** snapshot_ptr)
: snapshot_ptr_(snapshot_ptr) {} : snapshot_ptr_(snapshot_ptr) {}
void SnapshotCreated(const Snapshot* newSnapshot) { void SnapshotCreated(const Snapshot* newSnapshot) override {
*snapshot_ptr_ = newSnapshot; *snapshot_ptr_ = newSnapshot;
} }
}; };
@ -5266,15 +5266,13 @@ TEST_P(TransactionTest, Optimizations) {
class ThreeBytewiseComparator : public Comparator { class ThreeBytewiseComparator : public Comparator {
public: public:
ThreeBytewiseComparator() {} ThreeBytewiseComparator() {}
virtual const char* Name() const override { const char* Name() const override { return "test.ThreeBytewiseComparator"; }
return "test.ThreeBytewiseComparator"; int Compare(const Slice& a, const Slice& b) const override {
}
virtual int Compare(const Slice& a, const Slice& b) const override {
Slice na = Slice(a.data(), a.size() < 3 ? a.size() : 3); Slice na = Slice(a.data(), a.size() < 3 ? a.size() : 3);
Slice nb = Slice(b.data(), b.size() < 3 ? b.size() : 3); Slice nb = Slice(b.data(), b.size() < 3 ? b.size() : 3);
return na.compare(nb); return na.compare(nb);
} }
virtual bool Equal(const Slice& a, const Slice& b) const override { bool Equal(const Slice& a, const Slice& b) const override {
Slice na = Slice(a.data(), a.size() < 3 ? a.size() : 3); Slice na = Slice(a.data(), a.size() < 3 ? a.size() : 3);
Slice nb = Slice(b.data(), b.size() < 3 ? b.size() : 3); Slice nb = Slice(b.data(), b.size() < 3 ? b.size() : 3);
return na == nb; return na == nb;

@ -330,7 +330,7 @@ class WritePreparedTxnDBMock : public WritePreparedTxnDB {
void TakeSnapshot(SequenceNumber seq) { snapshots_.push_back(seq); } void TakeSnapshot(SequenceNumber seq) { snapshots_.push_back(seq); }
protected: protected:
virtual const std::vector<SequenceNumber> GetSnapshotListFromDB( const std::vector<SequenceNumber> GetSnapshotListFromDB(
SequenceNumber /* unused */) override { SequenceNumber /* unused */) override {
return snapshots_; return snapshots_;
} }

@ -185,7 +185,7 @@ Status WritePreparedTxn::CommitInternal() {
public: public:
explicit PublishSeqPreReleaseCallback(DBImpl* db_impl) explicit PublishSeqPreReleaseCallback(DBImpl* db_impl)
: db_impl_(db_impl) {} : db_impl_(db_impl) {}
virtual Status Callback(SequenceNumber seq, bool is_mem_disabled) override { Status Callback(SequenceNumber seq, bool is_mem_disabled) override {
#ifdef NDEBUG #ifdef NDEBUG
(void)is_mem_disabled; (void)is_mem_disabled;
#endif #endif
@ -311,7 +311,7 @@ Status WritePreparedTxn::RollbackInternal() {
} }
protected: protected:
virtual bool WriteAfterCommit() const override { return false; } bool WriteAfterCommit() const override { return false; }
} rollback_handler(db_impl_, wpt_db_, read_at_seq, &rollback_batch, } rollback_handler(db_impl_, wpt_db_, read_at_seq, &rollback_batch,
*cf_comp_map_shared_ptr.get(), *cf_map_shared_ptr.get(), *cf_comp_map_shared_ptr.get(), *cf_map_shared_ptr.get(),
wpt_db_->txn_db_options_.rollback_merge_operands); wpt_db_->txn_db_options_.rollback_merge_operands);

@ -64,8 +64,7 @@ Status WritePreparedTxnDB::Initialize(
public: public:
explicit CommitSubBatchPreReleaseCallback(WritePreparedTxnDB* db) explicit CommitSubBatchPreReleaseCallback(WritePreparedTxnDB* db)
: db_(db) {} : db_(db) {}
virtual Status Callback(SequenceNumber commit_seq, Status Callback(SequenceNumber commit_seq, bool is_mem_disabled) override {
bool is_mem_disabled) override {
#ifdef NDEBUG #ifdef NDEBUG
(void)is_mem_disabled; (void)is_mem_disabled;
#endif #endif

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

Loading…
Cancel
Save