rocksdb: Add missing override

Summary:
When using latest clang (3.6 or 3.7/trunck) rocksdb is failing with many errors. Almost all of them are missing override errors. This diff adds missing override keyword. No manual changes.

Prerequisites: bear and clang 3.5 build with extra tools

```lang=bash
% USE_CLANG=1 bear make all # generate a compilation database http://clang.llvm.org/docs/JSONCompilationDatabase.html
% clang-modernize -p . -include . -add-override
% make format
```

Test Plan:
Make sure all tests are passing.
```lang=bash
% #Use default fb code clang.
% make check
```
Verify less error and no missing override errors.
```lang=bash
% # Have trunk clang present in path.
% ROCKSDB_NO_FBCODE=1 CC=clang CXX=clang++ make
```

Reviewers: igor, kradhakrishnan, rven, meyering, sdong

Reviewed By: sdong

Subscribers: dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D34077
main
Igor Sugak 10 years ago
parent 1e06a40685
commit 62247ffa3b
  1. 106
      db/c.cc
  2. 2
      db/column_family.h
  3. 6
      db/column_family_test.cc
  4. 2
      db/compaction_picker.h
  5. 44
      db/comparator_db_test.cc
  6. 20
      db/db_bench.cc
  7. 2
      db/db_impl.cc
  8. 89
      db/db_impl.h
  9. 18
      db/db_iter.cc
  10. 191
      db/db_test.cc
  11. 19
      db/dbformat.h
  12. 15
      db/fault_injection_test.cc
  13. 11
      db/file_indexer_test.cc
  14. 2
      db/forward_iterator.cc
  15. 2
      db/forward_iterator.h
  16. 14
      db/log_test.cc
  17. 18
      db/memtable.cc
  18. 2
      db/memtable.h
  19. 3
      db/merge_test.cc
  20. 11
      db/prefix_test.cc
  21. 2
      db/repair.cc
  22. 2
      db/snapshot.h
  23. 4
      db/table_properties_collector.h
  24. 26
      db/table_properties_collector_test.cc
  25. 20
      db/transaction_log_impl.h
  26. 21
      db/version_set.cc
  27. 2
      db/version_set.h
  28. 2
      db/wal_manager.cc
  29. 7
      db/write_batch.cc
  30. 18
      db/write_batch_test.cc
  31. 85
      hdfs/env_hdfs.h
  32. 79
      include/rocksdb/env.h
  33. 13
      include/rocksdb/utilities/stackable_db.h
  34. 10
      table/block_based_filter_block_test.cc
  35. 8
      table/block_based_table_builder.cc
  36. 18
      table/block_hash_index_test.cc
  37. 10
      table/full_filter_block_test.cc
  38. 25
      table/iterator.cc
  39. 20
      table/merger.cc
  40. 18
      table/merger_test.cc
  41. 27
      table/mock_table.h
  42. 18
      table/plain_table_reader.cc
  43. 8
      table/plain_table_reader.h
  44. 71
      table/table_test.cc
  45. 22
      table/two_level_iterator.cc
  46. 45
      tools/db_sanity_test.cc
  47. 8
      util/auto_roll_logger.h
  48. 23
      util/cache.cc
  49. 15
      util/comparator.cc
  50. 143
      util/env_posix.cc
  51. 64
      util/hash_linklist_rep.cc
  52. 38
      util/hash_skiplist_rep.cc
  53. 8
      util/ldb_cmd.cc
  54. 64
      util/ldb_cmd.h
  55. 8
      util/manual_compaction_test.cc
  56. 50
      util/memenv.cc
  57. 34
      util/mock_env.cc
  58. 40
      util/mock_env.h
  59. 8
      util/posix_logger.h
  60. 38
      util/slice.cc
  61. 12
      util/testutil.h
  62. 39
      utilities/backupable/backupable_db.cc
  63. 19
      utilities/backupable/backupable_db_test.cc
  64. 2
      utilities/checkpoint/checkpoint.cc
  65. 25
      utilities/document/document_db.cc
  66. 16
      utilities/geodb/geodb_impl.h
  67. 2
      utilities/redis/redis_list_exception.h
  68. 11
      utilities/ttl/db_ttl_impl.cc
  69. 22
      utilities/ttl/db_ttl_impl.h
  70. 2
      utilities/ttl/ttl_test.cc
  71. 6
      utilities/write_batch_with_index/write_batch_with_index.cc

@ -125,12 +125,9 @@ struct rocksdb_compactionfilter_t : public CompactionFilter {
(*destructor_)(state_); (*destructor_)(state_);
} }
virtual bool Filter( virtual bool Filter(int level, const Slice& key, const Slice& existing_value,
int level, std::string* new_value,
const Slice& key, bool* value_changed) const override {
const Slice& existing_value,
std::string* new_value,
bool* value_changed) const {
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;
@ -147,9 +144,7 @@ struct rocksdb_compactionfilter_t : public CompactionFilter {
return result; return result;
} }
virtual const char* Name() const { virtual const char* Name() const override { return (*name_)(state_); }
return (*name_)(state_);
}
}; };
struct rocksdb_compactionfilterfactory_t : public CompactionFilterFactory { struct rocksdb_compactionfilterfactory_t : public CompactionFilterFactory {
@ -162,14 +157,14 @@ struct rocksdb_compactionfilterfactory_t : public CompactionFilterFactory {
virtual ~rocksdb_compactionfilterfactory_t() { (*destructor_)(state_); } virtual ~rocksdb_compactionfilterfactory_t() { (*destructor_)(state_); }
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter( virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& context) { const CompactionFilter::Context& context) override {
rocksdb_compactionfiltercontext_t ccontext; rocksdb_compactionfiltercontext_t ccontext;
ccontext.rep = context; ccontext.rep = context;
CompactionFilter* cf = (*create_compaction_filter_)(state_, &ccontext); CompactionFilter* cf = (*create_compaction_filter_)(state_, &ccontext);
return std::unique_ptr<CompactionFilter>(cf); return std::unique_ptr<CompactionFilter>(cf);
} }
virtual const char* Name() const { return (*name_)(state_); } virtual const char* Name() const override { return (*name_)(state_); }
}; };
struct rocksdb_compactionfilterv2_t : public CompactionFilterV2 { struct rocksdb_compactionfilterv2_t : public CompactionFilterV2 {
@ -186,15 +181,12 @@ struct rocksdb_compactionfilterv2_t : public CompactionFilterV2 {
(*destructor_)(state_); (*destructor_)(state_);
} }
virtual const char* Name() const { virtual const char* Name() const override { return (*name_)(state_); }
return (*name_)(state_);
}
virtual std::vector<bool> Filter(int level, virtual std::vector<bool> Filter(
const SliceVector& keys, int level, const SliceVector& keys, const SliceVector& existing_values,
const SliceVector& existing_values, std::vector<std::string>* new_values,
std::vector<std::string>* new_values, std::vector<bool>* values_changed) const override {
std::vector<bool>* values_changed) const {
// Make a vector pointing to the underlying key data. // Make a vector pointing to the underlying key data.
size_t num_keys = keys.size(); size_t num_keys = keys.size();
std::vector<const char*> keys_list(num_keys); std::vector<const char*> keys_list(num_keys);
@ -256,12 +248,10 @@ struct rocksdb_compactionfilterfactoryv2_t : public CompactionFilterFactoryV2 {
(*destructor_)(state_); (*destructor_)(state_);
} }
virtual const char* Name() const { virtual const char* Name() const override { return (*name_)(state_); }
return (*name_)(state_);
}
virtual std::unique_ptr<CompactionFilterV2> CreateCompactionFilterV2( virtual std::unique_ptr<CompactionFilterV2> CreateCompactionFilterV2(
const CompactionFilterContext& context) { const CompactionFilterContext& context) override {
struct rocksdb_compactionfiltercontext_t c_context; struct rocksdb_compactionfiltercontext_t c_context;
c_context.rep.is_full_compaction = context.is_full_compaction; c_context.rep.is_full_compaction = context.is_full_compaction;
c_context.rep.is_manual_compaction = context.is_manual_compaction; c_context.rep.is_manual_compaction = context.is_manual_compaction;
@ -283,17 +273,16 @@ struct rocksdb_comparator_t : public Comparator {
(*destructor_)(state_); (*destructor_)(state_);
} }
virtual int Compare(const Slice& a, const Slice& b) const { virtual 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 { virtual const char* Name() const override { return (*name_)(state_); }
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*, const Slice&) const { } virtual void FindShortestSeparator(std::string*,
virtual void FindShortSuccessor(std::string* key) const { } const Slice&) const override {}
virtual void FindShortSuccessor(std::string* key) const override {}
}; };
struct rocksdb_filterpolicy_t : public FilterPolicy { struct rocksdb_filterpolicy_t : public FilterPolicy {
@ -317,11 +306,10 @@ struct rocksdb_filterpolicy_t : public FilterPolicy {
(*destructor_)(state_); (*destructor_)(state_);
} }
virtual const char* Name() const { virtual const char* Name() const override { return (*name_)(state_); }
return (*name_)(state_);
}
virtual void CreateFilter(const Slice* keys, int n, std::string* dst) const { virtual void CreateFilter(const Slice* keys, int n,
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++) {
@ -339,7 +327,8 @@ struct rocksdb_filterpolicy_t : public FilterPolicy {
} }
} }
virtual bool KeyMayMatch(const Slice& key, const Slice& filter) const { virtual bool KeyMayMatch(const Slice& key,
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());
} }
@ -368,17 +357,12 @@ struct rocksdb_mergeoperator_t : public MergeOperator {
(*destructor_)(state_); (*destructor_)(state_);
} }
virtual const char* Name() const { virtual const char* Name() const override { return (*name_)(state_); }
return (*name_)(state_);
}
virtual bool FullMerge(
const Slice& key,
const Slice* existing_value,
const std::deque<std::string>& operand_list,
std::string* new_value,
Logger* logger) const {
virtual bool FullMerge(const Slice& key, const Slice* existing_value,
const std::deque<std::string>& operand_list,
std::string* new_value,
Logger* logger) const override {
size_t n = operand_list.size(); size_t n = 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);
@ -414,7 +398,8 @@ struct rocksdb_mergeoperator_t : public MergeOperator {
virtual bool PartialMergeMulti(const Slice& key, virtual bool PartialMergeMulti(const Slice& key,
const std::deque<Slice>& operand_list, const std::deque<Slice>& operand_list,
std::string* new_value, Logger* logger) const { std::string* new_value,
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);
@ -465,21 +450,19 @@ struct rocksdb_slicetransform_t : public SliceTransform {
(*destructor_)(state_); (*destructor_)(state_);
} }
virtual const char* Name() const { virtual const char* Name() const override { return (*name_)(state_); }
return (*name_)(state_);
}
virtual Slice Transform(const Slice& src) const { virtual 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 { virtual 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 { virtual bool InRange(const Slice& src) const override {
return (*in_range_)(state_, src.data(), src.size()); return (*in_range_)(state_, src.data(), src.size());
} }
}; };
@ -1126,10 +1109,10 @@ void rocksdb_writebatch_iterate(
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) { virtual 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) { virtual void Delete(const Slice& key) override {
(*deleted_)(state_, key.data(), key.size()); (*deleted_)(state_, key.data(), key.size());
} }
}; };
@ -1913,11 +1896,12 @@ rocksdb_filterpolicy_t* rocksdb_filterpolicy_create_bloom(int bits_per_key) {
struct Wrapper : public rocksdb_filterpolicy_t { struct Wrapper : public rocksdb_filterpolicy_t {
const FilterPolicy* rep_; const FilterPolicy* rep_;
~Wrapper() { delete rep_; } ~Wrapper() { delete rep_; }
const char* Name() const { return rep_->Name(); } const char* Name() const override { return rep_->Name(); }
void CreateFilter(const Slice* keys, int n, std::string* dst) const { void CreateFilter(const Slice* keys, int n,
std::string* dst) const override {
return rep_->CreateFilter(keys, n, dst); return rep_->CreateFilter(keys, n, dst);
} }
bool KeyMayMatch(const Slice& key, const Slice& filter) const { bool KeyMayMatch(const Slice& key, const Slice& filter) const override {
return rep_->KeyMayMatch(key, filter); return rep_->KeyMayMatch(key, filter);
} }
static void DoNothing(void*) { } static void DoNothing(void*) { }
@ -2099,16 +2083,14 @@ rocksdb_slicetransform_t* rocksdb_slicetransform_create_fixed_prefix(size_t pref
struct Wrapper : public rocksdb_slicetransform_t { struct Wrapper : public rocksdb_slicetransform_t {
const SliceTransform* rep_; const SliceTransform* rep_;
~Wrapper() { delete rep_; } ~Wrapper() { delete rep_; }
const char* Name() const { return rep_->Name(); } const char* Name() const override { return rep_->Name(); }
Slice Transform(const Slice& src) const { Slice Transform(const Slice& src) const override {
return rep_->Transform(src); return rep_->Transform(src);
} }
bool InDomain(const Slice& src) const { bool InDomain(const Slice& src) const override {
return rep_->InDomain(src); return rep_->InDomain(src);
} }
bool InRange(const Slice& src) const { bool InRange(const Slice& src) const override { return rep_->InRange(src); }
return rep_->InRange(src);
}
static void DoNothing(void*) { } static void DoNothing(void*) { }
}; };
Wrapper* wrapper = new Wrapper; Wrapper* wrapper = new Wrapper;

@ -55,7 +55,7 @@ class ColumnFamilyHandleImpl : public ColumnFamilyHandle {
virtual ColumnFamilyData* cfd() const { return cfd_; } virtual ColumnFamilyData* cfd() const { return cfd_; }
virtual const Comparator* user_comparator() const; virtual const Comparator* user_comparator() const;
virtual uint32_t GetID() const; virtual uint32_t GetID() const override;
virtual const std::string& GetName() const override; virtual const std::string& GetName() const override;
private: private:

@ -38,7 +38,7 @@ class EnvCounter : public EnvWrapper {
return num_new_writable_file_; return num_new_writable_file_;
} }
Status NewWritableFile(const std::string& f, unique_ptr<WritableFile>* r, Status NewWritableFile(const std::string& f, unique_ptr<WritableFile>* r,
const EnvOptions& soptions) { const EnvOptions& soptions) override {
++num_new_writable_file_; ++num_new_writable_file_;
return EnvWrapper::NewWritableFile(f, r, soptions); return EnvWrapper::NewWritableFile(f, r, soptions);
} }
@ -329,8 +329,8 @@ class ColumnFamilyTest {
class DumbLogger : public Logger { class DumbLogger : public Logger {
public: public:
using Logger::Logv; using Logger::Logv;
virtual void Logv(const char* format, va_list ap) {} virtual void Logv(const char* format, va_list ap) override {}
virtual size_t GetLogFileSize() const { return 0; } virtual size_t GetLogFileSize() const override { return 0; }
}; };
TEST(ColumnFamilyTest, DontReuseColumnFamilyID) { TEST(ColumnFamilyTest, DontReuseColumnFamilyID) {

@ -298,7 +298,7 @@ class NullCompactionPicker : public CompactionPicker {
// Given the current number of levels, returns the highest allowed level // Given the current number of levels, returns the highest allowed level
// for compaction input. // for compaction input.
virtual int MaxInputLevel(int current_num_levels) const { virtual int MaxInputLevel(int current_num_levels) const override {
return current_num_levels - 2; return current_num_levels - 2;
} }

@ -33,18 +33,20 @@ typedef std::map<std::string, std::string, MapComparator> KVMap;
class KVIter : public Iterator { class KVIter : public Iterator {
public: public:
explicit KVIter(const KVMap* map) : map_(map), iter_(map_->end()) {} explicit KVIter(const KVMap* map) : map_(map), iter_(map_->end()) {}
virtual bool Valid() const { return iter_ != map_->end(); } virtual bool Valid() const override { return iter_ != map_->end(); }
virtual void SeekToFirst() { iter_ = map_->begin(); } virtual void SeekToFirst() override { iter_ = map_->begin(); }
virtual void SeekToLast() { virtual 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) { iter_ = map_->lower_bound(k.ToString()); } virtual void Seek(const Slice& k) override {
virtual void Next() { ++iter_; } iter_ = map_->lower_bound(k.ToString());
virtual void Prev() { }
virtual void Next() override { ++iter_; }
virtual void Prev() override {
if (iter_ == map_->begin()) { if (iter_ == map_->begin()) {
iter_ = map_->end(); iter_ = map_->end();
return; return;
@ -52,9 +54,9 @@ class KVIter : public Iterator {
--iter_; --iter_;
} }
virtual Slice key() const { return iter_->first; } virtual Slice key() const override { return iter_->first; }
virtual Slice value() const { return iter_->second; } virtual Slice value() const override { return iter_->second; }
virtual Status status() const { return Status::OK(); } virtual Status status() const override { return Status::OK(); }
private: private:
const KVMap* const map_; const KVMap* const map_;
@ -171,9 +173,9 @@ class DoubleComparator : public Comparator {
public: public:
DoubleComparator() {} DoubleComparator() {}
virtual const char* Name() const { return "DoubleComparator"; } virtual const char* Name() const override { return "DoubleComparator"; }
virtual int Compare(const Slice& a, const Slice& b) const { virtual int Compare(const Slice& a, const Slice& b) const override {
double da = std::stod(a.ToString()); double da = std::stod(a.ToString());
double db = std::stod(b.ToString()); double db = std::stod(b.ToString());
if (da == db) { if (da == db) {
@ -185,18 +187,18 @@ class DoubleComparator : public Comparator {
} }
} }
virtual void FindShortestSeparator(std::string* start, virtual void FindShortestSeparator(std::string* start,
const Slice& limit) const {} const Slice& limit) const override {}
virtual void FindShortSuccessor(std::string* key) const {} virtual void FindShortSuccessor(std::string* key) const override {}
}; };
class HashComparator : public Comparator { class HashComparator : public Comparator {
public: public:
HashComparator() {} HashComparator() {}
virtual const char* Name() const { return "HashComparator"; } virtual const char* Name() const override { return "HashComparator"; }
virtual int Compare(const Slice& a, const Slice& b) const { virtual 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) {
@ -208,18 +210,18 @@ class HashComparator : public Comparator {
} }
} }
virtual void FindShortestSeparator(std::string* start, virtual void FindShortestSeparator(std::string* start,
const Slice& limit) const {} const Slice& limit) const override {}
virtual void FindShortSuccessor(std::string* key) const {} virtual void FindShortSuccessor(std::string* key) const override {}
}; };
class TwoStrComparator : public Comparator { class TwoStrComparator : public Comparator {
public: public:
TwoStrComparator() {} TwoStrComparator() {}
virtual const char* Name() const { return "TwoStrComparator"; } virtual const char* Name() const override { return "TwoStrComparator"; }
virtual int Compare(const Slice& a, const Slice& b) const { virtual 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]);
@ -240,9 +242,9 @@ class TwoStrComparator : public Comparator {
return a2.compare(b2); return a2.compare(b2);
} }
virtual void FindShortestSeparator(std::string* start, virtual void FindShortestSeparator(std::string* start,
const Slice& limit) const {} const Slice& limit) const override {}
virtual void FindShortSuccessor(std::string* key) const {} virtual void FindShortSuccessor(std::string* key) const override {}
}; };
} // namespace } // namespace

@ -653,7 +653,7 @@ class ReportFileOpEnv : public EnvWrapper {
} }
Status NewSequentialFile(const std::string& f, unique_ptr<SequentialFile>* r, Status NewSequentialFile(const std::string& f, unique_ptr<SequentialFile>* r,
const EnvOptions& soptions) { const EnvOptions& soptions) override {
class CountingFile : public SequentialFile { class CountingFile : public SequentialFile {
private: private:
unique_ptr<SequentialFile> target_; unique_ptr<SequentialFile> target_;
@ -664,7 +664,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) { virtual 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(),
@ -672,7 +672,7 @@ class ReportFileOpEnv : public EnvWrapper {
return rv; return rv;
} }
virtual Status Skip(uint64_t n) { return target_->Skip(n); } virtual Status Skip(uint64_t n) override { return target_->Skip(n); }
}; };
Status s = target()->NewSequentialFile(f, r, soptions); Status s = target()->NewSequentialFile(f, r, soptions);
@ -685,7 +685,7 @@ class ReportFileOpEnv : public EnvWrapper {
Status NewRandomAccessFile(const std::string& f, Status NewRandomAccessFile(const std::string& f,
unique_ptr<RandomAccessFile>* r, unique_ptr<RandomAccessFile>* r,
const EnvOptions& soptions) { const EnvOptions& soptions) override {
class CountingFile : public RandomAccessFile { class CountingFile : public RandomAccessFile {
private: private:
unique_ptr<RandomAccessFile> target_; unique_ptr<RandomAccessFile> target_;
@ -696,7 +696,7 @@ class ReportFileOpEnv : public EnvWrapper {
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, virtual Status Read(uint64_t offset, size_t n, Slice* result,
char* scratch) const { 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(),
@ -714,7 +714,7 @@ class ReportFileOpEnv : public EnvWrapper {
} }
Status NewWritableFile(const std::string& f, unique_ptr<WritableFile>* r, Status NewWritableFile(const std::string& f, unique_ptr<WritableFile>* r,
const EnvOptions& soptions) { const EnvOptions& soptions) override {
class CountingFile : public WritableFile { class CountingFile : public WritableFile {
private: private:
unique_ptr<WritableFile> target_; unique_ptr<WritableFile> target_;
@ -725,7 +725,7 @@ class ReportFileOpEnv : public EnvWrapper {
ReportFileOpCounters* counters) ReportFileOpCounters* counters)
: target_(std::move(target)), counters_(counters) {} : target_(std::move(target)), counters_(counters) {}
Status Append(const Slice& data) { Status Append(const Slice& data) override {
counters_->append_counter_.fetch_add(1, std::memory_order_relaxed); counters_->append_counter_.fetch_add(1, std::memory_order_relaxed);
Status rv = target_->Append(data); Status rv = target_->Append(data);
counters_->bytes_written_.fetch_add(data.size(), counters_->bytes_written_.fetch_add(data.size(),
@ -733,9 +733,9 @@ class ReportFileOpEnv : public EnvWrapper {
return rv; return rv;
} }
Status Close() { return target_->Close(); } Status Close() override { return target_->Close(); }
Status Flush() { return target_->Flush(); } Status Flush() override { return target_->Flush(); }
Status Sync() { return target_->Sync(); } Status Sync() override { return target_->Sync(); }
}; };
Status s = target()->NewWritableFile(f, r, soptions); Status s = target()->NewWritableFile(f, r, soptions);

@ -891,7 +891,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 db_options_.paranoid_checks==false Status* status; // nullptr if db_options_.paranoid_checks==false
virtual void Corruption(size_t bytes, const Status& s) { virtual void Corruption(size_t bytes, const Status& s) override {
Log(InfoLogLevel::WARN_LEVEL, Log(InfoLogLevel::WARN_LEVEL,
info_log, "%s%s: dropping %d bytes; %s", info_log, "%s%s: dropping %d bytes; %s",
(this->status == nullptr ? "(ignoring error) " : ""), (this->status == nullptr ? "(ignoring error) " : ""),

@ -62,30 +62,33 @@ class DBImpl : public DB {
using DB::Put; using DB::Put;
virtual Status Put(const WriteOptions& options, virtual Status Put(const WriteOptions& options,
ColumnFamilyHandle* column_family, const Slice& key, ColumnFamilyHandle* column_family, const Slice& key,
const Slice& value); const Slice& value) override;
using DB::Merge; using DB::Merge;
virtual Status Merge(const WriteOptions& options, virtual Status Merge(const WriteOptions& options,
ColumnFamilyHandle* column_family, const Slice& key, ColumnFamilyHandle* column_family, const Slice& key,
const Slice& value); const Slice& value) override;
using DB::Delete; using DB::Delete;
virtual Status Delete(const WriteOptions& options, virtual Status Delete(const WriteOptions& options,
ColumnFamilyHandle* column_family, const Slice& key); ColumnFamilyHandle* column_family,
const Slice& key) override;
using DB::Write; using DB::Write;
virtual Status Write(const WriteOptions& options, WriteBatch* updates); virtual Status Write(const WriteOptions& options,
WriteBatch* updates) override;
using DB::Get; using DB::Get;
virtual Status Get(const ReadOptions& options, virtual Status Get(const ReadOptions& options,
ColumnFamilyHandle* column_family, const Slice& key, ColumnFamilyHandle* column_family, const Slice& key,
std::string* value); std::string* value) override;
using DB::MultiGet; using DB::MultiGet;
virtual std::vector<Status> MultiGet( virtual 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, std::vector<std::string>* values); const std::vector<Slice>& keys,
std::vector<std::string>* values) override;
virtual Status CreateColumnFamily(const ColumnFamilyOptions& options, virtual Status CreateColumnFamily(const ColumnFamilyOptions& options,
const std::string& column_family, const std::string& column_family,
ColumnFamilyHandle** handle); ColumnFamilyHandle** handle) override;
virtual Status DropColumnFamily(ColumnFamilyHandle* column_family); virtual Status DropColumnFamily(ColumnFamilyHandle* column_family) override;
// Returns false if key doesn't exist in the database and true if it may. // Returns false if key doesn't exist in the database and true if it may.
// If value_found is not passed in as null, then return the value if found in // If value_found is not passed in as null, then return the value if found in
@ -94,75 +97,81 @@ class DBImpl : public DB {
using DB::KeyMayExist; using DB::KeyMayExist;
virtual bool KeyMayExist(const ReadOptions& options, virtual bool KeyMayExist(const ReadOptions& options,
ColumnFamilyHandle* column_family, const Slice& key, ColumnFamilyHandle* column_family, const Slice& key,
std::string* value, bool* value_found = nullptr); std::string* value,
bool* value_found = nullptr) override;
using DB::NewIterator; using DB::NewIterator;
virtual Iterator* NewIterator(const ReadOptions& options, virtual Iterator* NewIterator(const ReadOptions& options,
ColumnFamilyHandle* column_family); ColumnFamilyHandle* column_family) override;
virtual Status NewIterators( virtual Status NewIterators(
const ReadOptions& options, const ReadOptions& options,
const std::vector<ColumnFamilyHandle*>& column_families, const std::vector<ColumnFamilyHandle*>& column_families,
std::vector<Iterator*>* iterators); std::vector<Iterator*>* iterators) override;
virtual const Snapshot* GetSnapshot(); virtual const Snapshot* GetSnapshot() override;
virtual void ReleaseSnapshot(const Snapshot* snapshot); virtual void ReleaseSnapshot(const Snapshot* snapshot) override;
using DB::GetProperty; using DB::GetProperty;
virtual bool GetProperty(ColumnFamilyHandle* column_family, virtual bool GetProperty(ColumnFamilyHandle* column_family,
const Slice& property, std::string* value); const Slice& property, std::string* value) override;
using DB::GetIntProperty; using DB::GetIntProperty;
virtual bool GetIntProperty(ColumnFamilyHandle* column_family, virtual bool GetIntProperty(ColumnFamilyHandle* column_family,
const Slice& property, uint64_t* value) override; const Slice& property, uint64_t* value) override;
using DB::GetApproximateSizes; using DB::GetApproximateSizes;
virtual void GetApproximateSizes(ColumnFamilyHandle* column_family, virtual void GetApproximateSizes(ColumnFamilyHandle* column_family,
const Range* range, int n, uint64_t* sizes); const Range* range, int n,
uint64_t* sizes) override;
using DB::CompactRange; using DB::CompactRange;
virtual Status CompactRange(ColumnFamilyHandle* column_family, virtual Status CompactRange(ColumnFamilyHandle* column_family,
const Slice* begin, const Slice* end, const Slice* begin, const Slice* end,
bool reduce_level = false, int target_level = -1, bool reduce_level = false, int target_level = -1,
uint32_t target_path_id = 0); uint32_t target_path_id = 0) override;
using DB::CompactFiles; using DB::CompactFiles;
virtual Status CompactFiles( virtual 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, const int output_level,
const int output_level, const int output_path_id = -1); const int output_path_id = -1) override;
using DB::SetOptions; using DB::SetOptions;
Status SetOptions(ColumnFamilyHandle* column_family, Status SetOptions(
const std::unordered_map<std::string, std::string>& options_map); ColumnFamilyHandle* column_family,
const std::unordered_map<std::string, std::string>& options_map) override;
using DB::NumberLevels; using DB::NumberLevels;
virtual int NumberLevels(ColumnFamilyHandle* column_family); virtual int NumberLevels(ColumnFamilyHandle* column_family) override;
using DB::MaxMemCompactionLevel; using DB::MaxMemCompactionLevel;
virtual int MaxMemCompactionLevel(ColumnFamilyHandle* column_family); virtual int MaxMemCompactionLevel(ColumnFamilyHandle* column_family) override;
using DB::Level0StopWriteTrigger; using DB::Level0StopWriteTrigger;
virtual int Level0StopWriteTrigger(ColumnFamilyHandle* column_family); virtual int Level0StopWriteTrigger(
virtual const std::string& GetName() const; ColumnFamilyHandle* column_family) override;
virtual Env* GetEnv() const; virtual const std::string& GetName() const override;
virtual Env* GetEnv() const override;
using DB::GetOptions; using DB::GetOptions;
virtual const Options& GetOptions(ColumnFamilyHandle* column_family) const; virtual const Options& GetOptions(
ColumnFamilyHandle* column_family) const override;
using DB::Flush; using DB::Flush;
virtual Status Flush(const FlushOptions& options, virtual Status Flush(const FlushOptions& options,
ColumnFamilyHandle* column_family); ColumnFamilyHandle* column_family) override;
virtual SequenceNumber GetLatestSequenceNumber() const; virtual SequenceNumber GetLatestSequenceNumber() const override;
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
virtual Status DisableFileDeletions(); virtual Status DisableFileDeletions() override;
virtual Status EnableFileDeletions(bool force); virtual Status EnableFileDeletions(bool force) override;
virtual int IsFileDeletionsEnabled() const; virtual int IsFileDeletionsEnabled() const;
// All the returned filenames start with "/" // All the returned filenames start with "/"
virtual Status GetLiveFiles(std::vector<std::string>&, virtual Status GetLiveFiles(std::vector<std::string>&,
uint64_t* manifest_file_size, uint64_t* manifest_file_size,
bool flush_memtable = true); bool flush_memtable = true) override;
virtual Status GetSortedWalFiles(VectorLogPtr& files); virtual Status GetSortedWalFiles(VectorLogPtr& files) override;
virtual Status GetUpdatesSince( virtual Status GetUpdatesSince(
SequenceNumber seq_number, unique_ptr<TransactionLogIterator>* iter, SequenceNumber seq_number, unique_ptr<TransactionLogIterator>* iter,
const TransactionLogIterator::ReadOptions& const TransactionLogIterator::ReadOptions&
read_options = TransactionLogIterator::ReadOptions()); read_options = TransactionLogIterator::ReadOptions()) override;
virtual Status DeleteFile(std::string name); virtual Status DeleteFile(std::string name) override;
virtual void GetLiveFilesMetaData(std::vector<LiveFileMetaData>* metadata); virtual void GetLiveFilesMetaData(
std::vector<LiveFileMetaData>* metadata) override;
// Obtains the meta data of the specified column family of the DB. // Obtains the meta data of the specified column family of the DB.
// Status::NotFound() will be returned if the current DB does not have // Status::NotFound() will be returned if the current DB does not have
@ -178,7 +187,7 @@ class DBImpl : public DB {
// match to our in-memory records // match to our in-memory records
virtual Status CheckConsistency(); virtual Status CheckConsistency();
virtual Status GetDbIdentity(std::string& identity); virtual Status GetDbIdentity(std::string& identity) override;
Status RunManualCompaction(ColumnFamilyData* cfd, int input_level, Status RunManualCompaction(ColumnFamilyData* cfd, int input_level,
int output_level, uint32_t output_path_id, int output_level, uint32_t output_path_id,
@ -252,7 +261,7 @@ class DBImpl : public DB {
// It is not necessary to hold the mutex when invoking this method. // It is not necessary to hold the mutex when invoking this method.
void PurgeObsoleteFiles(const JobContext& background_contet); void PurgeObsoleteFiles(const JobContext& background_contet);
ColumnFamilyHandle* DefaultColumnFamily() const; ColumnFamilyHandle* DefaultColumnFamily() const override;
const SnapshotList& snapshots() const { return snapshots_; } const SnapshotList& snapshots() const { return snapshots_; }

@ -90,17 +90,17 @@ class DBIter: public Iterator {
assert(iter_ == nullptr); assert(iter_ == nullptr);
iter_ = iter; iter_ = iter;
} }
virtual bool Valid() const { return valid_; } virtual bool Valid() const override { return valid_; }
virtual Slice key() const { virtual Slice key() const override {
assert(valid_); assert(valid_);
return saved_key_.GetKey(); return saved_key_.GetKey();
} }
virtual Slice value() const { virtual Slice value() const override {
assert(valid_); assert(valid_);
return (direction_ == kForward && !current_entry_is_merged_) ? return (direction_ == kForward && !current_entry_is_merged_) ?
iter_->value() : saved_value_; iter_->value() : saved_value_;
} }
virtual Status status() const { virtual Status status() const override {
if (status_.ok()) { if (status_.ok()) {
return iter_->status(); return iter_->status();
} else { } else {
@ -108,11 +108,11 @@ class DBIter: public Iterator {
} }
} }
virtual void Next(); virtual void Next() override;
virtual void Prev(); virtual void Prev() override;
virtual void Seek(const Slice& target); virtual void Seek(const Slice& target) override;
virtual void SeekToFirst(); virtual void SeekToFirst() override;
virtual void SeekToLast(); virtual void SeekToLast() override;
private: private:
void PrevInternal(); void PrevInternal();

@ -202,7 +202,7 @@ class SpecialEnv : public EnvWrapper {
} }
Status NewWritableFile(const std::string& f, unique_ptr<WritableFile>* r, Status NewWritableFile(const std::string& f, unique_ptr<WritableFile>* r,
const EnvOptions& soptions) { const EnvOptions& soptions) override {
class SSTableFile : public WritableFile { class SSTableFile : public WritableFile {
private: private:
SpecialEnv* env_; SpecialEnv* env_;
@ -213,7 +213,7 @@ class SpecialEnv : public EnvWrapper {
: env_(env), : env_(env),
base_(std::move(base)) { base_(std::move(base)) {
} }
Status Append(const Slice& data) { Status Append(const Slice& data) override {
if (env_->table_write_callback_) { if (env_->table_write_callback_) {
(*env_->table_write_callback_)(); (*env_->table_write_callback_)();
} }
@ -227,16 +227,16 @@ class SpecialEnv : public EnvWrapper {
return base_->Append(data); return base_->Append(data);
} }
} }
Status Close() { return base_->Close(); } Status Close() override { return base_->Close(); }
Status Flush() { return base_->Flush(); } Status Flush() override { return base_->Flush(); }
Status Sync() { Status Sync() override {
++env_->sync_counter_; ++env_->sync_counter_;
while (env_->delay_sstable_sync_.load(std::memory_order_acquire)) { while (env_->delay_sstable_sync_.load(std::memory_order_acquire)) {
env_->SleepForMicroseconds(100000); env_->SleepForMicroseconds(100000);
} }
return base_->Sync(); return base_->Sync();
} }
void SetIOPriority(Env::IOPriority pri) { void SetIOPriority(Env::IOPriority pri) override {
base_->SetIOPriority(pri); base_->SetIOPriority(pri);
} }
}; };
@ -247,16 +247,16 @@ class SpecialEnv : public EnvWrapper {
public: public:
ManifestFile(SpecialEnv* env, unique_ptr<WritableFile>&& b) ManifestFile(SpecialEnv* env, unique_ptr<WritableFile>&& b)
: env_(env), base_(std::move(b)) { } : env_(env), base_(std::move(b)) { }
Status Append(const Slice& data) { Status Append(const Slice& data) override {
if (env_->manifest_write_error_.load(std::memory_order_acquire)) { if (env_->manifest_write_error_.load(std::memory_order_acquire)) {
return Status::IOError("simulated writer error"); return Status::IOError("simulated writer error");
} else { } else {
return base_->Append(data); return base_->Append(data);
} }
} }
Status Close() { return base_->Close(); } Status Close() override { return base_->Close(); }
Status Flush() { return base_->Flush(); } Status Flush() override { return base_->Flush(); }
Status Sync() { Status Sync() override {
++env_->sync_counter_; ++env_->sync_counter_;
if (env_->manifest_sync_error_.load(std::memory_order_acquire)) { if (env_->manifest_sync_error_.load(std::memory_order_acquire)) {
return Status::IOError("simulated sync error"); return Status::IOError("simulated sync error");
@ -264,9 +264,7 @@ class SpecialEnv : public EnvWrapper {
return base_->Sync(); return base_->Sync();
} }
} }
uint64_t GetFileSize() { uint64_t GetFileSize() override { return base_->GetFileSize(); }
return base_->GetFileSize();
}
}; };
class WalFile : public WritableFile { class WalFile : public WritableFile {
private: private:
@ -275,7 +273,7 @@ class SpecialEnv : public EnvWrapper {
public: public:
WalFile(SpecialEnv* env, unique_ptr<WritableFile>&& b) WalFile(SpecialEnv* env, unique_ptr<WritableFile>&& b)
: env_(env), base_(std::move(b)) {} : env_(env), base_(std::move(b)) {}
Status Append(const Slice& data) { Status Append(const Slice& data) override {
if (env_->log_write_error_.load(std::memory_order_acquire)) { if (env_->log_write_error_.load(std::memory_order_acquire)) {
return Status::IOError("simulated writer error"); return Status::IOError("simulated writer error");
} else { } else {
@ -287,9 +285,9 @@ class SpecialEnv : public EnvWrapper {
return base_->Append(data); return base_->Append(data);
} }
} }
Status Close() { return base_->Close(); } Status Close() override { return base_->Close(); }
Status Flush() { return base_->Flush(); } Status Flush() override { return base_->Flush(); }
Status Sync() { Status Sync() override {
++env_->sync_counter_; ++env_->sync_counter_;
return base_->Sync(); return base_->Sync();
} }
@ -328,7 +326,7 @@ class SpecialEnv : public EnvWrapper {
Status NewRandomAccessFile(const std::string& f, Status NewRandomAccessFile(const std::string& f,
unique_ptr<RandomAccessFile>* r, unique_ptr<RandomAccessFile>* r,
const EnvOptions& soptions) { const EnvOptions& soptions) override {
class CountingFile : public RandomAccessFile { class CountingFile : public RandomAccessFile {
private: private:
unique_ptr<RandomAccessFile> target_; unique_ptr<RandomAccessFile> target_;
@ -339,7 +337,7 @@ class SpecialEnv : public EnvWrapper {
: target_(std::move(target)), counter_(counter) { : target_(std::move(target)), counter_(counter) {
} }
virtual Status Read(uint64_t offset, size_t n, Slice* result, virtual Status Read(uint64_t offset, size_t n, Slice* result,
char* scratch) const { char* scratch) const override {
counter_->Increment(); counter_->Increment();
return target_->Read(offset, n, result, scratch); return target_->Read(offset, n, result, scratch);
} }
@ -353,7 +351,7 @@ class SpecialEnv : public EnvWrapper {
} }
Status NewSequentialFile(const std::string& f, unique_ptr<SequentialFile>* r, Status NewSequentialFile(const std::string& f, unique_ptr<SequentialFile>* r,
const EnvOptions& soptions) { const EnvOptions& soptions) override {
class CountingFile : public SequentialFile { class CountingFile : public SequentialFile {
private: private:
unique_ptr<SequentialFile> target_; unique_ptr<SequentialFile> target_;
@ -363,11 +361,11 @@ class SpecialEnv : public EnvWrapper {
CountingFile(unique_ptr<SequentialFile>&& target, CountingFile(unique_ptr<SequentialFile>&& target,
anon::AtomicCounter* counter) anon::AtomicCounter* counter)
: target_(std::move(target)), counter_(counter) {} : target_(std::move(target)), counter_(counter) {}
virtual Status Read(size_t n, Slice* result, char* scratch) { virtual Status Read(size_t n, Slice* result, char* scratch) override {
counter_->Increment(); counter_->Increment();
return target_->Read(n, result, scratch); return target_->Read(n, result, scratch);
} }
virtual Status Skip(uint64_t n) { return target_->Skip(n); } virtual Status Skip(uint64_t n) override { return target_->Skip(n); }
}; };
Status s = target()->NewSequentialFile(f, r, soptions); Status s = target()->NewSequentialFile(f, r, soptions);
@ -377,7 +375,7 @@ class SpecialEnv : public EnvWrapper {
return s; return s;
} }
virtual void SleepForMicroseconds(int micros) { virtual void SleepForMicroseconds(int micros) override {
sleep_counter_.Increment(); sleep_counter_.Increment();
target()->SleepForMicroseconds(micros); target()->SleepForMicroseconds(micros);
} }
@ -6337,14 +6335,17 @@ TEST(DBTest, L0_CompactionBug_Issue44_b) {
TEST(DBTest, ComparatorCheck) { TEST(DBTest, ComparatorCheck) {
class NewComparator : public Comparator { class NewComparator : public Comparator {
public: public:
virtual const char* Name() const { return "rocksdb.NewComparator"; } virtual const char* Name() const override {
virtual int Compare(const Slice& a, const Slice& b) const { return "rocksdb.NewComparator";
}
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, const Slice& l) const { virtual void FindShortestSeparator(std::string* s,
const Slice& l) const override {
BytewiseComparator()->FindShortestSeparator(s, l); BytewiseComparator()->FindShortestSeparator(s, l);
} }
virtual void FindShortSuccessor(std::string* key) const { virtual void FindShortSuccessor(std::string* key) const override {
BytewiseComparator()->FindShortSuccessor(key); BytewiseComparator()->FindShortSuccessor(key);
} }
}; };
@ -6367,15 +6368,18 @@ TEST(DBTest, ComparatorCheck) {
TEST(DBTest, CustomComparator) { TEST(DBTest, CustomComparator) {
class NumberComparator : public Comparator { class NumberComparator : public Comparator {
public: public:
virtual const char* Name() const { return "test.NumberComparator"; } virtual const char* Name() const override {
virtual int Compare(const Slice& a, const Slice& b) const { return "test.NumberComparator";
}
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, const Slice& l) const { virtual void FindShortestSeparator(std::string* s,
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 { virtual void FindShortSuccessor(std::string* key) const override {
ToNumber(*key); // Check format ToNumber(*key); // Check format
} }
private: private:
@ -7829,20 +7833,22 @@ TEST(DBTest, 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, const Slice& value) { virtual Status PutCF(uint32_t cf, const Slice& key,
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, const Slice& value) { virtual Status MergeCF(uint32_t cf, const Slice& key,
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) { virtual void LogData(const Slice& blob) override {
seen += "LogData(" + blob.ToString() + ")"; seen += "LogData(" + blob.ToString() + ")";
} }
virtual Status DeleteCF(uint32_t cf, const Slice& key) { virtual 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();
} }
@ -8090,7 +8096,7 @@ class ModelDB: public DB {
public: public:
KVMap map_; KVMap map_;
virtual SequenceNumber GetSequenceNumber() const { virtual SequenceNumber GetSequenceNumber() const override {
// no need to call this // no need to call this
assert(false); assert(false);
return 0; return 0;
@ -8100,28 +8106,28 @@ 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, virtual Status Put(const WriteOptions& o, ColumnFamilyHandle* cf,
const Slice& k, const Slice& v) { const Slice& k, 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::Merge; using DB::Merge;
virtual Status Merge(const WriteOptions& o, ColumnFamilyHandle* cf, virtual Status Merge(const WriteOptions& o, ColumnFamilyHandle* cf,
const Slice& k, const Slice& v) { const Slice& k, 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::Delete; using DB::Delete;
virtual Status Delete(const WriteOptions& o, ColumnFamilyHandle* cf, virtual Status Delete(const WriteOptions& o, ColumnFamilyHandle* cf,
const Slice& key) { 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::Get; using DB::Get;
virtual Status Get(const ReadOptions& options, ColumnFamilyHandle* cf, virtual Status Get(const ReadOptions& options, ColumnFamilyHandle* cf,
const Slice& key, std::string* value) { const Slice& key, std::string* value) override {
return Status::NotSupported(key); return Status::NotSupported(key);
} }
@ -8129,22 +8135,25 @@ class ModelDB: public DB {
virtual std::vector<Status> MultiGet( virtual 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, std::vector<std::string>* values) { const std::vector<Slice>& keys,
std::vector<std::string>* values) override {
std::vector<Status> s(keys.size(), std::vector<Status> s(keys.size(),
Status::NotSupported("Not implemented.")); Status::NotSupported("Not implemented."));
return s; return s;
} }
using DB::GetPropertiesOfAllTables; using DB::GetPropertiesOfAllTables;
virtual Status GetPropertiesOfAllTables(ColumnFamilyHandle* column_family, virtual Status GetPropertiesOfAllTables(
TablePropertiesCollection* props) { ColumnFamilyHandle* column_family,
TablePropertiesCollection* props) override {
return Status(); return Status();
} }
using DB::KeyMayExist; using DB::KeyMayExist;
virtual bool KeyMayExist(const ReadOptions& options, virtual bool KeyMayExist(const ReadOptions& options,
ColumnFamilyHandle* column_family, const Slice& key, ColumnFamilyHandle* column_family, const Slice& key,
std::string* value, bool* value_found = nullptr) { std::string* value,
bool* value_found = nullptr) override {
if (value_found != nullptr) { if (value_found != nullptr) {
*value_found = false; *value_found = false;
} }
@ -8152,7 +8161,7 @@ class ModelDB: public DB {
} }
using DB::NewIterator; using DB::NewIterator;
virtual Iterator* NewIterator(const ReadOptions& options, virtual Iterator* NewIterator(const ReadOptions& options,
ColumnFamilyHandle* column_family) { ColumnFamilyHandle* column_family) override {
if (options.snapshot == nullptr) { if (options.snapshot == nullptr) {
KVMap* saved = new KVMap; KVMap* saved = new KVMap;
*saved = map_; *saved = map_;
@ -8166,31 +8175,32 @@ class ModelDB: public DB {
virtual Status NewIterators( virtual Status NewIterators(
const ReadOptions& options, const ReadOptions& options,
const std::vector<ColumnFamilyHandle*>& column_family, const std::vector<ColumnFamilyHandle*>& column_family,
std::vector<Iterator*>* iterators) { std::vector<Iterator*>* iterators) override {
return Status::NotSupported("Not supported yet"); return Status::NotSupported("Not supported yet");
} }
virtual const Snapshot* GetSnapshot() { virtual 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) { virtual void ReleaseSnapshot(const Snapshot* snapshot) override {
delete reinterpret_cast<const ModelSnapshot*>(snapshot); delete reinterpret_cast<const ModelSnapshot*>(snapshot);
} }
virtual Status Write(const WriteOptions& options, WriteBatch* batch) { virtual Status Write(const WriteOptions& options,
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) { virtual 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, const Slice& value) { virtual void Merge(const Slice& key, 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) { virtual void Delete(const Slice& key) override {
map_->erase(key.ToString()); map_->erase(key.ToString());
} }
}; };
@ -8201,7 +8211,7 @@ class ModelDB: public DB {
using DB::GetProperty; using DB::GetProperty;
virtual bool GetProperty(ColumnFamilyHandle* column_family, virtual bool GetProperty(ColumnFamilyHandle* column_family,
const Slice& property, std::string* value) { const Slice& property, std::string* value) override {
return false; return false;
} }
using DB::GetIntProperty; using DB::GetIntProperty;
@ -8211,7 +8221,8 @@ class ModelDB: public DB {
} }
using DB::GetApproximateSizes; using DB::GetApproximateSizes;
virtual void GetApproximateSizes(ColumnFamilyHandle* column_family, virtual void GetApproximateSizes(ColumnFamilyHandle* column_family,
const Range* range, int n, uint64_t* sizes) { const Range* range, int n,
uint64_t* sizes) override {
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
sizes[i] = 0; sizes[i] = 0;
} }
@ -8220,7 +8231,7 @@ class ModelDB: public DB {
virtual Status CompactRange(ColumnFamilyHandle* column_family, virtual Status CompactRange(ColumnFamilyHandle* column_family,
const Slice* start, const Slice* end, const Slice* start, const Slice* end,
bool reduce_level, int target_level, bool reduce_level, int target_level,
uint32_t output_path_id) { uint32_t output_path_id) override {
return Status::NotSupported("Not supported operation."); return Status::NotSupported("Not supported operation.");
} }
@ -8234,76 +8245,73 @@ class ModelDB: public DB {
} }
using DB::NumberLevels; using DB::NumberLevels;
virtual int NumberLevels(ColumnFamilyHandle* column_family) { return 1; } virtual int NumberLevels(ColumnFamilyHandle* column_family) override {
return 1;
}
using DB::MaxMemCompactionLevel; using DB::MaxMemCompactionLevel;
virtual int MaxMemCompactionLevel(ColumnFamilyHandle* column_family) { virtual int MaxMemCompactionLevel(
ColumnFamilyHandle* column_family) override {
return 1; return 1;
} }
using DB::Level0StopWriteTrigger; using DB::Level0StopWriteTrigger;
virtual int Level0StopWriteTrigger(ColumnFamilyHandle* column_family) { virtual int Level0StopWriteTrigger(
ColumnFamilyHandle* column_family) override {
return -1; return -1;
} }
virtual const std::string& GetName() const { virtual const std::string& GetName() const override { return name_; }
return name_;
}
virtual Env* GetEnv() const { virtual Env* GetEnv() const override { return nullptr; }
return nullptr;
}
using DB::GetOptions; using DB::GetOptions;
virtual const Options& GetOptions(ColumnFamilyHandle* column_family) const { virtual const Options& GetOptions(
ColumnFamilyHandle* column_family) const override {
return options_; return options_;
} }
using DB::Flush; using DB::Flush;
virtual Status Flush(const rocksdb::FlushOptions& options, virtual Status Flush(const rocksdb::FlushOptions& options,
ColumnFamilyHandle* column_family) { ColumnFamilyHandle* column_family) override {
Status ret; Status ret;
return ret; return ret;
} }
virtual Status DisableFileDeletions() { virtual Status DisableFileDeletions() override { return Status::OK(); }
return Status::OK(); virtual Status EnableFileDeletions(bool force) override {
}
virtual Status EnableFileDeletions(bool force) {
return Status::OK(); return Status::OK();
} }
virtual Status GetLiveFiles(std::vector<std::string>&, uint64_t* size, virtual Status GetLiveFiles(std::vector<std::string>&, uint64_t* size,
bool flush_memtable = true) { bool flush_memtable = true) override {
return Status::OK(); return Status::OK();
} }
virtual Status GetSortedWalFiles(VectorLogPtr& files) { virtual Status GetSortedWalFiles(VectorLogPtr& files) override {
return Status::OK(); return Status::OK();
} }
virtual Status DeleteFile(std::string name) { virtual Status DeleteFile(std::string name) override { return Status::OK(); }
return Status::OK();
}
virtual Status GetDbIdentity(std::string& identity) { virtual Status GetDbIdentity(std::string& identity) override {
return Status::OK(); return Status::OK();
} }
virtual SequenceNumber GetLatestSequenceNumber() const { virtual SequenceNumber GetLatestSequenceNumber() const override { return 0; }
return 0;
}
virtual Status GetUpdatesSince( virtual Status GetUpdatesSince(
rocksdb::SequenceNumber, unique_ptr<rocksdb::TransactionLogIterator>*, rocksdb::SequenceNumber, unique_ptr<rocksdb::TransactionLogIterator>*,
const TransactionLogIterator::ReadOptions& const TransactionLogIterator::ReadOptions&
read_options = TransactionLogIterator::ReadOptions()) { read_options = TransactionLogIterator::ReadOptions()) override {
return Status::NotSupported("Not supported in Model DB"); return Status::NotSupported("Not supported in Model DB");
} }
virtual ColumnFamilyHandle* DefaultColumnFamily() const { return nullptr; } virtual ColumnFamilyHandle* DefaultColumnFamily() const override {
return nullptr;
}
virtual void GetColumnFamilyMetaData( virtual void GetColumnFamilyMetaData(
ColumnFamilyHandle* column_family, ColumnFamilyHandle* column_family,
ColumnFamilyMetaData* metadata) {} ColumnFamilyMetaData* metadata) override {}
private: private:
class ModelIter: public Iterator { class ModelIter: public Iterator {
@ -8314,20 +8322,20 @@ class ModelDB: public DB {
~ModelIter() { ~ModelIter() {
if (owned_) delete map_; if (owned_) delete map_;
} }
virtual bool Valid() const { return iter_ != map_->end(); } virtual bool Valid() const override { return iter_ != map_->end(); }
virtual void SeekToFirst() { iter_ = map_->begin(); } virtual void SeekToFirst() override { iter_ = map_->begin(); }
virtual void SeekToLast() { virtual 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) { virtual void Seek(const Slice& k) override {
iter_ = map_->lower_bound(k.ToString()); iter_ = map_->lower_bound(k.ToString());
} }
virtual void Next() { ++iter_; } virtual void Next() override { ++iter_; }
virtual void Prev() { virtual void Prev() override {
if (iter_ == map_->begin()) { if (iter_ == map_->begin()) {
iter_ = map_->end(); iter_ = map_->end();
return; return;
@ -8335,9 +8343,10 @@ class ModelDB: public DB {
--iter_; --iter_;
} }
virtual Slice key() const { return iter_->first; } virtual Slice key() const override { return iter_->first; }
virtual Slice value() const { return iter_->second; } virtual Slice value() const override { return iter_->second; }
virtual Status status() const { return Status::OK(); } virtual Status status() const override { return Status::OK(); }
private: private:
const KVMap* const map_; const KVMap* const map_;
const bool owned_; // Do we own map_ const bool owned_; // Do we own map_

@ -111,12 +111,11 @@ class InternalKeyComparator : public Comparator {
} }
virtual ~InternalKeyComparator() {} virtual ~InternalKeyComparator() {}
virtual const char* Name() const; virtual const char* Name() const override;
virtual int Compare(const Slice& a, const Slice& b) const; virtual int Compare(const Slice& a, const Slice& b) const override;
virtual void FindShortestSeparator( virtual void FindShortestSeparator(std::string* start,
std::string* start, const Slice& limit) const override;
const Slice& limit) const; virtual void FindShortSuccessor(std::string* key) const override;
virtual void FindShortSuccessor(std::string* key) const;
const Comparator* user_comparator() const { return user_comparator_; } const Comparator* user_comparator() const { return user_comparator_; }
@ -371,19 +370,19 @@ class InternalKeySliceTransform : public SliceTransform {
explicit InternalKeySliceTransform(const SliceTransform* transform) explicit InternalKeySliceTransform(const SliceTransform* transform)
: transform_(transform) {} : transform_(transform) {}
virtual const char* Name() const { return transform_->Name(); } virtual const char* Name() const override { return transform_->Name(); }
virtual Slice Transform(const Slice& src) const { virtual Slice Transform(const Slice& src) const override {
auto user_key = ExtractUserKey(src); auto user_key = ExtractUserKey(src);
return transform_->Transform(user_key); return transform_->Transform(user_key);
} }
virtual bool InDomain(const Slice& src) const { virtual bool InDomain(const Slice& src) const override {
auto user_key = ExtractUserKey(src); auto user_key = ExtractUserKey(src);
return transform_->InDomain(user_key); return transform_->InDomain(user_key);
} }
virtual bool InRange(const Slice& dst) const { virtual bool InRange(const Slice& dst) const override {
auto user_key = ExtractUserKey(dst); auto user_key = ExtractUserKey(dst);
return transform_->InRange(user_key); return transform_->InRange(user_key);
} }

@ -136,10 +136,10 @@ class TestWritableFile : public WritableFile {
unique_ptr<WritableFile>&& f, unique_ptr<WritableFile>&& f,
FaultInjectionTestEnv* env); FaultInjectionTestEnv* env);
virtual ~TestWritableFile(); virtual ~TestWritableFile();
virtual Status Append(const Slice& data); virtual Status Append(const Slice& data) override;
virtual Status Close(); virtual Status Close() override;
virtual Status Flush(); virtual Status Flush() override;
virtual Status Sync(); virtual Status Sync() override;
private: private:
FileState state_; FileState state_;
@ -184,7 +184,7 @@ class FaultInjectionTestEnv : public EnvWrapper {
Status NewWritableFile(const std::string& fname, Status NewWritableFile(const std::string& fname,
unique_ptr<WritableFile>* result, unique_ptr<WritableFile>* result,
const EnvOptions& soptions) { const EnvOptions& soptions) override {
Status s = target()->NewWritableFile(fname, result, soptions); Status s = target()->NewWritableFile(fname, result, soptions);
if (s.ok()) { if (s.ok()) {
result->reset(new TestWritableFile(fname, std::move(*result), this)); result->reset(new TestWritableFile(fname, std::move(*result), this));
@ -200,7 +200,7 @@ class FaultInjectionTestEnv : public EnvWrapper {
return s; return s;
} }
virtual Status DeleteFile(const std::string& f) { virtual Status DeleteFile(const std::string& f) override {
Status s = EnvWrapper::DeleteFile(f); Status s = EnvWrapper::DeleteFile(f);
if (!s.ok()) { if (!s.ok()) {
fprintf(stderr, "Cannot delete file %s: %s\n", f.c_str(), fprintf(stderr, "Cannot delete file %s: %s\n", f.c_str(),
@ -213,7 +213,8 @@ class FaultInjectionTestEnv : public EnvWrapper {
return s; return s;
} }
virtual Status RenameFile(const std::string& s, const std::string& t) { virtual Status RenameFile(const std::string& s,
const std::string& t) override {
Status ret = EnvWrapper::RenameFile(s, t); Status ret = EnvWrapper::RenameFile(s, t);
if (ret.ok()) { if (ret.ok()) {

@ -19,7 +19,7 @@ namespace rocksdb {
class IntComparator : public Comparator { class IntComparator : public Comparator {
public: public:
int Compare(const Slice& a, const Slice& b) const { int Compare(const Slice& a, const Slice& b) const override {
assert(a.size() == 8); assert(a.size() == 8);
assert(b.size() == 8); assert(b.size() == 8);
int64_t diff = *reinterpret_cast<const int64_t*>(a.data()) - int64_t diff = *reinterpret_cast<const int64_t*>(a.data()) -
@ -33,13 +33,12 @@ class IntComparator : public Comparator {
} }
} }
const char* Name() const { const char* Name() const override { return "IntComparator"; }
return "IntComparator";
}
void FindShortestSeparator(std::string* start, const Slice& limit) const {} void FindShortestSeparator(std::string* start,
const Slice& limit) const override {}
void FindShortSuccessor(std::string* key) const {} void FindShortSuccessor(std::string* key) const override {}
}; };
struct FileIndexerTest { struct FileIndexerTest {

@ -53,7 +53,7 @@ class LevelIterator : public Iterator {
status_ = Status::NotSupported("LevelIterator::SeekToLast()"); status_ = Status::NotSupported("LevelIterator::SeekToLast()");
valid_ = false; valid_ = false;
} }
void Prev() { void Prev() override {
status_ = Status::NotSupported("LevelIterator::Prev()"); status_ = Status::NotSupported("LevelIterator::Prev()");
valid_ = false; valid_ = false;
} }

@ -58,7 +58,7 @@ class ForwardIterator : public Iterator {
status_ = Status::NotSupported("ForwardIterator::SeekToLast()"); status_ = Status::NotSupported("ForwardIterator::SeekToLast()");
valid_ = false; valid_ = false;
} }
void Prev() { void Prev() override {
status_ = Status::NotSupported("ForwardIterator::Prev"); status_ = Status::NotSupported("ForwardIterator::Prev");
valid_ = false; valid_ = false;
} }

@ -55,8 +55,8 @@ class LogTest {
reader_contents_ = Slice(contents_.data(), 0); reader_contents_ = Slice(contents_.data(), 0);
}; };
virtual Status Close() { return Status::OK(); } virtual Status Close() override { return Status::OK(); }
virtual Status Flush() { virtual Status Flush() override {
ASSERT_TRUE(reader_contents_.size() <= last_flush_); ASSERT_TRUE(reader_contents_.size() <= last_flush_);
size_t offset = last_flush_ - reader_contents_.size(); size_t offset = last_flush_ - reader_contents_.size();
reader_contents_ = Slice( reader_contents_ = Slice(
@ -66,8 +66,8 @@ class LogTest {
return Status::OK(); return Status::OK();
} }
virtual Status Sync() { return Status::OK(); } virtual Status Sync() override { return Status::OK(); }
virtual Status Append(const Slice& slice) { virtual Status Append(const Slice& slice) override {
contents_.append(slice.data(), slice.size()); contents_.append(slice.data(), slice.size());
return Status::OK(); return Status::OK();
} }
@ -99,7 +99,7 @@ class LogTest {
force_eof_position_(0), force_eof_position_(0),
returned_partial_(false) { } returned_partial_(false) { }
virtual Status Read(size_t n, Slice* result, char* scratch) { virtual Status Read(size_t n, Slice* result, char* scratch) override {
ASSERT_TRUE(!returned_partial_) << "must not Read() after eof/error"; ASSERT_TRUE(!returned_partial_) << "must not Read() after eof/error";
if (force_error_) { if (force_error_) {
@ -138,7 +138,7 @@ class LogTest {
return Status::OK(); return Status::OK();
} }
virtual Status Skip(uint64_t n) { virtual 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");
@ -156,7 +156,7 @@ class LogTest {
std::string message_; std::string message_;
ReportCollector() : dropped_bytes_(0) { } ReportCollector() : dropped_bytes_(0) { }
virtual void Corruption(size_t bytes, const Status& status) { virtual void Corruption(size_t bytes, const Status& status) override {
dropped_bytes_ += bytes; dropped_bytes_ += bytes;
message_.append(status.ToString()); message_.append(status.ToString());
} }

@ -221,8 +221,8 @@ class MemTableIterator: public Iterator {
} }
} }
virtual bool Valid() const { return valid_; } virtual bool Valid() const override { return valid_; }
virtual void Seek(const Slice& k) { virtual void Seek(const Slice& k) override {
if (bloom_ != nullptr && if (bloom_ != nullptr &&
!bloom_->MayContain(prefix_extractor_->Transform(ExtractUserKey(k)))) { !bloom_->MayContain(prefix_extractor_->Transform(ExtractUserKey(k)))) {
valid_ = false; valid_ = false;
@ -231,35 +231,35 @@ class MemTableIterator: public Iterator {
iter_->Seek(k, nullptr); iter_->Seek(k, nullptr);
valid_ = iter_->Valid(); valid_ = iter_->Valid();
} }
virtual void SeekToFirst() { virtual void SeekToFirst() override {
iter_->SeekToFirst(); iter_->SeekToFirst();
valid_ = iter_->Valid(); valid_ = iter_->Valid();
} }
virtual void SeekToLast() { virtual void SeekToLast() override {
iter_->SeekToLast(); iter_->SeekToLast();
valid_ = iter_->Valid(); valid_ = iter_->Valid();
} }
virtual void Next() { virtual void Next() override {
assert(Valid()); assert(Valid());
iter_->Next(); iter_->Next();
valid_ = iter_->Valid(); valid_ = iter_->Valid();
} }
virtual void Prev() { virtual void Prev() override {
assert(Valid()); assert(Valid());
iter_->Prev(); iter_->Prev();
valid_ = iter_->Valid(); valid_ = iter_->Valid();
} }
virtual Slice key() const { virtual Slice key() const override {
assert(Valid()); assert(Valid());
return GetLengthPrefixedSlice(iter_->key()); return GetLengthPrefixedSlice(iter_->key());
} }
virtual Slice value() const { virtual 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 { return Status::OK(); } virtual Status status() const override { return Status::OK(); }
private: private:
DynamicBloom* bloom_; DynamicBloom* bloom_;

@ -59,7 +59,7 @@ class MemTable {
const InternalKeyComparator comparator; const InternalKeyComparator comparator;
explicit KeyComparator(const InternalKeyComparator& c) : comparator(c) { } explicit KeyComparator(const InternalKeyComparator& c) : comparator(c) { }
virtual int operator()(const char* prefix_len_key1, virtual int operator()(const char* prefix_len_key1,
const char* prefix_len_key2) const; const char* prefix_len_key2) const override;
virtual int operator()(const char* prefix_len_key, virtual int operator()(const char* prefix_len_key,
const Slice& key) const override; const Slice& key) const override;
}; };

@ -57,7 +57,8 @@ class CountMergeOperator : public AssociativeMergeOperator {
virtual bool PartialMergeMulti(const Slice& key, virtual bool PartialMergeMulti(const Slice& key,
const std::deque<Slice>& operand_list, const std::deque<Slice>& operand_list,
std::string* new_value, Logger* logger) const { std::string* new_value,
Logger* logger) const override {
++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);

@ -70,7 +70,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 { virtual int Compare(const Slice& a, const Slice& b) const override {
const TestKey* key_a = SliceToTestKey(a); const TestKey* key_a = SliceToTestKey(a);
const TestKey* key_b = SliceToTestKey(b); const TestKey* key_b = SliceToTestKey(b);
if (key_a->prefix != key_b->prefix) { if (key_a->prefix != key_b->prefix) {
@ -106,13 +106,10 @@ class TestKeyComparator : public Comparator {
return "TestKeyComparator"; return "TestKeyComparator";
} }
virtual void FindShortestSeparator( virtual void FindShortestSeparator(std::string* start,
std::string* start, const Slice& limit) const override {}
const Slice& limit) const {
}
virtual void FindShortSuccessor(std::string* key) const {}
virtual void FindShortSuccessor(std::string* key) const override {}
}; };
namespace { namespace {

@ -189,7 +189,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) { virtual 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.
Log(InfoLogLevel::ERROR_LEVEL, info_log, Log(InfoLogLevel::ERROR_LEVEL, info_log,
"Log #%" PRIu64 ": dropping %d bytes; %s", lognum, "Log #%" PRIu64 ": dropping %d bytes; %s", lognum,

@ -20,7 +20,7 @@ class SnapshotImpl : public Snapshot {
public: public:
SequenceNumber number_; // const after creation SequenceNumber number_; // const after creation
virtual SequenceNumber GetSequenceNumber() const { return number_; } virtual SequenceNumber GetSequenceNumber() const override { return number_; }
private: private:
friend class SnapshotList; friend class SnapshotList;

@ -39,7 +39,7 @@ class InternalKeyPropertiesCollector : public TablePropertiesCollector {
class InternalKeyPropertiesCollectorFactory class InternalKeyPropertiesCollectorFactory
: public TablePropertiesCollectorFactory { : public TablePropertiesCollectorFactory {
public: public:
virtual TablePropertiesCollector* CreateTablePropertiesCollector() { virtual TablePropertiesCollector* CreateTablePropertiesCollector() override {
return new InternalKeyPropertiesCollector(); return new InternalKeyPropertiesCollector();
} }
@ -79,7 +79,7 @@ class UserKeyTablePropertiesCollectorFactory
explicit UserKeyTablePropertiesCollectorFactory( explicit UserKeyTablePropertiesCollectorFactory(
std::shared_ptr<TablePropertiesCollectorFactory> user_collector_factory) std::shared_ptr<TablePropertiesCollectorFactory> user_collector_factory)
: user_collector_factory_(user_collector_factory) {} : user_collector_factory_(user_collector_factory) {}
virtual TablePropertiesCollector* CreateTablePropertiesCollector() { virtual TablePropertiesCollector* CreateTablePropertiesCollector() override {
return new UserKeyTablePropertiesCollector( return new UserKeyTablePropertiesCollector(
user_collector_factory_->CreateTablePropertiesCollector()); user_collector_factory_->CreateTablePropertiesCollector());
} }

@ -35,11 +35,11 @@ class FakeWritableFile : public WritableFile {
const std::string& contents() const { return contents_; } const std::string& contents() const { return contents_; }
virtual Status Close() { return Status::OK(); } virtual Status Close() override { return Status::OK(); }
virtual Status Flush() { return Status::OK(); } virtual Status Flush() override { return Status::OK(); }
virtual Status Sync() { return Status::OK(); } virtual Status Sync() override { return Status::OK(); }
virtual Status Append(const Slice& data) { virtual Status Append(const Slice& data) override {
contents_.append(data.data(), data.size()); contents_.append(data.data(), data.size());
return Status::OK(); return Status::OK();
} }
@ -60,7 +60,7 @@ class FakeRandomeAccessFile : public RandomAccessFile {
uint64_t Size() const { return contents_.size(); } uint64_t Size() const { return contents_.size(); }
virtual Status Read(uint64_t offset, size_t n, Slice* result, virtual Status Read(uint64_t offset, size_t n, Slice* result,
char* scratch) const { char* scratch) const override {
if (offset > contents_.size()) { if (offset > contents_.size()) {
return Status::InvalidArgument("invalid Read offset"); return Status::InvalidArgument("invalid Read offset");
} }
@ -80,8 +80,8 @@ class FakeRandomeAccessFile : public RandomAccessFile {
class DumbLogger : public Logger { class DumbLogger : public Logger {
public: public:
using Logger::Logv; using Logger::Logv;
virtual void Logv(const char* format, va_list ap) { } virtual void Logv(const char* format, va_list ap) override {}
virtual size_t GetLogFileSize() const { return 0; } virtual size_t GetLogFileSize() const override { return 0; }
}; };
// Utilities test functions // Utilities test functions
@ -101,9 +101,9 @@ void MakeBuilder(const Options& options,
// Collects keys that starts with "A" in a table. // Collects keys that starts with "A" in a table.
class RegularKeysStartWithA: public TablePropertiesCollector { class RegularKeysStartWithA: public TablePropertiesCollector {
public: public:
const char* Name() const { return "RegularKeysStartWithA"; } const char* Name() const override { return "RegularKeysStartWithA"; }
Status Finish(UserCollectedProperties* properties) { Status Finish(UserCollectedProperties* properties) override {
std::string encoded; std::string encoded;
PutVarint32(&encoded, count_); PutVarint32(&encoded, count_);
*properties = UserCollectedProperties { *properties = UserCollectedProperties {
@ -113,7 +113,7 @@ class RegularKeysStartWithA: public TablePropertiesCollector {
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 {
// simply asssume all user keys are not empty. // simply asssume all user keys are not empty.
if (user_key.data()[0] == 'A') { if (user_key.data()[0] == 'A') {
++count_; ++count_;
@ -121,7 +121,7 @@ class RegularKeysStartWithA: public TablePropertiesCollector {
return Status::OK(); return Status::OK();
} }
virtual UserCollectedProperties GetReadableProperties() const { virtual UserCollectedProperties GetReadableProperties() const override {
return UserCollectedProperties{}; return UserCollectedProperties{};
} }
@ -131,10 +131,10 @@ class RegularKeysStartWithA: public TablePropertiesCollector {
class RegularKeysStartWithAFactory : public TablePropertiesCollectorFactory { class RegularKeysStartWithAFactory : public TablePropertiesCollectorFactory {
public: public:
virtual TablePropertiesCollector* CreateTablePropertiesCollector() { virtual TablePropertiesCollector* CreateTablePropertiesCollector() override {
return new RegularKeysStartWithA(); return new RegularKeysStartWithA();
} }
const char* Name() const { return "RegularKeysStartWithA"; } const char* Name() const override { return "RegularKeysStartWithA"; }
}; };
extern uint64_t kBlockBasedTableMagicNumber; extern uint64_t kBlockBasedTableMagicNumber;

@ -27,20 +27,20 @@ class LogFileImpl : public LogFile {
sizeFileBytes_(sizeBytes) { sizeFileBytes_(sizeBytes) {
} }
std::string PathName() const { std::string PathName() const override {
if (type_ == kArchivedLogFile) { if (type_ == kArchivedLogFile) {
return ArchivedLogFileName("", logNumber_); return ArchivedLogFileName("", logNumber_);
} }
return LogFileName("", logNumber_); return LogFileName("", logNumber_);
} }
uint64_t LogNumber() const { return logNumber_; } uint64_t LogNumber() const override { return logNumber_; }
WalFileType Type() const { return type_; } WalFileType Type() const override { return type_; }
SequenceNumber StartSequence() const { return startSequence_; } SequenceNumber StartSequence() const override { return startSequence_; }
uint64_t SizeFileBytes() const { return sizeFileBytes_; } uint64_t SizeFileBytes() const override { return sizeFileBytes_; }
bool operator < (const LogFile& that) const { bool operator < (const LogFile& that) const {
return LogNumber() < that.LogNumber(); return LogNumber() < that.LogNumber();
@ -62,13 +62,13 @@ class TransactionLogIteratorImpl : public TransactionLogIterator {
const EnvOptions& soptions, const SequenceNumber seqNum, const EnvOptions& soptions, const SequenceNumber seqNum,
std::unique_ptr<VectorLogPtr> files, VersionSet const* const versions); std::unique_ptr<VectorLogPtr> files, VersionSet const* const versions);
virtual bool Valid(); virtual bool Valid() override;
virtual void Next(); virtual void Next() override;
virtual Status status(); virtual Status status() override;
virtual BatchResult GetBatch(); virtual BatchResult GetBatch() override;
private: private:
const std::string& dir_; const std::string& dir_;
@ -88,7 +88,7 @@ class TransactionLogIteratorImpl : public TransactionLogIterator {
struct LogReporter : public log::Reader::Reporter { struct LogReporter : public log::Reader::Reporter {
Env* env; Env* env;
Logger* info_log; Logger* info_log;
virtual void Corruption(size_t bytes, const Status& s) { virtual void Corruption(size_t bytes, const Status& s) override {
Log(InfoLogLevel::ERROR_LEVEL, info_log, "dropping %zu bytes; %s", bytes, Log(InfoLogLevel::ERROR_LEVEL, info_log, "dropping %zu bytes; %s", bytes,
s.ToString().c_str()); s.ToString().c_str());
} }

@ -425,23 +425,21 @@ class LevelFileNumIterator : public Iterator {
index_(static_cast<uint32_t>(flevel->num_files)), index_(static_cast<uint32_t>(flevel->num_files)),
current_value_(0, 0, 0) { // Marks as invalid current_value_(0, 0, 0) { // Marks as invalid
} }
virtual bool Valid() const { virtual bool Valid() const override { return index_ < flevel_->num_files; }
return index_ < flevel_->num_files; virtual void Seek(const Slice& target) override {
}
virtual void Seek(const Slice& target) {
index_ = FindFile(icmp_, *flevel_, target); index_ = FindFile(icmp_, *flevel_, target);
} }
virtual void SeekToFirst() { index_ = 0; } virtual void SeekToFirst() override { index_ = 0; }
virtual void SeekToLast() { virtual void SeekToLast() override {
index_ = (flevel_->num_files == 0) index_ = (flevel_->num_files == 0)
? 0 ? 0
: static_cast<uint32_t>(flevel_->num_files) - 1; : static_cast<uint32_t>(flevel_->num_files) - 1;
} }
virtual void Next() { virtual void Next() override {
assert(Valid()); assert(Valid());
index_++; index_++;
} }
virtual void Prev() { virtual void Prev() override {
assert(Valid()); assert(Valid());
if (index_ == 0) { if (index_ == 0) {
index_ = static_cast<uint32_t>(flevel_->num_files); // Marks as invalid index_ = static_cast<uint32_t>(flevel_->num_files); // Marks as invalid
@ -449,11 +447,11 @@ class LevelFileNumIterator : public Iterator {
index_--; index_--;
} }
} }
Slice key() const { Slice key() const override {
assert(Valid()); assert(Valid());
return flevel_->files[index_].largest_key; return flevel_->files[index_].largest_key;
} }
Slice value() const { Slice value() const override {
assert(Valid()); assert(Valid());
auto file_meta = flevel_->files[index_]; auto file_meta = flevel_->files[index_];
@ -461,7 +459,8 @@ class LevelFileNumIterator : public Iterator {
return Slice(reinterpret_cast<const char*>(&current_value_), return Slice(reinterpret_cast<const char*>(&current_value_),
sizeof(FileDescriptor)); sizeof(FileDescriptor));
} }
virtual Status status() const { return Status::OK(); } virtual Status status() const override { return Status::OK(); }
private: private:
const InternalKeyComparator icmp_; const InternalKeyComparator icmp_;
const LevelFilesBrief* flevel_; const LevelFilesBrief* flevel_;

@ -606,7 +606,7 @@ class VersionSet {
struct LogReporter : public log::Reader::Reporter { struct LogReporter : public log::Reader::Reporter {
Status* status; Status* status;
virtual void Corruption(size_t bytes, const Status& s) { virtual void Corruption(size_t bytes, const Status& s) override {
if (this->status->ok()) *this->status = s; if (this->status->ok()) *this->status = s;
} }
}; };

@ -416,7 +416,7 @@ Status WalManager::ReadFirstLine(const std::string& fname,
Status* status; Status* status;
bool ignore_error; // true if db_options_.paranoid_checks==false bool ignore_error; // true if db_options_.paranoid_checks==false
virtual void Corruption(size_t bytes, const Status& s) { virtual void Corruption(size_t bytes, const Status& s) override {
Log(InfoLogLevel::WARN_LEVEL, info_log, Log(InfoLogLevel::WARN_LEVEL, info_log,
"[WalManager] %s%s: dropping %d bytes; %s", "[WalManager] %s%s: dropping %d bytes; %s",
(this->ignore_error ? "(ignoring error) " : ""), fname, (this->ignore_error ? "(ignoring error) " : ""), fname,

@ -332,7 +332,7 @@ class MemTableInserter : public WriteBatch::Handler {
return true; return true;
} }
virtual Status PutCF(uint32_t column_family_id, const Slice& key, virtual Status PutCF(uint32_t column_family_id, const Slice& key,
const Slice& value) { const Slice& value) override {
Status seek_status; Status seek_status;
if (!SeekToColumnFamily(column_family_id, &seek_status)) { if (!SeekToColumnFamily(column_family_id, &seek_status)) {
++sequence_; ++sequence_;
@ -388,7 +388,7 @@ class MemTableInserter : public WriteBatch::Handler {
} }
virtual Status MergeCF(uint32_t column_family_id, const Slice& key, virtual Status MergeCF(uint32_t column_family_id, const Slice& key,
const Slice& value) { const Slice& value) override {
Status seek_status; Status seek_status;
if (!SeekToColumnFamily(column_family_id, &seek_status)) { if (!SeekToColumnFamily(column_family_id, &seek_status)) {
++sequence_; ++sequence_;
@ -458,7 +458,8 @@ class MemTableInserter : public WriteBatch::Handler {
return Status::OK(); return Status::OK();
} }
virtual Status DeleteCF(uint32_t column_family_id, const Slice& key) { virtual Status DeleteCF(uint32_t column_family_id,
const Slice& key) override {
Status seek_status; Status seek_status;
if (!SeekToColumnFamily(column_family_id, &seek_status)) { if (!SeekToColumnFamily(column_family_id, &seek_status)) {
++sequence_; ++sequence_;

@ -153,7 +153,7 @@ namespace {
struct TestHandler : public WriteBatch::Handler { struct TestHandler : public WriteBatch::Handler {
std::string seen; std::string seen;
virtual Status PutCF(uint32_t column_family_id, const Slice& key, virtual Status PutCF(uint32_t column_family_id, const Slice& key,
const Slice& value) { const Slice& value) override {
if (column_family_id == 0) { if (column_family_id == 0) {
seen += "Put(" + key.ToString() + ", " + value.ToString() + ")"; seen += "Put(" + key.ToString() + ", " + value.ToString() + ")";
} else { } else {
@ -163,7 +163,7 @@ namespace {
return Status::OK(); return Status::OK();
} }
virtual Status MergeCF(uint32_t column_family_id, const Slice& key, virtual Status MergeCF(uint32_t column_family_id, const Slice& key,
const Slice& value) { const Slice& value) override {
if (column_family_id == 0) { if (column_family_id == 0) {
seen += "Merge(" + key.ToString() + ", " + value.ToString() + ")"; seen += "Merge(" + key.ToString() + ", " + value.ToString() + ")";
} else { } else {
@ -172,10 +172,11 @@ namespace {
} }
return Status::OK(); return Status::OK();
} }
virtual void LogData(const Slice& blob) { virtual void LogData(const Slice& blob) override {
seen += "LogData(" + blob.ToString() + ")"; seen += "LogData(" + blob.ToString() + ")";
} }
virtual Status DeleteCF(uint32_t column_family_id, const Slice& key) { virtual Status DeleteCF(uint32_t column_family_id,
const Slice& key) override {
if (column_family_id == 0) { if (column_family_id == 0) {
seen += "Delete(" + key.ToString() + ")"; seen += "Delete(" + key.ToString() + ")";
} else { } else {
@ -256,20 +257,21 @@ TEST(WriteBatchTest, Continue) {
struct Handler : public TestHandler { struct Handler : public TestHandler {
int num_seen = 0; int num_seen = 0;
virtual Status PutCF(uint32_t column_family_id, const Slice& key, virtual Status PutCF(uint32_t column_family_id, const Slice& key,
const Slice& value) { const Slice& value) override {
++num_seen; ++num_seen;
return TestHandler::PutCF(column_family_id, key, value); return TestHandler::PutCF(column_family_id, key, value);
} }
virtual Status MergeCF(uint32_t column_family_id, const Slice& key, virtual Status MergeCF(uint32_t column_family_id, const Slice& key,
const Slice& value) { const Slice& value) override {
++num_seen; ++num_seen;
return TestHandler::MergeCF(column_family_id, key, value); return TestHandler::MergeCF(column_family_id, key, value);
} }
virtual void LogData(const Slice& blob) { virtual void LogData(const Slice& blob) override {
++num_seen; ++num_seen;
TestHandler::LogData(blob); TestHandler::LogData(blob);
} }
virtual Status DeleteCF(uint32_t column_family_id, const Slice& key) { virtual Status DeleteCF(uint32_t column_family_id,
const Slice& key) override {
++num_seen; ++num_seen;
return TestHandler::DeleteCF(column_family_id, key); return TestHandler::DeleteCF(column_family_id, key);
} }

@ -246,91 +246,114 @@ class HdfsEnv : public Env {
virtual Status NewSequentialFile(const std::string& fname, virtual Status NewSequentialFile(const std::string& fname,
unique_ptr<SequentialFile>* result, unique_ptr<SequentialFile>* result,
const EnvOptions& options); const EnvOptions& options) override;
virtual Status NewRandomAccessFile(const std::string& fname, virtual Status NewRandomAccessFile(const std::string& fname,
unique_ptr<RandomAccessFile>* result, unique_ptr<RandomAccessFile>* result,
const EnvOptions& options) { const EnvOptions& options) override {
return notsup; return notsup;
} }
virtual Status NewWritableFile(const std::string& fname, virtual Status NewWritableFile(const std::string& fname,
unique_ptr<WritableFile>* result, unique_ptr<WritableFile>* result,
const EnvOptions& options) { const EnvOptions& options) override {
return notsup; return notsup;
} }
virtual Status NewRandomRWFile(const std::string& fname, virtual Status NewRandomRWFile(const std::string& fname,
unique_ptr<RandomRWFile>* result, unique_ptr<RandomRWFile>* result,
const EnvOptions& options) { const EnvOptions& options) override {
return notsup; return notsup;
} }
virtual Status NewDirectory(const std::string& name, virtual Status NewDirectory(const std::string& name,
unique_ptr<Directory>* result) { unique_ptr<Directory>* result) override {
return notsup; return notsup;
} }
virtual bool FileExists(const std::string& fname){return false;} virtual bool FileExists(const std::string& fname) override { return false; }
virtual Status GetChildren(const std::string& path, virtual Status GetChildren(const std::string& path,
std::vector<std::string>* result){return notsup;} std::vector<std::string>* result) override {
return notsup;
}
virtual Status DeleteFile(const std::string& fname){return notsup;} virtual Status DeleteFile(const std::string& fname) override {
return notsup;
}
virtual Status CreateDir(const std::string& name){return notsup;} virtual Status CreateDir(const std::string& name) override { return notsup; }
virtual Status CreateDirIfMissing(const std::string& name){return notsup;} virtual Status CreateDirIfMissing(const std::string& name) override {
return notsup;
}
virtual Status DeleteDir(const std::string& name){return notsup;} virtual Status DeleteDir(const std::string& name) override { return notsup; }
virtual Status GetFileSize(const std::string& fname, uint64_t* size){return notsup;} virtual Status GetFileSize(const std::string& fname,
uint64_t* size) override {
return notsup;
}
virtual Status GetFileModificationTime(const std::string& fname, virtual Status GetFileModificationTime(const std::string& fname,
uint64_t* time) { uint64_t* time) override {
return notsup; return notsup;
} }
virtual Status RenameFile(const std::string& src, const std::string& target){return notsup;} virtual Status RenameFile(const std::string& src,
const std::string& target) override {
return notsup;
}
virtual Status LinkFile(const std::string& src, const std::string& target) { virtual Status LinkFile(const std::string& src,
const std::string& target) override {
return notsup; return notsup;
} }
virtual Status LockFile(const std::string& fname, FileLock** lock){return notsup;} virtual Status LockFile(const std::string& fname, FileLock** lock) override {
return notsup;
}
virtual Status UnlockFile(FileLock* lock){return notsup;} virtual Status UnlockFile(FileLock* lock) override { return notsup; }
virtual Status NewLogger(const std::string& fname, virtual Status NewLogger(const std::string& fname,
shared_ptr<Logger>* result){return notsup;} shared_ptr<Logger>* result) override {
return notsup;
}
virtual void Schedule(void (*function)(void* arg), void* arg, virtual void Schedule(void (*function)(void* arg), void* arg,
Priority pri = LOW) {} Priority pri = LOW) override {}
virtual void StartThread(void (*function)(void* arg), void* arg) {} virtual void StartThread(void (*function)(void* arg), void* arg) override {}
virtual void WaitForJoin() {} virtual void WaitForJoin() override {}
virtual unsigned int GetThreadPoolQueueLen(Priority pri = LOW) const { virtual unsigned int GetThreadPoolQueueLen(
Priority pri = LOW) const override {
return 0; return 0;
} }
virtual Status GetTestDirectory(std::string* path) {return notsup;} virtual Status GetTestDirectory(std::string* path) override { return notsup; }
virtual uint64_t NowMicros() {return 0;} virtual uint64_t NowMicros() override { return 0; }
virtual void SleepForMicroseconds(int micros) {} virtual void SleepForMicroseconds(int micros) override {}
virtual Status GetHostName(char* name, uint64_t len) {return notsup;} virtual Status GetHostName(char* name, uint64_t len) override {
return notsup;
}
virtual Status GetCurrentTime(int64_t* unix_time) {return notsup;} virtual Status GetCurrentTime(int64_t* unix_time) override { return notsup; }
virtual Status GetAbsolutePath(const std::string& db_path, virtual Status GetAbsolutePath(const std::string& db_path,
std::string* outputpath) {return notsup;} std::string* outputpath) override {
return notsup;
}
virtual void SetBackgroundThreads(int number, Priority pri = LOW) {} virtual void SetBackgroundThreads(int number, Priority pri = LOW) override {}
virtual void IncBackgroundThreadsIfNeeded(int number, Priority pri) {} virtual void IncBackgroundThreadsIfNeeded(int number, Priority pri) override {
virtual std::string TimeToString(uint64_t number) { return "";} }
virtual std::string TimeToString(uint64_t number) override { return ""; }
}; };
} }

@ -744,97 +744,104 @@ class EnvWrapper : public Env {
Env* target() const { return target_; } Env* target() const { return target_; }
// The following text is boilerplate that forwards all methods to target() // The following text is boilerplate that forwards all methods to target()
Status NewSequentialFile(const std::string& f, Status NewSequentialFile(const std::string& f, unique_ptr<SequentialFile>* r,
unique_ptr<SequentialFile>* r, const EnvOptions& options) override {
const EnvOptions& options) {
return target_->NewSequentialFile(f, r, options); return target_->NewSequentialFile(f, r, options);
} }
Status NewRandomAccessFile(const std::string& f, Status NewRandomAccessFile(const std::string& f,
unique_ptr<RandomAccessFile>* r, unique_ptr<RandomAccessFile>* r,
const EnvOptions& options) { const EnvOptions& options) override {
return target_->NewRandomAccessFile(f, r, options); return target_->NewRandomAccessFile(f, r, options);
} }
Status NewWritableFile(const std::string& f, unique_ptr<WritableFile>* r, Status NewWritableFile(const std::string& f, unique_ptr<WritableFile>* r,
const EnvOptions& options) { const EnvOptions& options) override {
return target_->NewWritableFile(f, r, options); return target_->NewWritableFile(f, r, options);
} }
Status NewRandomRWFile(const std::string& f, unique_ptr<RandomRWFile>* r, Status NewRandomRWFile(const std::string& f, unique_ptr<RandomRWFile>* r,
const EnvOptions& options) { const EnvOptions& options) override {
return target_->NewRandomRWFile(f, r, options); return target_->NewRandomRWFile(f, r, options);
} }
virtual Status NewDirectory(const std::string& name, virtual Status NewDirectory(const std::string& name,
unique_ptr<Directory>* result) { unique_ptr<Directory>* result) override {
return target_->NewDirectory(name, result); return target_->NewDirectory(name, result);
} }
bool FileExists(const std::string& f) { return target_->FileExists(f); } bool FileExists(const std::string& f) override {
Status GetChildren(const std::string& dir, std::vector<std::string>* r) { return target_->FileExists(f);
}
Status GetChildren(const std::string& dir,
std::vector<std::string>* r) override {
return target_->GetChildren(dir, r); return target_->GetChildren(dir, r);
} }
Status DeleteFile(const std::string& f) { return target_->DeleteFile(f); } Status DeleteFile(const std::string& f) override {
Status CreateDir(const std::string& d) { return target_->CreateDir(d); } return target_->DeleteFile(f);
Status CreateDirIfMissing(const std::string& d) { }
Status CreateDir(const std::string& d) override {
return target_->CreateDir(d);
}
Status CreateDirIfMissing(const std::string& d) override {
return target_->CreateDirIfMissing(d); return target_->CreateDirIfMissing(d);
} }
Status DeleteDir(const std::string& d) { return target_->DeleteDir(d); } Status DeleteDir(const std::string& d) override {
Status GetFileSize(const std::string& f, uint64_t* s) { return target_->DeleteDir(d);
}
Status GetFileSize(const std::string& f, uint64_t* s) override {
return target_->GetFileSize(f, s); return target_->GetFileSize(f, s);
} }
Status GetFileModificationTime(const std::string& fname, Status GetFileModificationTime(const std::string& fname,
uint64_t* file_mtime) { uint64_t* file_mtime) override {
return target_->GetFileModificationTime(fname, file_mtime); return target_->GetFileModificationTime(fname, file_mtime);
} }
Status RenameFile(const std::string& s, const std::string& t) { Status RenameFile(const std::string& s, const std::string& t) override {
return target_->RenameFile(s, t); return target_->RenameFile(s, t);
} }
Status LinkFile(const std::string& s, const std::string& t) { Status LinkFile(const std::string& s, const std::string& t) override {
return target_->LinkFile(s, t); return target_->LinkFile(s, t);
} }
Status LockFile(const std::string& f, FileLock** l) { Status LockFile(const std::string& f, FileLock** l) override {
return target_->LockFile(f, l); return target_->LockFile(f, l);
} }
Status UnlockFile(FileLock* l) { return target_->UnlockFile(l); } Status UnlockFile(FileLock* l) override { return target_->UnlockFile(l); }
void Schedule(void (*f)(void*), void* a, Priority pri) { void Schedule(void (*f)(void*), void* a, Priority pri) override {
return target_->Schedule(f, a, pri); return target_->Schedule(f, a, pri);
} }
void StartThread(void (*f)(void*), void* a) { void StartThread(void (*f)(void*), void* a) override {
return target_->StartThread(f, a); return target_->StartThread(f, a);
} }
void WaitForJoin() { return target_->WaitForJoin(); } void WaitForJoin() override { return target_->WaitForJoin(); }
virtual unsigned int GetThreadPoolQueueLen(Priority pri = LOW) const { virtual unsigned int GetThreadPoolQueueLen(
Priority pri = LOW) const override {
return target_->GetThreadPoolQueueLen(pri); return target_->GetThreadPoolQueueLen(pri);
} }
virtual Status GetTestDirectory(std::string* path) { virtual Status GetTestDirectory(std::string* path) override {
return target_->GetTestDirectory(path); return target_->GetTestDirectory(path);
} }
virtual Status NewLogger(const std::string& fname, virtual Status NewLogger(const std::string& fname,
shared_ptr<Logger>* result) { shared_ptr<Logger>* result) override {
return target_->NewLogger(fname, result); return target_->NewLogger(fname, result);
} }
uint64_t NowMicros() { uint64_t NowMicros() override { return target_->NowMicros(); }
return target_->NowMicros(); void SleepForMicroseconds(int micros) override {
}
void SleepForMicroseconds(int micros) {
target_->SleepForMicroseconds(micros); target_->SleepForMicroseconds(micros);
} }
Status GetHostName(char* name, uint64_t len) { Status GetHostName(char* name, uint64_t len) override {
return target_->GetHostName(name, len); return target_->GetHostName(name, len);
} }
Status GetCurrentTime(int64_t* unix_time) { Status GetCurrentTime(int64_t* unix_time) override {
return target_->GetCurrentTime(unix_time); return target_->GetCurrentTime(unix_time);
} }
Status GetAbsolutePath(const std::string& db_path, Status GetAbsolutePath(const std::string& db_path,
std::string* output_path) { std::string* output_path) override {
return target_->GetAbsolutePath(db_path, output_path); return target_->GetAbsolutePath(db_path, output_path);
} }
void SetBackgroundThreads(int num, Priority pri) { void SetBackgroundThreads(int num, Priority pri) override {
return target_->SetBackgroundThreads(num, pri); return target_->SetBackgroundThreads(num, pri);
} }
void IncBackgroundThreadsIfNeeded(int num, Priority pri) { void IncBackgroundThreadsIfNeeded(int num, Priority pri) override {
return target_->IncBackgroundThreadsIfNeeded(num, pri); return target_->IncBackgroundThreadsIfNeeded(num, pri);
} }
@ -842,11 +849,11 @@ class EnvWrapper : public Env {
target_->LowerThreadPoolIOPriority(pool); target_->LowerThreadPoolIOPriority(pool);
} }
std::string TimeToString(uint64_t time) { std::string TimeToString(uint64_t time) override {
return target_->TimeToString(time); return target_->TimeToString(time);
} }
Status GetThreadList(std::vector<ThreadStatus>* thread_list) { Status GetThreadList(std::vector<ThreadStatus>* thread_list) override {
return target_->GetThreadList(thread_list); return target_->GetThreadList(thread_list);
} }

@ -24,11 +24,11 @@ class StackableDB : public DB {
virtual Status CreateColumnFamily(const ColumnFamilyOptions& options, virtual Status CreateColumnFamily(const ColumnFamilyOptions& options,
const std::string& column_family_name, const std::string& column_family_name,
ColumnFamilyHandle** handle) { ColumnFamilyHandle** handle) override {
return db_->CreateColumnFamily(options, column_family_name, handle); return db_->CreateColumnFamily(options, column_family_name, handle);
} }
virtual Status DropColumnFamily(ColumnFamilyHandle* column_family) { virtual Status DropColumnFamily(ColumnFamilyHandle* column_family) override {
return db_->DropColumnFamily(column_family); return db_->DropColumnFamily(column_family);
} }
@ -92,7 +92,7 @@ class StackableDB : public DB {
virtual Status NewIterators( virtual Status NewIterators(
const ReadOptions& options, const ReadOptions& options,
const std::vector<ColumnFamilyHandle*>& column_families, const std::vector<ColumnFamilyHandle*>& column_families,
std::vector<Iterator*>* iterators) { std::vector<Iterator*>* iterators) override {
return db_->NewIterators(options, column_families, iterators); return db_->NewIterators(options, column_families, iterators);
} }
@ -221,7 +221,7 @@ class StackableDB : public DB {
return db_->DeleteFile(name); return db_->DeleteFile(name);
} }
virtual Status GetDbIdentity(std::string& identity) { virtual Status GetDbIdentity(std::string& identity) override {
return db_->GetDbIdentity(identity); return db_->GetDbIdentity(identity);
} }
@ -232,8 +232,9 @@ class StackableDB : public DB {
} }
using DB::GetPropertiesOfAllTables; using DB::GetPropertiesOfAllTables;
virtual Status GetPropertiesOfAllTables(ColumnFamilyHandle* column_family, virtual Status GetPropertiesOfAllTables(
TablePropertiesCollection* props) { ColumnFamilyHandle* column_family,
TablePropertiesCollection* props) override {
return db_->GetPropertiesOfAllTables(column_family, props); return db_->GetPropertiesOfAllTables(column_family, props);
} }

@ -21,18 +21,18 @@ 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 { virtual const char* Name() const override { return "TestHashFilter"; }
return "TestHashFilter";
}
virtual void CreateFilter(const Slice* keys, int n, std::string* dst) const { virtual void CreateFilter(const Slice* keys, int n,
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, const Slice& filter) const { virtual bool KeyMayMatch(const Slice& key,
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)) {

@ -395,13 +395,13 @@ 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 Add(const Slice& key, const Slice& value) { virtual Status Add(const Slice& key, const Slice& value) 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) { virtual 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});
@ -413,11 +413,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 { virtual const char* Name() const override {
return "BlockBasedTablePropertiesCollector"; return "BlockBasedTablePropertiesCollector";
} }
virtual UserCollectedProperties GetReadableProperties() const { virtual UserCollectedProperties GetReadableProperties() const override {
// Intentionally left blank. // Intentionally left blank.
return UserCollectedProperties(); return UserCollectedProperties();
} }

@ -22,28 +22,28 @@ class MapIterator : public Iterator {
public: public:
explicit MapIterator(const Data& data) : data_(data), pos_(data_.end()) {} explicit MapIterator(const Data& data) : data_(data), pos_(data_.end()) {}
virtual bool Valid() const { return pos_ != data_.end(); } virtual bool Valid() const override { return pos_ != data_.end(); }
virtual void SeekToFirst() { pos_ = data_.begin(); } virtual void SeekToFirst() override { pos_ = data_.begin(); }
virtual void SeekToLast() { virtual void SeekToLast() override {
pos_ = data_.end(); pos_ = data_.end();
--pos_; --pos_;
} }
virtual void Seek(const Slice& target) { virtual void Seek(const Slice& target) override {
pos_ = data_.find(target.ToString()); pos_ = data_.find(target.ToString());
} }
virtual void Next() { ++pos_; } virtual void Next() override { ++pos_; }
virtual void Prev() { --pos_; } virtual void Prev() override { --pos_; }
virtual Slice key() const { return pos_->first; } virtual Slice key() const override { return pos_->first; }
virtual Slice value() const { return pos_->second; } virtual Slice value() const override { return pos_->second; }
virtual Status status() const { return Status::OK(); } virtual Status status() const override { return Status::OK(); }
private: private:
const Data& data_; const Data& data_;

@ -62,18 +62,18 @@ class TestFilterBitsReader : public FilterBitsReader {
class TestHashFilter : public FilterPolicy { class TestHashFilter : public FilterPolicy {
public: public:
virtual const char* Name() const { virtual const char* Name() const override { return "TestHashFilter"; }
return "TestHashFilter";
}
virtual void CreateFilter(const Slice* keys, int n, std::string* dst) const { virtual void CreateFilter(const Slice* keys, int n,
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, const Slice& filter) const { virtual bool KeyMayMatch(const Slice& key,
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)) {

@ -49,15 +49,22 @@ 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 { return false; } virtual bool Valid() const override { return false; }
virtual void Seek(const Slice& target) { } virtual void Seek(const Slice& target) override {}
virtual void SeekToFirst() { } virtual void SeekToFirst() override {}
virtual void SeekToLast() { } virtual void SeekToLast() override {}
virtual void Next() { assert(false); } virtual void Next() override { assert(false); }
virtual void Prev() { assert(false); } virtual void Prev() override { assert(false); }
Slice key() const { assert(false); return Slice(); } Slice key() const override {
Slice value() const { assert(false); return Slice(); } assert(false);
virtual Status status() const { return status_; } return Slice();
}
Slice value() const override {
assert(false);
return Slice();
}
virtual Status status() const override { return status_; }
private: private:
Status status_; Status status_;
}; };

@ -81,11 +81,9 @@ class MergingIterator : public Iterator {
} }
} }
virtual bool Valid() const { virtual bool Valid() const override { return (current_ != nullptr); }
return (current_ != nullptr);
}
virtual void SeekToFirst() { virtual void SeekToFirst() override {
ClearHeaps(); ClearHeaps();
for (auto& child : children_) { for (auto& child : children_) {
child.SeekToFirst(); child.SeekToFirst();
@ -97,7 +95,7 @@ class MergingIterator : public Iterator {
direction_ = kForward; direction_ = kForward;
} }
virtual void SeekToLast() { virtual void SeekToLast() override {
ClearHeaps(); ClearHeaps();
for (auto& child : children_) { for (auto& child : children_) {
child.SeekToLast(); child.SeekToLast();
@ -109,7 +107,7 @@ class MergingIterator : public Iterator {
direction_ = kReverse; direction_ = kReverse;
} }
virtual void Seek(const Slice& target) { virtual void Seek(const Slice& target) override {
// Invalidate the heap. // Invalidate the heap.
use_heap_ = false; use_heap_ = false;
IteratorWrapper* first_child = nullptr; IteratorWrapper* first_child = nullptr;
@ -154,7 +152,7 @@ class MergingIterator : public Iterator {
direction_ = kForward; direction_ = kForward;
} }
virtual void Next() { virtual void Next() override {
assert(Valid()); assert(Valid());
// Ensure that all children are positioned after key(). // Ensure that all children are positioned after key().
@ -192,7 +190,7 @@ class MergingIterator : public Iterator {
} }
} }
virtual void Prev() { virtual 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
@ -226,17 +224,17 @@ class MergingIterator : public Iterator {
FindLargest(); FindLargest();
} }
virtual Slice key() const { virtual Slice key() const override {
assert(Valid()); assert(Valid());
return current_->key(); return current_->key();
} }
virtual Slice value() const { virtual Slice value() const override {
assert(Valid()); assert(Valid());
return current_->value(); return current_->value();
} }
virtual Status status() const { virtual Status status() const override {
Status s; Status s;
for (auto& child : children_) { for (auto& child : children_) {
s = child.status(); s = child.status();

@ -21,23 +21,23 @@ class VectorIterator : public Iterator {
std::sort(keys_.begin(), keys_.end()); std::sort(keys_.begin(), keys_.end());
} }
virtual bool Valid() const { return current_ < keys_.size(); } virtual bool Valid() const override { return current_ < keys_.size(); }
virtual void SeekToFirst() { current_ = 0; } virtual void SeekToFirst() override { current_ = 0; }
virtual void SeekToLast() { current_ = keys_.size() - 1; } virtual void SeekToLast() override { current_ = keys_.size() - 1; }
virtual void Seek(const Slice& target) { virtual void Seek(const Slice& target) override {
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 Next() { current_++; } virtual void Next() override { current_++; }
virtual void Prev() { current_--; } virtual void Prev() override { current_--; }
virtual Slice key() const { return Slice(keys_[current_]); } virtual Slice key() const override { return Slice(keys_[current_]); }
virtual Slice value() const { return Slice(); } virtual Slice value() const override { return Slice(); }
virtual Status status() const { return Status::OK(); } virtual Status status() const override { return Status::OK(); }
private: private:
std::vector<std::string> keys_; std::vector<std::string> keys_;

@ -60,23 +60,23 @@ class MockTableIterator : public Iterator {
itr_ = table_.end(); itr_ = table_.end();
} }
bool Valid() const { return itr_ != table_.end(); } bool Valid() const override { return itr_ != table_.end(); }
void SeekToFirst() { itr_ = table_.begin(); } void SeekToFirst() override { itr_ = table_.begin(); }
void SeekToLast() { void SeekToLast() override {
itr_ = table_.end(); itr_ = table_.end();
--itr_; --itr_;
} }
void Seek(const Slice& target) { void Seek(const Slice& target) override {
std::string str_target(target.data(), target.size()); std::string str_target(target.data(), target.size());
itr_ = table_.lower_bound(str_target); itr_ = table_.lower_bound(str_target);
} }
void Next() { ++itr_; } void Next() override { ++itr_; }
void Prev() { void Prev() override {
if (itr_ == table_.begin()) { if (itr_ == table_.begin()) {
itr_ = table_.end(); itr_ = table_.end();
} else { } else {
@ -84,11 +84,11 @@ class MockTableIterator : public Iterator {
} }
} }
Slice key() const { return Slice(itr_->first); } Slice key() const override { return Slice(itr_->first); }
Slice value() const { return Slice(itr_->second); } Slice value() const override { return Slice(itr_->second); }
Status status() const { return Status::OK(); } Status status() const override { return Status::OK(); }
private: private:
const MockFileContents& table_; const MockFileContents& table_;
@ -139,13 +139,13 @@ class MockTableFactory : public TableFactory {
const EnvOptions& env_options, const EnvOptions& env_options,
const InternalKeyComparator& internal_key, const InternalKeyComparator& internal_key,
unique_ptr<RandomAccessFile>&& file, uint64_t file_size, unique_ptr<RandomAccessFile>&& file, uint64_t file_size,
unique_ptr<TableReader>* table_reader) const; unique_ptr<TableReader>* table_reader) const override;
TableBuilder* NewTableBuilder( TableBuilder* NewTableBuilder(
const ImmutableCFOptions& ioptions, const ImmutableCFOptions& ioptions,
const InternalKeyComparator& internal_key, WritableFile* file, const InternalKeyComparator& internal_key, WritableFile* file,
const CompressionType compression_type, const CompressionType compression_type,
const CompressionOptions& compression_opts) const; const CompressionOptions& compression_opts) const override;
// This function will directly create mock table instead of going through // This function will directly create mock table instead of going through
// MockTableBuilder. MockFileContents has to have a format of <internal_key, // MockTableBuilder. MockFileContents has to have a format of <internal_key,
@ -153,8 +153,9 @@ class MockTableFactory : public TableFactory {
Status CreateMockTable(Env* env, const std::string& fname, Status CreateMockTable(Env* env, const std::string& fname,
MockFileContents file_contents); MockFileContents file_contents);
virtual Status SanitizeOptions(const DBOptions& db_opts, virtual Status SanitizeOptions(
const ColumnFamilyOptions& cf_opts) const { const DBOptions& db_opts,
const ColumnFamilyOptions& cf_opts) const override {
return Status::OK(); return Status::OK();
} }

@ -56,23 +56,23 @@ class PlainTableIterator : public Iterator {
explicit PlainTableIterator(PlainTableReader* table, bool use_prefix_seek); explicit PlainTableIterator(PlainTableReader* table, bool use_prefix_seek);
~PlainTableIterator(); ~PlainTableIterator();
bool Valid() const; bool Valid() const override;
void SeekToFirst(); void SeekToFirst() override;
void SeekToLast(); void SeekToLast() override;
void Seek(const Slice& target); void Seek(const Slice& target) override;
void Next(); void Next() override;
void Prev(); void Prev() override;
Slice key() const; Slice key() const override;
Slice value() const; Slice value() const override;
Status status() const; Status status() const override;
private: private:
PlainTableReader* table_; PlainTableReader* table_;

@ -64,17 +64,17 @@ class PlainTableReader: public TableReader {
Iterator* NewIterator(const ReadOptions&, Arena* arena = nullptr) override; Iterator* NewIterator(const ReadOptions&, Arena* arena = nullptr) override;
void Prepare(const Slice& target); void Prepare(const Slice& target) override;
Status Get(const ReadOptions&, const Slice& key, Status Get(const ReadOptions&, const Slice& key,
GetContext* get_context) override; GetContext* get_context) override;
uint64_t ApproximateOffsetOf(const Slice& key); uint64_t ApproximateOffsetOf(const Slice& key) override;
uint32_t GetIndexSize() const { return index_.GetIndexSize(); } uint32_t GetIndexSize() const { return index_.GetIndexSize(); }
void SetupForCompaction(); void SetupForCompaction() override;
std::shared_ptr<const TableProperties> GetTableProperties() const { std::shared_ptr<const TableProperties> GetTableProperties() const override {
return table_properties_; return table_properties_;
} }

@ -66,24 +66,23 @@ std::string Reverse(const Slice& key) {
class ReverseKeyComparator : public Comparator { class ReverseKeyComparator : public Comparator {
public: public:
virtual const char* Name() const { virtual const char* Name() const override {
return "rocksdb.ReverseBytewiseComparator"; return "rocksdb.ReverseBytewiseComparator";
} }
virtual int Compare(const Slice& a, const Slice& b) const { virtual 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( virtual void FindShortestSeparator(std::string* start,
std::string* start, const Slice& limit) const override {
const Slice& limit) const {
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 { virtual 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);
@ -122,11 +121,11 @@ class StringSink: public WritableFile {
const std::string& contents() const { return contents_; } const std::string& contents() const { return contents_; }
virtual Status Close() { return Status::OK(); } virtual Status Close() override { return Status::OK(); }
virtual Status Flush() { return Status::OK(); } virtual Status Flush() override { return Status::OK(); }
virtual Status Sync() { return Status::OK(); } virtual Status Sync() override { return Status::OK(); }
virtual Status Append(const Slice& data) { virtual Status Append(const Slice& data) override {
contents_.append(data.data(), data.size()); contents_.append(data.data(), data.size());
return Status::OK(); return Status::OK();
} }
@ -148,7 +147,7 @@ class StringSource: public RandomAccessFile {
uint64_t Size() const { return contents_.size(); } uint64_t Size() const { return contents_.size(); }
virtual Status Read(uint64_t offset, size_t n, Slice* result, virtual Status Read(uint64_t offset, size_t n, Slice* result,
char* scratch) const { char* scratch) const override {
if (offset > contents_.size()) { if (offset > contents_.size()) {
return Status::InvalidArgument("invalid Read offset"); return Status::InvalidArgument("invalid Read offset");
} }
@ -164,7 +163,7 @@ class StringSource: public RandomAccessFile {
return Status::OK(); return Status::OK();
} }
virtual size_t GetUniqueId(char* id, size_t max_size) const { virtual size_t GetUniqueId(char* id, size_t max_size) const override {
if (max_size < 20) { if (max_size < 20) {
return 0; return 0;
} }
@ -253,7 +252,7 @@ class BlockConstructor: public Constructor {
const ImmutableCFOptions& ioptions, const ImmutableCFOptions& ioptions,
const BlockBasedTableOptions& table_options, const BlockBasedTableOptions& table_options,
const InternalKeyComparator& internal_comparator, const InternalKeyComparator& internal_comparator,
const KVMap& kv_map) { const 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);
@ -269,7 +268,7 @@ class BlockConstructor: public Constructor {
block_ = new Block(std::move(contents)); block_ = new Block(std::move(contents));
return Status::OK(); return Status::OK();
} }
virtual Iterator* NewIterator() const { virtual Iterator* NewIterator() const override {
return block_->NewIterator(comparator_); return block_->NewIterator(comparator_);
} }
@ -293,19 +292,19 @@ class KeyConvertingIterator: public Iterator {
delete iter_; delete iter_;
} }
} }
virtual bool Valid() const { return iter_->Valid(); } virtual bool Valid() const override { return iter_->Valid(); }
virtual void Seek(const Slice& target) { virtual 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 SeekToFirst() { iter_->SeekToFirst(); } virtual void SeekToFirst() override { iter_->SeekToFirst(); }
virtual void SeekToLast() { iter_->SeekToLast(); } virtual void SeekToLast() override { iter_->SeekToLast(); }
virtual void Next() { iter_->Next(); } virtual void Next() override { iter_->Next(); }
virtual void Prev() { iter_->Prev(); } virtual void Prev() override { iter_->Prev(); }
virtual Slice key() const { virtual 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)) {
@ -315,8 +314,8 @@ class KeyConvertingIterator: public Iterator {
return parsed_key.user_key; return parsed_key.user_key;
} }
virtual Slice value() const { return iter_->value(); } virtual Slice value() const override { return iter_->value(); }
virtual Status status() const { virtual Status status() const override {
return status_.ok() ? iter_->status() : status_; return status_.ok() ? iter_->status() : status_;
} }
@ -342,7 +341,7 @@ class TableConstructor: public Constructor {
const ImmutableCFOptions& ioptions, const ImmutableCFOptions& ioptions,
const BlockBasedTableOptions& table_options, const BlockBasedTableOptions& table_options,
const InternalKeyComparator& internal_comparator, const InternalKeyComparator& internal_comparator,
const KVMap& kv_map) { const KVMap& kv_map) override {
Reset(); Reset();
sink_.reset(new StringSink()); sink_.reset(new StringSink());
unique_ptr<TableBuilder> builder; unique_ptr<TableBuilder> builder;
@ -375,7 +374,7 @@ class TableConstructor: public Constructor {
sink_->contents().size(), &table_reader_); sink_->contents().size(), &table_reader_);
} }
virtual Iterator* NewIterator() const { virtual Iterator* NewIterator() const override {
ReadOptions ro; ReadOptions ro;
Iterator* iter = table_reader_->NewIterator(ro); Iterator* iter = table_reader_->NewIterator(ro);
if (convert_to_internal_key_) { if (convert_to_internal_key_) {
@ -446,7 +445,7 @@ class MemTableConstructor: public Constructor {
virtual Status FinishImpl(const Options&, const ImmutableCFOptions& ioptions, virtual Status FinishImpl(const Options&, const ImmutableCFOptions& ioptions,
const BlockBasedTableOptions& table_options, const BlockBasedTableOptions& table_options,
const InternalKeyComparator& internal_comparator, const InternalKeyComparator& internal_comparator,
const KVMap& kv_map) { const 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,
@ -460,7 +459,7 @@ class MemTableConstructor: public Constructor {
} }
return Status::OK(); return Status::OK();
} }
virtual Iterator* NewIterator() const { virtual Iterator* NewIterator() const override {
return new KeyConvertingIterator( return new KeyConvertingIterator(
memtable_->NewIterator(ReadOptions(), &arena_), true); memtable_->NewIterator(ReadOptions(), &arena_), true);
} }
@ -493,7 +492,7 @@ class DBConstructor: public Constructor {
const ImmutableCFOptions& ioptions, const ImmutableCFOptions& ioptions,
const BlockBasedTableOptions& table_options, const BlockBasedTableOptions& table_options,
const InternalKeyComparator& internal_comparator, const InternalKeyComparator& internal_comparator,
const KVMap& kv_map) { const KVMap& kv_map) override {
delete db_; delete db_;
db_ = nullptr; db_ = nullptr;
NewDB(); NewDB();
@ -504,11 +503,11 @@ class DBConstructor: public Constructor {
} }
return Status::OK(); return Status::OK();
} }
virtual Iterator* NewIterator() const { virtual Iterator* NewIterator() const override {
return db_->NewIterator(ReadOptions()); return db_->NewIterator(ReadOptions());
} }
virtual DB* db() const { return db_; } virtual DB* db() const override { return db_; }
private: private:
void NewDB() { void NewDB() {
@ -679,11 +678,9 @@ class FixedOrLessPrefixTransform : public SliceTransform {
prefix_len_(prefix_len) { prefix_len_(prefix_len) {
} }
virtual const char* Name() const { virtual const char* Name() const override { return "rocksdb.FixedPrefix"; }
return "rocksdb.FixedPrefix";
}
virtual Slice Transform(const Slice& src) const { virtual 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;
@ -691,11 +688,9 @@ class FixedOrLessPrefixTransform : public SliceTransform {
return Slice(src.data(), prefix_len_); return Slice(src.data(), prefix_len_);
} }
virtual bool InDomain(const Slice& src) const { virtual bool InDomain(const Slice& src) const override { return true; }
return true;
}
virtual bool InRange(const Slice& dst) const { virtual bool InRange(const Slice& dst) const override {
return (dst.size() <= prefix_len_); return (dst.size() <= prefix_len_);
} }
}; };

@ -29,24 +29,22 @@ class TwoLevelIterator: public Iterator {
second_level_iter_.DeleteIter(false); second_level_iter_.DeleteIter(false);
} }
virtual void Seek(const Slice& target); virtual void Seek(const Slice& target) override;
virtual void SeekToFirst(); virtual void SeekToFirst() override;
virtual void SeekToLast(); virtual void SeekToLast() override;
virtual void Next(); virtual void Next() override;
virtual void Prev(); virtual void Prev() override;
virtual bool Valid() const { virtual bool Valid() const override { return second_level_iter_.Valid(); }
return second_level_iter_.Valid(); virtual Slice key() const override {
}
virtual Slice key() const {
assert(Valid()); assert(Valid());
return second_level_iter_.key(); return second_level_iter_.key();
} }
virtual Slice value() const { virtual Slice value() const override {
assert(Valid()); assert(Valid());
return second_level_iter_.value(); return second_level_iter_.value();
} }
virtual Status status() const { virtual Status status() const override {
// It'd be nice if status() returned a const Status& instead of a Status // It'd be nice if status() returned a const Status& instead of a Status
if (!first_level_iter_.status().ok()) { if (!first_level_iter_.status().ok()) {
return first_level_iter_.status(); return first_level_iter_.status();

@ -85,12 +85,12 @@ class SanityTest {
class SanityTestBasic : public SanityTest { class SanityTestBasic : public SanityTest {
public: public:
explicit SanityTestBasic(const std::string& path) : SanityTest(path) {} explicit SanityTestBasic(const std::string& path) : SanityTest(path) {}
virtual Options GetOptions() const { virtual Options GetOptions() const override {
Options options; Options options;
options.create_if_missing = true; options.create_if_missing = true;
return options; return options;
} }
virtual std::string Name() const { return "Basic"; } virtual std::string Name() const override { return "Basic"; }
}; };
class SanityTestSpecialComparator : public SanityTest { class SanityTestSpecialComparator : public SanityTest {
@ -100,20 +100,23 @@ class SanityTestSpecialComparator : public SanityTest {
options_.comparator = new NewComparator(); options_.comparator = new NewComparator();
} }
~SanityTestSpecialComparator() { delete options_.comparator; } ~SanityTestSpecialComparator() { delete options_.comparator; }
virtual Options GetOptions() const { return options_; } virtual Options GetOptions() const override { return options_; }
virtual std::string Name() const { return "SpecialComparator"; } virtual std::string Name() const override { return "SpecialComparator"; }
private: private:
class NewComparator : public Comparator { class NewComparator : public Comparator {
public: public:
virtual const char* Name() const { return "rocksdb.NewComparator"; } virtual const char* Name() const override {
virtual int Compare(const Slice& a, const Slice& b) const { return "rocksdb.NewComparator";
}
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, const Slice& l) const { virtual void FindShortestSeparator(std::string* s,
const Slice& l) const override {
BytewiseComparator()->FindShortestSeparator(s, l); BytewiseComparator()->FindShortestSeparator(s, l);
} }
virtual void FindShortSuccessor(std::string* key) const { virtual void FindShortSuccessor(std::string* key) const override {
BytewiseComparator()->FindShortSuccessor(key); BytewiseComparator()->FindShortSuccessor(key);
} }
}; };
@ -126,8 +129,8 @@ class SanityTestZlibCompression : public SanityTest {
: SanityTest(path) { : SanityTest(path) {
options_.compression = kZlibCompression; options_.compression = kZlibCompression;
} }
virtual Options GetOptions() const { return options_; } virtual Options GetOptions() const override { return options_; }
virtual std::string Name() const { return "ZlibCompression"; } virtual std::string Name() const override { return "ZlibCompression"; }
private: private:
Options options_; Options options_;
@ -142,8 +145,10 @@ class SanityTestZlibCompressionVersion2 : public SanityTest {
table_options.format_version = 2; table_options.format_version = 2;
options_.table_factory.reset(NewBlockBasedTableFactory(table_options)); options_.table_factory.reset(NewBlockBasedTableFactory(table_options));
} }
virtual Options GetOptions() const { return options_; } virtual Options GetOptions() const override { return options_; }
virtual std::string Name() const { return "ZlibCompressionVersion2"; } virtual std::string Name() const override {
return "ZlibCompressionVersion2";
}
private: private:
Options options_; Options options_;
@ -155,8 +160,8 @@ class SanityTestLZ4Compression : public SanityTest {
: SanityTest(path) { : SanityTest(path) {
options_.compression = kLZ4Compression; options_.compression = kLZ4Compression;
} }
virtual Options GetOptions() const { return options_; } virtual Options GetOptions() const override { return options_; }
virtual std::string Name() const { return "LZ4Compression"; } virtual std::string Name() const override { return "LZ4Compression"; }
private: private:
Options options_; Options options_;
@ -168,8 +173,8 @@ class SanityTestLZ4HCCompression : public SanityTest {
: SanityTest(path) { : SanityTest(path) {
options_.compression = kLZ4HCCompression; options_.compression = kLZ4HCCompression;
} }
virtual Options GetOptions() const { return options_; } virtual Options GetOptions() const override { return options_; }
virtual std::string Name() const { return "LZ4HCCompression"; } virtual std::string Name() const override { return "LZ4HCCompression"; }
private: private:
Options options_; Options options_;
@ -185,8 +190,8 @@ class SanityTestPlainTableFactory : public SanityTest {
options_.allow_mmap_reads = true; options_.allow_mmap_reads = true;
} }
~SanityTestPlainTableFactory() {} ~SanityTestPlainTableFactory() {}
virtual Options GetOptions() const { return options_; } virtual Options GetOptions() const override { return options_; }
virtual std::string Name() const { return "PlainTable"; } virtual std::string Name() const override { return "PlainTable"; }
private: private:
Options options_; Options options_;
@ -201,8 +206,8 @@ class SanityTestBloomFilter : public SanityTest {
options_.table_factory.reset(NewBlockBasedTableFactory(table_options)); options_.table_factory.reset(NewBlockBasedTableFactory(table_options));
} }
~SanityTestBloomFilter() {} ~SanityTestBloomFilter() {}
virtual Options GetOptions() const { return options_; } virtual Options GetOptions() const override { return options_; }
virtual std::string Name() const { return "BloomFilter"; } virtual std::string Name() const override { return "BloomFilter"; }
private: private:
Options options_; Options options_;

@ -41,7 +41,7 @@ class AutoRollLogger : public Logger {
} }
using Logger::Logv; using Logger::Logv;
void Logv(const char* format, va_list ap); void Logv(const char* format, va_list ap) override;
// Write a header entry to the log. All header information will be written // Write a header entry to the log. All header information will be written
// again every time the log rolls over. // again every time the log rolls over.
@ -52,11 +52,9 @@ class AutoRollLogger : public Logger {
return status_; return status_;
} }
size_t GetLogFileSize() const { size_t GetLogFileSize() const override { return logger_->GetLogFileSize(); }
return logger_->GetLogFileSize();
}
void Flush() { void Flush() override {
if (logger_) { if (logger_) {
logger_->Flush(); logger_->Flush();
} }

@ -471,34 +471,33 @@ class ShardedLRUCache : public Cache {
delete[] shards_; delete[] shards_;
} }
virtual Handle* Insert(const Slice& key, void* value, size_t charge, virtual Handle* Insert(const Slice& key, void* value, size_t charge,
void (*deleter)(const Slice& key, void* value)) { void (*deleter)(const Slice& key,
void* value)) override {
const uint32_t hash = HashSlice(key); const uint32_t hash = HashSlice(key);
return shards_[Shard(hash)].Insert(key, hash, value, charge, deleter); return shards_[Shard(hash)].Insert(key, hash, value, charge, deleter);
} }
virtual Handle* Lookup(const Slice& key) { virtual Handle* Lookup(const Slice& key) override {
const uint32_t hash = HashSlice(key); const uint32_t hash = HashSlice(key);
return shards_[Shard(hash)].Lookup(key, hash); return shards_[Shard(hash)].Lookup(key, hash);
} }
virtual void Release(Handle* handle) { virtual void Release(Handle* handle) override {
LRUHandle* h = reinterpret_cast<LRUHandle*>(handle); LRUHandle* h = reinterpret_cast<LRUHandle*>(handle);
shards_[Shard(h->hash)].Release(handle); shards_[Shard(h->hash)].Release(handle);
} }
virtual void Erase(const Slice& key) { virtual void Erase(const Slice& key) override {
const uint32_t hash = HashSlice(key); const uint32_t hash = HashSlice(key);
shards_[Shard(hash)].Erase(key, hash); shards_[Shard(hash)].Erase(key, hash);
} }
virtual void* Value(Handle* handle) { virtual void* Value(Handle* handle) override {
return reinterpret_cast<LRUHandle*>(handle)->value; return reinterpret_cast<LRUHandle*>(handle)->value;
} }
virtual uint64_t NewId() { virtual uint64_t NewId() override {
MutexLock l(&id_mutex_); MutexLock l(&id_mutex_);
return ++(last_id_); return ++(last_id_);
} }
virtual size_t GetCapacity() const { virtual size_t GetCapacity() const override { return capacity_; }
return capacity_;
}
virtual size_t GetUsage() const { virtual size_t GetUsage() const override {
// We will not lock the cache when getting the usage from shards. // We will not lock the cache when getting the usage from shards.
// for (size_t i = 0; i < num_shard_bits_; ++i) // for (size_t i = 0; i < num_shard_bits_; ++i)
int num_shards = 1 << num_shard_bits_; int num_shards = 1 << num_shard_bits_;
@ -509,9 +508,7 @@ class ShardedLRUCache : public Cache {
return usage; return usage;
} }
virtual void DisownData() { virtual void DisownData() override { shards_ = nullptr; }
shards_ = nullptr;
}
virtual void ApplyToAllCacheEntries(void (*callback)(void*, size_t), virtual void ApplyToAllCacheEntries(void (*callback)(void*, size_t),
bool thread_safe) override { bool thread_safe) override {

@ -23,17 +23,16 @@ class BytewiseComparatorImpl : public Comparator {
public: public:
BytewiseComparatorImpl() { } BytewiseComparatorImpl() { }
virtual const char* Name() const { virtual const char* Name() const override {
return "leveldb.BytewiseComparator"; return "leveldb.BytewiseComparator";
} }
virtual int Compare(const Slice& a, const Slice& b) const { virtual int Compare(const Slice& a, const Slice& b) const override {
return a.compare(b); return a.compare(b);
} }
virtual void FindShortestSeparator( virtual void FindShortestSeparator(std::string* start,
std::string* start, const Slice& limit) const override {
const Slice& limit) const {
// 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;
@ -55,7 +54,7 @@ class BytewiseComparatorImpl : public Comparator {
} }
} }
virtual void FindShortSuccessor(std::string* key) const { virtual 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++) {
@ -74,11 +73,11 @@ class ReverseBytewiseComparatorImpl : public BytewiseComparatorImpl {
public: public:
ReverseBytewiseComparatorImpl() { } ReverseBytewiseComparatorImpl() { }
virtual const char* Name() const { virtual const char* Name() const override {
return "rocksdb.ReverseBytewiseComparator"; return "rocksdb.ReverseBytewiseComparator";
} }
virtual int Compare(const Slice& a, const Slice& b) const { virtual int Compare(const Slice& a, const Slice& b) const override {
return -a.compare(b); return -a.compare(b);
} }
}; };

@ -179,7 +179,7 @@ class PosixSequentialFile: public SequentialFile {
} }
virtual ~PosixSequentialFile() { fclose(file_); } virtual ~PosixSequentialFile() { fclose(file_); }
virtual Status Read(size_t n, Slice* result, char* scratch) { virtual Status Read(size_t n, Slice* result, char* scratch) override {
Status s; Status s;
size_t r = 0; size_t r = 0;
do { do {
@ -206,14 +206,14 @@ class PosixSequentialFile: public SequentialFile {
return s; return s;
} }
virtual Status Skip(uint64_t n) { virtual Status Skip(uint64_t n) override {
if (fseek(file_, static_cast<long int>(n), SEEK_CUR)) { if (fseek(file_, static_cast<long int>(n), SEEK_CUR)) {
return IOError(filename_, errno); return IOError(filename_, errno);
} }
return Status::OK(); return Status::OK();
} }
virtual Status InvalidateCache(size_t offset, size_t length) { virtual Status InvalidateCache(size_t offset, size_t length) override {
#ifndef OS_LINUX #ifndef OS_LINUX
return Status::OK(); return Status::OK();
#else #else
@ -243,7 +243,7 @@ class PosixRandomAccessFile: public RandomAccessFile {
virtual ~PosixRandomAccessFile() { close(fd_); } virtual ~PosixRandomAccessFile() { close(fd_); }
virtual Status Read(uint64_t offset, size_t n, Slice* result, virtual Status Read(uint64_t offset, size_t n, Slice* result,
char* scratch) const { char* scratch) const override {
Status s; Status s;
ssize_t r = -1; ssize_t r = -1;
size_t left = n; size_t left = n;
@ -276,12 +276,12 @@ class PosixRandomAccessFile: public RandomAccessFile {
} }
#ifdef OS_LINUX #ifdef OS_LINUX
virtual size_t GetUniqueId(char* id, size_t max_size) const { virtual size_t GetUniqueId(char* id, size_t max_size) const override {
return GetUniqueIdFromFile(fd_, id, max_size); return GetUniqueIdFromFile(fd_, id, max_size);
} }
#endif #endif
virtual void Hint(AccessPattern pattern) { virtual void Hint(AccessPattern pattern) override {
switch(pattern) { switch(pattern) {
case NORMAL: case NORMAL:
Fadvise(fd_, 0, 0, POSIX_FADV_NORMAL); Fadvise(fd_, 0, 0, POSIX_FADV_NORMAL);
@ -304,7 +304,7 @@ class PosixRandomAccessFile: public RandomAccessFile {
} }
} }
virtual Status InvalidateCache(size_t offset, size_t length) { virtual Status InvalidateCache(size_t offset, size_t length) override {
#ifndef OS_LINUX #ifndef OS_LINUX
return Status::OK(); return Status::OK();
#else #else
@ -345,7 +345,7 @@ class PosixMmapReadableFile: public RandomAccessFile {
} }
virtual Status Read(uint64_t offset, size_t n, Slice* result, virtual Status Read(uint64_t offset, size_t n, Slice* result,
char* scratch) const { char* scratch) const override {
Status s; Status s;
if (offset + n > length_) { if (offset + n > length_) {
*result = Slice(); *result = Slice();
@ -355,7 +355,7 @@ class PosixMmapReadableFile: public RandomAccessFile {
} }
return s; return s;
} }
virtual Status InvalidateCache(size_t offset, size_t length) { virtual Status InvalidateCache(size_t offset, size_t length) override {
#ifndef OS_LINUX #ifndef OS_LINUX
return Status::OK(); return Status::OK();
#else #else
@ -488,7 +488,7 @@ class PosixMmapFile : public WritableFile {
} }
} }
virtual Status Append(const Slice& data) { virtual Status Append(const Slice& data) override {
const char* src = data.data(); const char* src = data.data();
size_t left = data.size(); size_t left = data.size();
TEST_KILL_RANDOM(rocksdb_kill_odds * REDUCE_ODDS); TEST_KILL_RANDOM(rocksdb_kill_odds * REDUCE_ODDS);
@ -520,7 +520,7 @@ class PosixMmapFile : public WritableFile {
return Status::OK(); return Status::OK();
} }
virtual Status Close() { virtual Status Close() override {
Status s; Status s;
size_t unused = limit_ - dst_; size_t unused = limit_ - dst_;
@ -550,12 +550,12 @@ class PosixMmapFile : public WritableFile {
return s; return s;
} }
virtual Status Flush() { virtual Status Flush() override {
TEST_KILL_RANDOM(rocksdb_kill_odds); TEST_KILL_RANDOM(rocksdb_kill_odds);
return Status::OK(); return Status::OK();
} }
virtual Status Sync() { virtual Status Sync() override {
Status s; Status s;
if (pending_sync_) { if (pending_sync_) {
@ -587,7 +587,7 @@ class PosixMmapFile : public WritableFile {
/** /**
* Flush data as well as metadata to stable storage. * Flush data as well as metadata to stable storage.
*/ */
virtual Status Fsync() { virtual Status Fsync() override {
if (pending_sync_) { if (pending_sync_) {
// Some unmapped data was not synced // Some unmapped data was not synced
TEST_KILL_RANDOM(rocksdb_kill_odds); TEST_KILL_RANDOM(rocksdb_kill_odds);
@ -607,12 +607,12 @@ class PosixMmapFile : public WritableFile {
* size that is returned from the filesystem because we use mmap * size that is returned from the filesystem because we use mmap
* to extend file by map_size every time. * to extend file by map_size every time.
*/ */
virtual uint64_t GetFileSize() { virtual uint64_t GetFileSize() override {
size_t used = dst_ - base_; size_t used = dst_ - base_;
return file_offset_ + used; return file_offset_ + used;
} }
virtual Status InvalidateCache(size_t offset, size_t length) { virtual Status InvalidateCache(size_t offset, size_t length) override {
#ifndef OS_LINUX #ifndef OS_LINUX
return Status::OK(); return Status::OK();
#else #else
@ -626,7 +626,7 @@ class PosixMmapFile : public WritableFile {
} }
#ifdef ROCKSDB_FALLOCATE_PRESENT #ifdef ROCKSDB_FALLOCATE_PRESENT
virtual Status Allocate(off_t offset, off_t len) { virtual Status Allocate(off_t offset, off_t len) override {
TEST_KILL_RANDOM(rocksdb_kill_odds); TEST_KILL_RANDOM(rocksdb_kill_odds);
int alloc_status = fallocate( int alloc_status = fallocate(
fd_, fallocate_with_keep_size_ ? FALLOC_FL_KEEP_SIZE : 0, offset, len); fd_, fallocate_with_keep_size_ ? FALLOC_FL_KEEP_SIZE : 0, offset, len);
@ -683,7 +683,7 @@ class PosixWritableFile : public WritableFile {
} }
} }
virtual Status Append(const Slice& data) { virtual Status Append(const Slice& data) override {
const char* src = data.data(); const char* src = data.data();
size_t left = data.size(); size_t left = data.size();
Status s; Status s;
@ -732,7 +732,7 @@ class PosixWritableFile : public WritableFile {
return Status::OK(); return Status::OK();
} }
virtual Status Close() { virtual Status Close() override {
Status s; Status s;
s = Flush(); // flush cache to OS s = Flush(); // flush cache to OS
if (!s.ok()) { if (!s.ok()) {
@ -775,7 +775,7 @@ class PosixWritableFile : public WritableFile {
} }
// write out the cached data to the OS cache // write out the cached data to the OS cache
virtual Status Flush() { virtual Status Flush() override {
TEST_KILL_RANDOM(rocksdb_kill_odds * REDUCE_ODDS2); TEST_KILL_RANDOM(rocksdb_kill_odds * REDUCE_ODDS2);
size_t left = cursize_; size_t left = cursize_;
char* src = buf_.get(); char* src = buf_.get();
@ -807,7 +807,7 @@ class PosixWritableFile : public WritableFile {
return Status::OK(); return Status::OK();
} }
virtual Status Sync() { virtual Status Sync() override {
Status s = Flush(); Status s = Flush();
if (!s.ok()) { if (!s.ok()) {
return s; return s;
@ -821,7 +821,7 @@ class PosixWritableFile : public WritableFile {
return Status::OK(); return Status::OK();
} }
virtual Status Fsync() { virtual Status Fsync() override {
Status s = Flush(); Status s = Flush();
if (!s.ok()) { if (!s.ok()) {
return s; return s;
@ -836,11 +836,9 @@ class PosixWritableFile : public WritableFile {
return Status::OK(); return Status::OK();
} }
virtual uint64_t GetFileSize() { virtual uint64_t GetFileSize() override { return filesize_; }
return filesize_;
}
virtual Status InvalidateCache(size_t offset, size_t length) { virtual Status InvalidateCache(size_t offset, size_t length) override {
#ifndef OS_LINUX #ifndef OS_LINUX
return Status::OK(); return Status::OK();
#else #else
@ -854,7 +852,7 @@ class PosixWritableFile : public WritableFile {
} }
#ifdef ROCKSDB_FALLOCATE_PRESENT #ifdef ROCKSDB_FALLOCATE_PRESENT
virtual Status Allocate(off_t offset, off_t len) { virtual Status Allocate(off_t offset, off_t len) override {
TEST_KILL_RANDOM(rocksdb_kill_odds); TEST_KILL_RANDOM(rocksdb_kill_odds);
int alloc_status = fallocate( int alloc_status = fallocate(
fd_, fallocate_with_keep_size_ ? FALLOC_FL_KEEP_SIZE : 0, offset, len); fd_, fallocate_with_keep_size_ ? FALLOC_FL_KEEP_SIZE : 0, offset, len);
@ -865,14 +863,14 @@ class PosixWritableFile : public WritableFile {
} }
} }
virtual Status RangeSync(off_t offset, off_t nbytes) { virtual Status RangeSync(off_t offset, off_t nbytes) override {
if (sync_file_range(fd_, offset, nbytes, SYNC_FILE_RANGE_WRITE) == 0) { if (sync_file_range(fd_, offset, nbytes, SYNC_FILE_RANGE_WRITE) == 0) {
return Status::OK(); return Status::OK();
} else { } else {
return IOError(filename_, errno); return IOError(filename_, errno);
} }
} }
virtual size_t GetUniqueId(char* id, size_t max_size) const { virtual size_t GetUniqueId(char* id, size_t max_size) const override {
return GetUniqueIdFromFile(fd_, id, max_size); return GetUniqueIdFromFile(fd_, id, max_size);
} }
#endif #endif
@ -916,7 +914,7 @@ class PosixRandomRWFile : public RandomRWFile {
} }
} }
virtual Status Write(uint64_t offset, const Slice& data) { virtual Status Write(uint64_t offset, const Slice& data) override {
const char* src = data.data(); const char* src = data.data();
size_t left = data.size(); size_t left = data.size();
Status s; Status s;
@ -942,7 +940,7 @@ class PosixRandomRWFile : public RandomRWFile {
} }
virtual Status Read(uint64_t offset, size_t n, Slice* result, virtual Status Read(uint64_t offset, size_t n, Slice* result,
char* scratch) const { char* scratch) const override {
Status s; Status s;
ssize_t r = -1; ssize_t r = -1;
size_t left = n; size_t left = n;
@ -967,7 +965,7 @@ class PosixRandomRWFile : public RandomRWFile {
return s; return s;
} }
virtual Status Close() { virtual Status Close() override {
Status s = Status::OK(); Status s = Status::OK();
if (fd_ >= 0 && close(fd_) < 0) { if (fd_ >= 0 && close(fd_) < 0) {
s = IOError(filename_, errno); s = IOError(filename_, errno);
@ -976,7 +974,7 @@ class PosixRandomRWFile : public RandomRWFile {
return s; return s;
} }
virtual Status Sync() { virtual Status Sync() override {
if (pending_sync_ && fdatasync(fd_) < 0) { if (pending_sync_ && fdatasync(fd_) < 0) {
return IOError(filename_, errno); return IOError(filename_, errno);
} }
@ -984,7 +982,7 @@ class PosixRandomRWFile : public RandomRWFile {
return Status::OK(); return Status::OK();
} }
virtual Status Fsync() { virtual Status Fsync() override {
if (pending_fsync_ && fsync(fd_) < 0) { if (pending_fsync_ && fsync(fd_) < 0) {
return IOError(filename_, errno); return IOError(filename_, errno);
} }
@ -994,7 +992,7 @@ class PosixRandomRWFile : public RandomRWFile {
} }
#ifdef ROCKSDB_FALLOCATE_PRESENT #ifdef ROCKSDB_FALLOCATE_PRESENT
virtual Status Allocate(off_t offset, off_t len) { virtual Status Allocate(off_t offset, off_t len) override {
TEST_KILL_RANDOM(rocksdb_kill_odds); TEST_KILL_RANDOM(rocksdb_kill_odds);
int alloc_status = fallocate( int alloc_status = fallocate(
fd_, fallocate_with_keep_size_ ? FALLOC_FL_KEEP_SIZE : 0, offset, len); fd_, fallocate_with_keep_size_ ? FALLOC_FL_KEEP_SIZE : 0, offset, len);
@ -1014,7 +1012,7 @@ class PosixDirectory : public Directory {
close(fd_); close(fd_);
} }
virtual Status Fsync() { virtual Status Fsync() override {
if (fsync(fd_) == -1) { if (fsync(fd_) == -1) {
return IOError("directory", errno); return IOError("directory", errno);
} }
@ -1100,7 +1098,7 @@ class PosixEnv : public Env {
virtual Status NewSequentialFile(const std::string& fname, virtual Status NewSequentialFile(const std::string& fname,
unique_ptr<SequentialFile>* result, unique_ptr<SequentialFile>* result,
const EnvOptions& options) { const EnvOptions& options) override {
result->reset(); result->reset();
FILE* f = nullptr; FILE* f = nullptr;
do { do {
@ -1119,7 +1117,7 @@ class PosixEnv : public Env {
virtual Status NewRandomAccessFile(const std::string& fname, virtual Status NewRandomAccessFile(const std::string& fname,
unique_ptr<RandomAccessFile>* result, unique_ptr<RandomAccessFile>* result,
const EnvOptions& options) { const EnvOptions& options) override {
result->reset(); result->reset();
Status s; Status s;
int fd = open(fname.c_str(), O_RDONLY); int fd = open(fname.c_str(), O_RDONLY);
@ -1150,7 +1148,7 @@ class PosixEnv : public Env {
virtual Status NewWritableFile(const std::string& fname, virtual Status NewWritableFile(const std::string& fname,
unique_ptr<WritableFile>* result, unique_ptr<WritableFile>* result,
const EnvOptions& options) { const EnvOptions& options) override {
result->reset(); result->reset();
Status s; Status s;
int fd = -1; int fd = -1;
@ -1188,7 +1186,7 @@ class PosixEnv : public Env {
virtual Status NewRandomRWFile(const std::string& fname, virtual Status NewRandomRWFile(const std::string& fname,
unique_ptr<RandomRWFile>* result, unique_ptr<RandomRWFile>* result,
const EnvOptions& options) { const EnvOptions& options) override {
result->reset(); result->reset();
// no support for mmap yet // no support for mmap yet
if (options.use_mmap_writes || options.use_mmap_reads) { if (options.use_mmap_writes || options.use_mmap_reads) {
@ -1206,7 +1204,7 @@ class PosixEnv : public Env {
} }
virtual Status NewDirectory(const std::string& name, virtual Status NewDirectory(const std::string& name,
unique_ptr<Directory>* result) { unique_ptr<Directory>* result) override {
result->reset(); result->reset();
const int fd = open(name.c_str(), 0); const int fd = open(name.c_str(), 0);
if (fd < 0) { if (fd < 0) {
@ -1217,12 +1215,12 @@ class PosixEnv : public Env {
return Status::OK(); return Status::OK();
} }
virtual bool FileExists(const std::string& fname) { virtual bool FileExists(const std::string& fname) override {
return access(fname.c_str(), F_OK) == 0; return access(fname.c_str(), F_OK) == 0;
} }
virtual Status GetChildren(const std::string& dir, virtual Status GetChildren(const std::string& dir,
std::vector<std::string>* result) { std::vector<std::string>* result) override {
result->clear(); result->clear();
DIR* d = opendir(dir.c_str()); DIR* d = opendir(dir.c_str());
if (d == nullptr) { if (d == nullptr) {
@ -1236,7 +1234,7 @@ class PosixEnv : public Env {
return Status::OK(); return Status::OK();
} }
virtual Status DeleteFile(const std::string& fname) { virtual Status DeleteFile(const std::string& fname) override {
Status result; Status result;
if (unlink(fname.c_str()) != 0) { if (unlink(fname.c_str()) != 0) {
result = IOError(fname, errno); result = IOError(fname, errno);
@ -1244,7 +1242,7 @@ class PosixEnv : public Env {
return result; return result;
}; };
virtual Status CreateDir(const std::string& name) { virtual Status CreateDir(const std::string& name) override {
Status result; Status result;
if (mkdir(name.c_str(), 0755) != 0) { if (mkdir(name.c_str(), 0755) != 0) {
result = IOError(name, errno); result = IOError(name, errno);
@ -1252,7 +1250,7 @@ class PosixEnv : public Env {
return result; return result;
}; };
virtual Status CreateDirIfMissing(const std::string& name) { virtual Status CreateDirIfMissing(const std::string& name) override {
Status result; Status result;
if (mkdir(name.c_str(), 0755) != 0) { if (mkdir(name.c_str(), 0755) != 0) {
if (errno != EEXIST) { if (errno != EEXIST) {
@ -1266,7 +1264,7 @@ class PosixEnv : public Env {
return result; return result;
}; };
virtual Status DeleteDir(const std::string& name) { virtual Status DeleteDir(const std::string& name) override {
Status result; Status result;
if (rmdir(name.c_str()) != 0) { if (rmdir(name.c_str()) != 0) {
result = IOError(name, errno); result = IOError(name, errno);
@ -1274,7 +1272,8 @@ class PosixEnv : public Env {
return result; return result;
}; };
virtual Status GetFileSize(const std::string& fname, uint64_t* size) { virtual Status GetFileSize(const std::string& fname,
uint64_t* size) override {
Status s; Status s;
struct stat sbuf; struct stat sbuf;
if (stat(fname.c_str(), &sbuf) != 0) { if (stat(fname.c_str(), &sbuf) != 0) {
@ -1287,7 +1286,7 @@ class PosixEnv : public Env {
} }
virtual Status GetFileModificationTime(const std::string& fname, virtual Status GetFileModificationTime(const std::string& fname,
uint64_t* file_mtime) { uint64_t* file_mtime) override {
struct stat s; struct stat s;
if (stat(fname.c_str(), &s) !=0) { if (stat(fname.c_str(), &s) !=0) {
return IOError(fname, errno); return IOError(fname, errno);
@ -1295,7 +1294,8 @@ class PosixEnv : public Env {
*file_mtime = static_cast<uint64_t>(s.st_mtime); *file_mtime = static_cast<uint64_t>(s.st_mtime);
return Status::OK(); return Status::OK();
} }
virtual Status RenameFile(const std::string& src, const std::string& target) { virtual Status RenameFile(const std::string& src,
const std::string& target) override {
Status result; Status result;
if (rename(src.c_str(), target.c_str()) != 0) { if (rename(src.c_str(), target.c_str()) != 0) {
result = IOError(src, errno); result = IOError(src, errno);
@ -1303,7 +1303,8 @@ class PosixEnv : public Env {
return result; return result;
} }
virtual Status LinkFile(const std::string& src, const std::string& target) { virtual Status LinkFile(const std::string& src,
const std::string& target) override {
Status result; Status result;
if (link(src.c_str(), target.c_str()) != 0) { if (link(src.c_str(), target.c_str()) != 0) {
if (errno == EXDEV) { if (errno == EXDEV) {
@ -1314,7 +1315,7 @@ class PosixEnv : public Env {
return result; return result;
} }
virtual Status LockFile(const std::string& fname, FileLock** lock) { virtual Status LockFile(const std::string& fname, FileLock** lock) override {
*lock = nullptr; *lock = nullptr;
Status result; Status result;
int fd = open(fname.c_str(), O_RDWR | O_CREAT, 0644); int fd = open(fname.c_str(), O_RDWR | O_CREAT, 0644);
@ -1333,7 +1334,7 @@ class PosixEnv : public Env {
return result; return result;
} }
virtual Status UnlockFile(FileLock* lock) { virtual Status UnlockFile(FileLock* lock) override {
PosixFileLock* my_lock = reinterpret_cast<PosixFileLock*>(lock); PosixFileLock* my_lock = reinterpret_cast<PosixFileLock*>(lock);
Status result; Status result;
if (LockOrUnlock(my_lock->filename, my_lock->fd_, false) == -1) { if (LockOrUnlock(my_lock->filename, my_lock->fd_, false) == -1) {
@ -1344,15 +1345,16 @@ class PosixEnv : public Env {
return result; return result;
} }
virtual void Schedule(void (*function)(void*), void* arg, Priority pri = LOW); virtual void Schedule(void (*function)(void*), void* arg,
Priority pri = LOW) override;
virtual void StartThread(void (*function)(void* arg), void* arg); virtual void StartThread(void (*function)(void* arg), void* arg) override;
virtual void WaitForJoin(); virtual void WaitForJoin() override;
virtual unsigned int GetThreadPoolQueueLen(Priority pri = LOW) const override; virtual unsigned int GetThreadPoolQueueLen(Priority pri = LOW) const override;
virtual Status GetTestDirectory(std::string* result) { virtual Status GetTestDirectory(std::string* result) override {
const char* env = getenv("TEST_TMPDIR"); const char* env = getenv("TEST_TMPDIR");
if (env && env[0] != '\0') { if (env && env[0] != '\0') {
*result = env; *result = env;
@ -1384,7 +1386,7 @@ class PosixEnv : public Env {
} }
virtual Status NewLogger(const std::string& fname, virtual Status NewLogger(const std::string& fname,
shared_ptr<Logger>* result) { shared_ptr<Logger>* result) override {
FILE* f = fopen(fname.c_str(), "w"); FILE* f = fopen(fname.c_str(), "w");
if (f == nullptr) { if (f == nullptr) {
result->reset(); result->reset();
@ -1397,21 +1399,19 @@ class PosixEnv : public Env {
} }
} }
virtual uint64_t NowMicros() { virtual uint64_t NowMicros() override {
return std::chrono::duration_cast<std::chrono::microseconds>( return std::chrono::duration_cast<std::chrono::microseconds>(
std::chrono::system_clock::now().time_since_epoch()).count(); std::chrono::system_clock::now().time_since_epoch()).count();
} }
virtual uint64_t NowNanos() { virtual uint64_t NowNanos() override {
return std::chrono::duration_cast<std::chrono::nanoseconds>( return std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::steady_clock::now().time_since_epoch()).count(); std::chrono::steady_clock::now().time_since_epoch()).count();
} }
virtual void SleepForMicroseconds(int micros) { virtual void SleepForMicroseconds(int micros) override { usleep(micros); }
usleep(micros);
}
virtual Status GetHostName(char* name, uint64_t len) { virtual Status GetHostName(char* name, uint64_t len) override {
int ret = gethostname(name, static_cast<size_t>(len)); int ret = gethostname(name, static_cast<size_t>(len));
if (ret < 0) { if (ret < 0) {
if (errno == EFAULT || errno == EINVAL) if (errno == EFAULT || errno == EINVAL)
@ -1422,7 +1422,7 @@ class PosixEnv : public Env {
return Status::OK(); return Status::OK();
} }
virtual Status GetCurrentTime(int64_t* unix_time) { virtual Status GetCurrentTime(int64_t* unix_time) override {
time_t ret = time(nullptr); time_t ret = time(nullptr);
if (ret == (time_t) -1) { if (ret == (time_t) -1) {
return IOError("GetCurrentTime", errno); return IOError("GetCurrentTime", errno);
@ -1432,7 +1432,7 @@ class PosixEnv : public Env {
} }
virtual Status GetAbsolutePath(const std::string& db_path, virtual Status GetAbsolutePath(const std::string& db_path,
std::string* output_path) { std::string* output_path) override {
if (db_path.find('/') == 0) { if (db_path.find('/') == 0) {
*output_path = db_path; *output_path = db_path;
return Status::OK(); return Status::OK();
@ -1449,13 +1449,13 @@ class PosixEnv : public Env {
} }
// Allow increasing the number of worker threads. // Allow increasing the number of worker threads.
virtual void SetBackgroundThreads(int num, Priority pri) { virtual void SetBackgroundThreads(int num, Priority pri) override {
assert(pri >= Priority::LOW && pri <= Priority::HIGH); assert(pri >= Priority::LOW && pri <= Priority::HIGH);
thread_pools_[pri].SetBackgroundThreads(num); thread_pools_[pri].SetBackgroundThreads(num);
} }
// Allow increasing the number of worker threads. // Allow increasing the number of worker threads.
virtual void IncBackgroundThreadsIfNeeded(int num, Priority pri) { virtual void IncBackgroundThreadsIfNeeded(int num, Priority pri) override {
assert(pri >= Priority::LOW && pri <= Priority::HIGH); assert(pri >= Priority::LOW && pri <= Priority::HIGH);
thread_pools_[pri].IncBackgroundThreadsIfNeeded(num); thread_pools_[pri].IncBackgroundThreadsIfNeeded(num);
} }
@ -1467,7 +1467,7 @@ class PosixEnv : public Env {
#endif #endif
} }
virtual std::string TimeToString(uint64_t secondsSince1970) { virtual std::string TimeToString(uint64_t secondsSince1970) override {
const time_t seconds = (time_t)secondsSince1970; const time_t seconds = (time_t)secondsSince1970;
struct tm t; struct tm t;
int maxsize = 64; int maxsize = 64;
@ -1487,7 +1487,7 @@ class PosixEnv : public Env {
return dummy; return dummy;
} }
EnvOptions OptimizeForLogWrite(const EnvOptions& env_options) const { EnvOptions OptimizeForLogWrite(const EnvOptions& env_options) const override {
EnvOptions optimized = env_options; EnvOptions optimized = env_options;
optimized.use_mmap_writes = false; optimized.use_mmap_writes = false;
// TODO(icanadi) it's faster if fallocate_with_keep_size is false, but it // TODO(icanadi) it's faster if fallocate_with_keep_size is false, but it
@ -1497,7 +1497,8 @@ class PosixEnv : public Env {
return optimized; return optimized;
} }
EnvOptions OptimizeForManifestWrite(const EnvOptions& env_options) const { EnvOptions OptimizeForManifestWrite(
const EnvOptions& env_options) const override {
EnvOptions optimized = env_options; EnvOptions optimized = env_options;
optimized.use_mmap_writes = false; optimized.use_mmap_writes = false;
optimized.fallocate_with_keep_size = true; optimized.fallocate_with_keep_size = true;

@ -252,33 +252,32 @@ class HashLinkListRep : 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 { virtual 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 { virtual 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() { virtual 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() { virtual 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, const char* memtable_key) { virtual void Seek(const Slice& internal_key,
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);
@ -287,15 +286,11 @@ 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() { virtual void SeekToFirst() override { iter_.SeekToFirst(); }
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() { virtual void SeekToLast() override { iter_.SeekToLast(); }
iter_.SeekToLast();
}
private: private:
MemtableSkipList::Iterator iter_; MemtableSkipList::Iterator iter_;
// To destruct with the iterator. // To destruct with the iterator.
@ -315,41 +310,40 @@ class HashLinkListRep : public MemTableRep {
virtual ~LinkListIterator() {} virtual ~LinkListIterator() {}
// 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 { virtual bool Valid() const override { return node_ != nullptr; }
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 { virtual 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() { virtual 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() { virtual 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, const char* memtable_key) { virtual void Seek(const Slice& internal_key,
const char* memtable_key) override {
node_ = hash_link_list_rep_->FindGreaterOrEqualInBucket(head_, node_ = hash_link_list_rep_->FindGreaterOrEqualInBucket(head_,
internal_key); internal_key);
} }
// 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() { virtual 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);
@ -357,7 +351,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() { virtual 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);
@ -386,7 +380,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) { virtual 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);
@ -415,21 +409,21 @@ class HashLinkListRep : public MemTableRep {
} }
} }
virtual bool Valid() const { virtual 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 { virtual 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() { virtual void Next() override {
if (skip_list_iter_) { if (skip_list_iter_) {
skip_list_iter_->Next(); skip_list_iter_->Next();
} else { } else {
@ -448,18 +442,18 @@ 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 { virtual bool Valid() const override { return false; }
return false; virtual const char* key() const override {
}
virtual const char* key() const {
assert(false); assert(false);
return nullptr; return nullptr;
} }
virtual void Next() { } virtual void Next() override {}
virtual void Prev() { } virtual void Prev() override {}
virtual void Seek(const Slice& user_key, const char* memtable_key) { } virtual void Seek(const Slice& user_key,
virtual void SeekToFirst() { } const char* memtable_key) override {}
virtual void SeekToLast() { } virtual void SeekToFirst() override {}
virtual void SeekToLast() override {}
private: private:
}; };
}; };

@ -94,33 +94,34 @@ 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 { virtual 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 { virtual 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() { virtual 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() { virtual 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, const char* memtable_key) { virtual void Seek(const Slice& internal_key,
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,7 +132,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() { virtual void SeekToFirst() override {
if (list_ != nullptr) { if (list_ != nullptr) {
iter_.SeekToFirst(); iter_.SeekToFirst();
} }
@ -139,7 +140,7 @@ 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() { virtual void SeekToLast() override {
if (list_ != nullptr) { if (list_ != nullptr) {
iter_.SeekToLast(); iter_.SeekToLast();
} }
@ -173,7 +174,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) { virtual 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);
@ -181,7 +182,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() { virtual 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);
@ -189,7 +190,7 @@ 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() { virtual 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);
@ -204,19 +205,18 @@ 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 { virtual bool Valid() const override { return false; }
return false; virtual const char* key() const override {
}
virtual const char* key() const {
assert(false); assert(false);
return nullptr; return nullptr;
} }
virtual void Next() { } virtual void Next() override {}
virtual void Prev() { } virtual void Prev() override {}
virtual void Seek(const Slice& internal_key, virtual void Seek(const Slice& internal_key,
const char* memtable_key) { } const char* memtable_key) override {}
virtual void SeekToFirst() { } virtual void SeekToFirst() override {}
virtual void SeekToLast() { } virtual void SeekToLast() override {}
private: private:
}; };
}; };

@ -1343,7 +1343,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) { virtual void Corruption(size_t bytes, const Status& s) override {
cerr << "Corruption detected in log file " << s.ToString() << "\n"; cerr << "Corruption detected in log file " << s.ToString() << "\n";
} }
}; };
@ -1365,17 +1365,17 @@ class InMemoryHandler : public WriteBatch::Handler {
} }
} }
virtual void Put(const Slice& key, const Slice& value) { virtual void Put(const Slice& key, const Slice& value) override {
row_ << "PUT : "; row_ << "PUT : ";
commonPutMerge(key, value); commonPutMerge(key, value);
} }
virtual void Merge(const Slice& key, const Slice& value) { virtual void Merge(const Slice& key, const Slice& value) override {
row_ << "MERGE : "; row_ << "MERGE : ";
commonPutMerge(key, value); commonPutMerge(key, value);
} }
virtual void Delete(const Slice& key) { virtual void Delete(const Slice& key) override {
row_ <<",DELETE : "; row_ <<",DELETE : ";
row_ << LDBCommand::StringToHex(key.ToString()) << " "; row_ << LDBCommand::StringToHex(key.ToString()) << " ";
} }

@ -385,7 +385,7 @@ public:
static void Help(string& ret); static void Help(string& ret);
virtual void DoCommand(); virtual void DoCommand() override;
private: private:
bool null_from_; bool null_from_;
@ -404,7 +404,7 @@ class DBFileDumperCommand : public LDBCommand {
static void Help(string& ret); static void Help(string& ret);
virtual void DoCommand(); virtual void DoCommand() override;
}; };
class DBDumperCommand: public LDBCommand { class DBDumperCommand: public LDBCommand {
@ -416,7 +416,7 @@ public:
static void Help(string& ret); static void Help(string& ret);
virtual void DoCommand(); virtual void DoCommand() override;
private: private:
bool null_from_; bool null_from_;
@ -445,7 +445,7 @@ public:
static void Help(string& ret); static void Help(string& ret);
virtual void DoCommand(); virtual void DoCommand() override;
private: private:
bool has_from_; bool has_from_;
@ -476,9 +476,9 @@ public:
const map<string, string>& options, const vector<string>& flags); const map<string, string>& options, const vector<string>& flags);
static void Help(string& ret); static void Help(string& ret);
virtual void DoCommand(); virtual void DoCommand() override;
virtual Options PrepareOptionsForOpenDB(); virtual Options PrepareOptionsForOpenDB() override;
private: private:
bool create_if_missing_; bool create_if_missing_;
@ -499,11 +499,9 @@ public:
const map<string, string>& options, const vector<string>& flags); const map<string, string>& options, const vector<string>& flags);
static void Help(string& ret); static void Help(string& ret);
virtual void DoCommand(); virtual void DoCommand() override;
virtual bool NoDBOpen() { virtual bool NoDBOpen() override { return true; }
return true;
}
private: private:
bool verbose_; bool verbose_;
@ -522,9 +520,9 @@ class ListColumnFamiliesCommand : public LDBCommand {
const vector<string>& flags); const vector<string>& flags);
static void Help(string& ret); static void Help(string& ret);
virtual void DoCommand(); virtual void DoCommand() override;
virtual bool NoDBOpen() { return true; } virtual bool NoDBOpen() override { return true; }
private: private:
string dbname_; string dbname_;
@ -537,13 +535,11 @@ public:
ReduceDBLevelsCommand(const vector<string>& params, ReduceDBLevelsCommand(const vector<string>& params,
const map<string, string>& options, const vector<string>& flags); const map<string, string>& options, const vector<string>& flags);
virtual Options PrepareOptionsForOpenDB(); virtual Options PrepareOptionsForOpenDB() override;
virtual void DoCommand(); virtual void DoCommand() override;
virtual bool NoDBOpen() { virtual bool NoDBOpen() override { return true; }
return true;
}
static void Help(string& msg); static void Help(string& msg);
@ -568,9 +564,9 @@ public:
ChangeCompactionStyleCommand(const vector<string>& params, ChangeCompactionStyleCommand(const vector<string>& params,
const map<string, string>& options, const vector<string>& flags); const map<string, string>& options, const vector<string>& flags);
virtual Options PrepareOptionsForOpenDB(); virtual Options PrepareOptionsForOpenDB() override;
virtual void DoCommand(); virtual void DoCommand() override;
static void Help(string& msg); static void Help(string& msg);
@ -589,12 +585,10 @@ public:
WALDumperCommand(const vector<string>& params, WALDumperCommand(const vector<string>& params,
const map<string, string>& options, const vector<string>& flags); const map<string, string>& options, const vector<string>& flags);
virtual bool NoDBOpen() { virtual bool NoDBOpen() override { return true; }
return true;
}
static void Help(string& ret); static void Help(string& ret);
virtual void DoCommand(); virtual void DoCommand() override;
private: private:
bool print_header_; bool print_header_;
@ -614,7 +608,7 @@ public:
GetCommand(const vector<string>& params, const map<string, string>& options, GetCommand(const vector<string>& params, const map<string, string>& options,
const vector<string>& flags); const vector<string>& flags);
virtual void DoCommand(); virtual void DoCommand() override;
static void Help(string& ret); static void Help(string& ret);
@ -629,7 +623,7 @@ public:
ApproxSizeCommand(const vector<string>& params, ApproxSizeCommand(const vector<string>& params,
const map<string, string>& options, const vector<string>& flags); const map<string, string>& options, const vector<string>& flags);
virtual void DoCommand(); virtual void DoCommand() override;
static void Help(string& ret); static void Help(string& ret);
@ -645,11 +639,11 @@ public:
BatchPutCommand(const vector<string>& params, BatchPutCommand(const vector<string>& params,
const map<string, string>& options, const vector<string>& flags); const map<string, string>& options, const vector<string>& flags);
virtual void DoCommand(); virtual void DoCommand() override;
static void Help(string& ret); static void Help(string& ret);
virtual Options PrepareOptionsForOpenDB(); virtual Options PrepareOptionsForOpenDB() override;
private: private:
/** /**
@ -665,7 +659,7 @@ public:
ScanCommand(const vector<string>& params, const map<string, string>& options, ScanCommand(const vector<string>& params, const map<string, string>& options,
const vector<string>& flags); const vector<string>& flags);
virtual void DoCommand(); virtual void DoCommand() override;
static void Help(string& ret); static void Help(string& ret);
@ -684,7 +678,7 @@ public:
DeleteCommand(const vector<string>& params, DeleteCommand(const vector<string>& params,
const map<string, string>& options, const vector<string>& flags); const map<string, string>& options, const vector<string>& flags);
virtual void DoCommand(); virtual void DoCommand() override;
static void Help(string& ret); static void Help(string& ret);
@ -699,11 +693,11 @@ public:
PutCommand(const vector<string>& params, const map<string, string>& options, PutCommand(const vector<string>& params, const map<string, string>& options,
const vector<string>& flags); const vector<string>& flags);
virtual void DoCommand(); virtual void DoCommand() override;
static void Help(string& ret); static void Help(string& ret);
virtual Options PrepareOptionsForOpenDB(); virtual Options PrepareOptionsForOpenDB() override;
private: private:
string key_; string key_;
@ -723,7 +717,7 @@ public:
static void Help(string& ret); static void Help(string& ret);
virtual void DoCommand(); virtual void DoCommand() override;
private: private:
static const char* HELP_CMD; static const char* HELP_CMD;
@ -739,11 +733,9 @@ public:
CheckConsistencyCommand(const vector<string>& params, CheckConsistencyCommand(const vector<string>& params,
const map<string, string>& options, const vector<string>& flags); const map<string, string>& options, const vector<string>& flags);
virtual void DoCommand(); virtual void DoCommand() override;
virtual bool NoDBOpen() { virtual bool NoDBOpen() override { return true; }
return true;
}
static void Help(string& ret); static void Help(string& ret);
}; };

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

@ -175,7 +175,7 @@ class SequentialFileImpl : public SequentialFile {
file_->Unref(); file_->Unref();
} }
virtual Status Read(size_t n, Slice* result, char* scratch) { virtual Status Read(size_t n, Slice* result, char* scratch) override {
Status s = file_->Read(pos_, n, result, scratch); Status s = file_->Read(pos_, n, result, scratch);
if (s.ok()) { if (s.ok()) {
pos_ += result->size(); pos_ += result->size();
@ -183,7 +183,7 @@ class SequentialFileImpl : public SequentialFile {
return s; return s;
} }
virtual Status Skip(uint64_t n) { virtual Status Skip(uint64_t n) override {
if (pos_ > file_->Size()) { if (pos_ > file_->Size()) {
return Status::IOError("pos_ > file_->Size()"); return Status::IOError("pos_ > file_->Size()");
} }
@ -211,7 +211,7 @@ class RandomAccessFileImpl : public RandomAccessFile {
} }
virtual Status Read(uint64_t offset, size_t n, Slice* result, virtual Status Read(uint64_t offset, size_t n, Slice* result,
char* scratch) const { char* scratch) const override {
return file_->Read(offset, n, result, scratch); return file_->Read(offset, n, result, scratch);
} }
@ -229,13 +229,13 @@ class WritableFileImpl : public WritableFile {
file_->Unref(); file_->Unref();
} }
virtual Status Append(const Slice& data) { virtual Status Append(const Slice& data) override {
return file_->Append(data); return file_->Append(data);
} }
virtual Status Close() { return Status::OK(); } virtual Status Close() override { return Status::OK(); }
virtual Status Flush() { return Status::OK(); } virtual Status Flush() override { return Status::OK(); }
virtual Status Sync() { return Status::OK(); } virtual Status Sync() override { return Status::OK(); }
private: private:
FileState* file_; FileState* file_;
@ -243,7 +243,7 @@ class WritableFileImpl : public WritableFile {
class InMemoryDirectory : public Directory { class InMemoryDirectory : public Directory {
public: public:
virtual Status Fsync() { return Status::OK(); } virtual Status Fsync() override { return Status::OK(); }
}; };
class InMemoryEnv : public EnvWrapper { class InMemoryEnv : public EnvWrapper {
@ -259,7 +259,7 @@ class InMemoryEnv : public EnvWrapper {
// Partial implementation of the Env interface. // Partial implementation of the Env interface.
virtual Status NewSequentialFile(const std::string& fname, virtual Status NewSequentialFile(const std::string& fname,
unique_ptr<SequentialFile>* result, unique_ptr<SequentialFile>* result,
const EnvOptions& soptions) { const EnvOptions& soptions) override {
std::string nfname = NormalizeFileName(fname); std::string nfname = NormalizeFileName(fname);
MutexLock lock(&mutex_); MutexLock lock(&mutex_);
if (file_map_.find(fname) == file_map_.end()) { if (file_map_.find(fname) == file_map_.end()) {
@ -273,7 +273,7 @@ class InMemoryEnv : public EnvWrapper {
virtual Status NewRandomAccessFile(const std::string& fname, virtual Status NewRandomAccessFile(const std::string& fname,
unique_ptr<RandomAccessFile>* result, unique_ptr<RandomAccessFile>* result,
const EnvOptions& soptions) { const EnvOptions& soptions) override {
std::string nfname = NormalizeFileName(fname); std::string nfname = NormalizeFileName(fname);
MutexLock lock(&mutex_); MutexLock lock(&mutex_);
if (file_map_.find(nfname) == file_map_.end()) { if (file_map_.find(nfname) == file_map_.end()) {
@ -287,7 +287,7 @@ class InMemoryEnv : public EnvWrapper {
virtual Status NewWritableFile(const std::string& fname, virtual Status NewWritableFile(const std::string& fname,
unique_ptr<WritableFile>* result, unique_ptr<WritableFile>* result,
const EnvOptions& soptions) { const EnvOptions& soptions) override {
std::string nfname = NormalizeFileName(fname); std::string nfname = NormalizeFileName(fname);
MutexLock lock(&mutex_); MutexLock lock(&mutex_);
if (file_map_.find(nfname) != file_map_.end()) { if (file_map_.find(nfname) != file_map_.end()) {
@ -303,19 +303,19 @@ class InMemoryEnv : public EnvWrapper {
} }
virtual Status NewDirectory(const std::string& name, virtual Status NewDirectory(const std::string& name,
unique_ptr<Directory>* result) { unique_ptr<Directory>* result) override {
result->reset(new InMemoryDirectory()); result->reset(new InMemoryDirectory());
return Status::OK(); return Status::OK();
} }
virtual bool FileExists(const std::string& fname) { virtual bool FileExists(const std::string& fname) override {
std::string nfname = NormalizeFileName(fname); std::string nfname = NormalizeFileName(fname);
MutexLock lock(&mutex_); MutexLock lock(&mutex_);
return file_map_.find(nfname) != file_map_.end(); return file_map_.find(nfname) != file_map_.end();
} }
virtual Status GetChildren(const std::string& dir, virtual Status GetChildren(const std::string& dir,
std::vector<std::string>* result) { std::vector<std::string>* result) override {
MutexLock lock(&mutex_); MutexLock lock(&mutex_);
result->clear(); result->clear();
@ -340,7 +340,7 @@ class InMemoryEnv : public EnvWrapper {
file_map_.erase(fname); file_map_.erase(fname);
} }
virtual Status DeleteFile(const std::string& fname) { virtual Status DeleteFile(const std::string& fname) override {
std::string nfname = NormalizeFileName(fname); std::string nfname = NormalizeFileName(fname);
MutexLock lock(&mutex_); MutexLock lock(&mutex_);
if (file_map_.find(nfname) == file_map_.end()) { if (file_map_.find(nfname) == file_map_.end()) {
@ -351,19 +351,20 @@ class InMemoryEnv : public EnvWrapper {
return Status::OK(); return Status::OK();
} }
virtual Status CreateDir(const std::string& dirname) { virtual Status CreateDir(const std::string& dirname) override {
return Status::OK(); return Status::OK();
} }
virtual Status CreateDirIfMissing(const std::string& dirname) { virtual Status CreateDirIfMissing(const std::string& dirname) override {
return Status::OK(); return Status::OK();
} }
virtual Status DeleteDir(const std::string& dirname) { virtual Status DeleteDir(const std::string& dirname) override {
return Status::OK(); return Status::OK();
} }
virtual Status GetFileSize(const std::string& fname, uint64_t* file_size) { virtual Status GetFileSize(const std::string& fname,
uint64_t* file_size) override {
std::string nfname = NormalizeFileName(fname); std::string nfname = NormalizeFileName(fname);
MutexLock lock(&mutex_); MutexLock lock(&mutex_);
@ -376,11 +377,12 @@ class InMemoryEnv : public EnvWrapper {
} }
virtual Status GetFileModificationTime(const std::string& fname, virtual Status GetFileModificationTime(const std::string& fname,
uint64_t* time) { uint64_t* time) override {
return Status::NotSupported("getFileMTime", "Not supported in MemEnv"); return Status::NotSupported("getFileMTime", "Not supported in MemEnv");
} }
virtual Status RenameFile(const std::string& src, const std::string& dest) { virtual Status RenameFile(const std::string& src,
const std::string& dest) override {
std::string nsrc = NormalizeFileName(src); std::string nsrc = NormalizeFileName(src);
std::string ndest = NormalizeFileName(dest); std::string ndest = NormalizeFileName(dest);
MutexLock lock(&mutex_); MutexLock lock(&mutex_);
@ -394,17 +396,17 @@ class InMemoryEnv : public EnvWrapper {
return Status::OK(); return Status::OK();
} }
virtual Status LockFile(const std::string& fname, FileLock** lock) { virtual Status LockFile(const std::string& fname, FileLock** lock) override {
*lock = new FileLock; *lock = new FileLock;
return Status::OK(); return Status::OK();
} }
virtual Status UnlockFile(FileLock* lock) { virtual Status UnlockFile(FileLock* lock) override {
delete lock; delete lock;
return Status::OK(); return Status::OK();
} }
virtual Status GetTestDirectory(std::string* path) { virtual Status GetTestDirectory(std::string* path) override {
*path = "/test"; *path = "/test";
return Status::OK(); return Status::OK();
} }

@ -178,7 +178,7 @@ class MockSequentialFile : public SequentialFile {
file_->Unref(); file_->Unref();
} }
virtual Status Read(size_t n, Slice* result, char* scratch) { virtual Status Read(size_t n, Slice* result, char* scratch) override {
Status s = file_->Read(pos_, n, result, scratch); Status s = file_->Read(pos_, n, result, scratch);
if (s.ok()) { if (s.ok()) {
pos_ += result->size(); pos_ += result->size();
@ -186,7 +186,7 @@ class MockSequentialFile : public SequentialFile {
return s; return s;
} }
virtual Status Skip(uint64_t n) { virtual Status Skip(uint64_t n) override {
if (pos_ > file_->Size()) { if (pos_ > file_->Size()) {
return Status::IOError("pos_ > file_->Size()"); return Status::IOError("pos_ > file_->Size()");
} }
@ -214,7 +214,7 @@ class MockRandomAccessFile : public RandomAccessFile {
} }
virtual Status Read(uint64_t offset, size_t n, Slice* result, virtual Status Read(uint64_t offset, size_t n, Slice* result,
char* scratch) const { char* scratch) const override {
return file_->Read(offset, n, result, scratch); return file_->Read(offset, n, result, scratch);
} }
@ -234,7 +234,7 @@ class MockWritableFile : public WritableFile {
file_->Unref(); file_->Unref();
} }
virtual Status Append(const Slice& data) { virtual Status Append(const Slice& data) override {
uint64_t bytes_written = 0; uint64_t bytes_written = 0;
while (bytes_written < data.size()) { while (bytes_written < data.size()) {
auto bytes = RequestToken(data.size() - bytes_written); auto bytes = RequestToken(data.size() - bytes_written);
@ -247,21 +247,13 @@ class MockWritableFile : public WritableFile {
return Status::OK(); return Status::OK();
} }
virtual Status Close() { virtual Status Close() override { return file_->Fsync(); }
return file_->Fsync();
}
virtual Status Flush() { virtual Status Flush() override { return Status::OK(); }
return Status::OK();
}
virtual Status Sync() { virtual Status Sync() override { return file_->Fsync(); }
return file_->Fsync();
}
virtual uint64_t GetFileSize() { virtual uint64_t GetFileSize() override { return file_->Size(); }
return file_->Size();
}
private: private:
inline size_t RequestToken(size_t bytes) { inline size_t RequestToken(size_t bytes) {
@ -279,7 +271,7 @@ class MockWritableFile : public WritableFile {
class MockEnvDirectory : public Directory { class MockEnvDirectory : public Directory {
public: public:
virtual Status Fsync() { return Status::OK(); } virtual Status Fsync() override { return Status::OK(); }
}; };
class MockEnvFileLock : public FileLock { class MockEnvFileLock : public FileLock {
@ -316,7 +308,7 @@ class TestMemLogger : public Logger {
virtual ~TestMemLogger() { virtual ~TestMemLogger() {
} }
virtual void Flush() { virtual void Flush() override {
if (flush_pending_) { if (flush_pending_) {
flush_pending_ = false; flush_pending_ = false;
} }
@ -324,7 +316,7 @@ class TestMemLogger : public Logger {
} }
using Logger::Logv; using Logger::Logv;
virtual void Logv(const char* format, va_list ap) { virtual void Logv(const char* format, va_list ap) override {
// We try twice: the first time with a fixed-size stack allocated buffer, // We try twice: the first time with a fixed-size stack allocated buffer,
// and the second time with a much larger dynamically allocated buffer. // and the second time with a much larger dynamically allocated buffer.
char buffer[500]; char buffer[500];
@ -396,9 +388,7 @@ class TestMemLogger : public Logger {
break; break;
} }
} }
size_t GetLogFileSize() const { size_t GetLogFileSize() const override { return log_size_; }
return log_size_;
}
}; };
} // Anonymous namespace } // Anonymous namespace

@ -29,56 +29,58 @@ class MockEnv : public EnvWrapper {
// Partial implementation of the Env interface. // Partial implementation of the Env interface.
virtual Status NewSequentialFile(const std::string& fname, virtual Status NewSequentialFile(const std::string& fname,
unique_ptr<SequentialFile>* result, unique_ptr<SequentialFile>* result,
const EnvOptions& soptions); const EnvOptions& soptions) override;
virtual Status NewRandomAccessFile(const std::string& fname, virtual Status NewRandomAccessFile(const std::string& fname,
unique_ptr<RandomAccessFile>* result, unique_ptr<RandomAccessFile>* result,
const EnvOptions& soptions); const EnvOptions& soptions) override;
virtual Status NewWritableFile(const std::string& fname, virtual Status NewWritableFile(const std::string& fname,
unique_ptr<WritableFile>* result, unique_ptr<WritableFile>* result,
const EnvOptions& env_options); const EnvOptions& env_options) override;
virtual Status NewRandomRWFile(const std::string& fname, virtual Status NewRandomRWFile(const std::string& fname,
unique_ptr<RandomRWFile>* result, unique_ptr<RandomRWFile>* result,
const EnvOptions& options); const EnvOptions& options) override;
virtual Status NewDirectory(const std::string& name, virtual Status NewDirectory(const std::string& name,
unique_ptr<Directory>* result); unique_ptr<Directory>* result) override;
virtual bool FileExists(const std::string& fname); virtual bool FileExists(const std::string& fname) override;
virtual Status GetChildren(const std::string& dir, virtual Status GetChildren(const std::string& dir,
std::vector<std::string>* result); std::vector<std::string>* result) override;
void DeleteFileInternal(const std::string& fname); void DeleteFileInternal(const std::string& fname);
virtual Status DeleteFile(const std::string& fname); virtual Status DeleteFile(const std::string& fname) override;
virtual Status CreateDir(const std::string& dirname); virtual Status CreateDir(const std::string& dirname) override;
virtual Status CreateDirIfMissing(const std::string& dirname); virtual Status CreateDirIfMissing(const std::string& dirname) override;
virtual Status DeleteDir(const std::string& dirname); virtual Status DeleteDir(const std::string& dirname) override;
virtual Status GetFileSize(const std::string& fname, uint64_t* file_size); virtual Status GetFileSize(const std::string& fname,
uint64_t* file_size) override;
virtual Status GetFileModificationTime(const std::string& fname, virtual Status GetFileModificationTime(const std::string& fname,
uint64_t* time); uint64_t* time) override;
virtual Status RenameFile(const std::string& src, virtual Status RenameFile(const std::string& src,
const std::string& target); const std::string& target) override;
virtual Status LinkFile(const std::string& src, const std::string& target); virtual Status LinkFile(const std::string& src,
const std::string& target) override;
virtual Status NewLogger(const std::string& fname, virtual Status NewLogger(const std::string& fname,
shared_ptr<Logger>* result); shared_ptr<Logger>* result) override;
virtual Status LockFile(const std::string& fname, FileLock** flock); virtual Status LockFile(const std::string& fname, FileLock** flock) override;
virtual Status UnlockFile(FileLock* flock); virtual Status UnlockFile(FileLock* flock) override;
virtual Status GetTestDirectory(std::string* path); virtual Status GetTestDirectory(std::string* path) override;
// Non-virtual functions, specific to MockEnv // Non-virtual functions, specific to MockEnv
Status Truncate(const std::string& fname, size_t size); Status Truncate(const std::string& fname, size_t size);

@ -51,7 +51,7 @@ class PosixLogger : public Logger {
virtual ~PosixLogger() { virtual ~PosixLogger() {
fclose(file_); fclose(file_);
} }
virtual void Flush() { virtual void Flush() override {
if (flush_pending_) { if (flush_pending_) {
flush_pending_ = false; flush_pending_ = false;
fflush(file_); fflush(file_);
@ -60,7 +60,7 @@ class PosixLogger : public Logger {
} }
using Logger::Logv; using Logger::Logv;
virtual void Logv(const char* format, va_list ap) { virtual void Logv(const char* format, va_list ap) override {
const uint64_t thread_id = (*gettid_)(); const uint64_t thread_id = (*gettid_)();
// We try twice: the first time with a fixed-size stack allocated buffer, // We try twice: the first time with a fixed-size stack allocated buffer,
@ -156,9 +156,7 @@ class PosixLogger : public Logger {
break; break;
} }
} }
size_t GetLogFileSize() const { size_t GetLogFileSize() const override { return log_size_; }
return log_size_;
}
}; };
} // namespace rocksdb } // namespace rocksdb

@ -25,22 +25,22 @@ class FixedPrefixTransform : public SliceTransform {
: prefix_len_(prefix_len), : prefix_len_(prefix_len),
name_("rocksdb.FixedPrefix." + ToString(prefix_len_)) {} name_("rocksdb.FixedPrefix." + ToString(prefix_len_)) {}
virtual const char* Name() const { return name_.c_str(); } virtual const char* Name() const override { return name_.c_str(); }
virtual Slice Transform(const Slice& src) const { virtual 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 { virtual bool InDomain(const Slice& src) const override {
return (src.size() >= prefix_len_); return (src.size() >= prefix_len_);
} }
virtual bool InRange(const Slice& dst) const { virtual bool InRange(const Slice& dst) const override {
return (dst.size() == prefix_len_); return (dst.size() == prefix_len_);
} }
virtual bool SameResultWhenAppended(const Slice& prefix) const { virtual bool SameResultWhenAppended(const Slice& prefix) const override {
return InDomain(prefix); return InDomain(prefix);
} }
}; };
@ -55,20 +55,20 @@ class CappedPrefixTransform : public SliceTransform {
: cap_len_(cap_len), : cap_len_(cap_len),
name_("rocksdb.CappedPrefix." + ToString(cap_len_)) {} name_("rocksdb.CappedPrefix." + ToString(cap_len_)) {}
virtual const char* Name() const { return name_.c_str(); } virtual const char* Name() const override { return name_.c_str(); }
virtual Slice Transform(const Slice& src) const { virtual 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 { return true; } virtual bool InDomain(const Slice& src) const override { return true; }
virtual bool InRange(const Slice& dst) const { virtual bool InRange(const Slice& dst) const override {
return (dst.size() <= cap_len_); return (dst.size() <= cap_len_);
} }
virtual bool SameResultWhenAppended(const Slice& prefix) const { virtual bool SameResultWhenAppended(const Slice& prefix) const override {
return prefix.size() >= cap_len_; return prefix.size() >= cap_len_;
} }
}; };
@ -77,23 +77,15 @@ class NoopTransform : public SliceTransform {
public: public:
explicit NoopTransform() { } explicit NoopTransform() { }
virtual const char* Name() const { virtual const char* Name() const override { return "rocksdb.Noop"; }
return "rocksdb.Noop";
}
virtual Slice Transform(const Slice& src) const { virtual Slice Transform(const Slice& src) const override { return src; }
return src;
}
virtual bool InDomain(const Slice& src) const { virtual bool InDomain(const Slice& src) const override { return true; }
return true;
}
virtual bool InRange(const Slice& dst) const { virtual bool InRange(const Slice& dst) const override { return true; }
return true;
}
virtual bool SameResultWhenAppended(const Slice& prefix) const { virtual bool SameResultWhenAppended(const Slice& prefix) const override {
return false; return false;
} }
}; };

@ -45,7 +45,7 @@ class ErrorEnv : public EnvWrapper {
virtual Status NewWritableFile(const std::string& fname, virtual Status NewWritableFile(const std::string& fname,
unique_ptr<WritableFile>* result, unique_ptr<WritableFile>* result,
const EnvOptions& soptions) { const EnvOptions& soptions) override {
result->reset(); result->reset();
if (writable_file_error_) { if (writable_file_error_) {
++num_writable_file_errors_; ++num_writable_file_errors_;
@ -88,9 +88,11 @@ class SimpleSuffixReverseComparator : public Comparator {
public: public:
SimpleSuffixReverseComparator() {} SimpleSuffixReverseComparator() {}
virtual const char* Name() const { return "SimpleSuffixReverseComparator"; } virtual const char* Name() const override {
return "SimpleSuffixReverseComparator";
}
virtual int Compare(const Slice& a, const Slice& b) const { virtual int Compare(const Slice& a, const Slice& b) const override {
Slice prefix_a = Slice(a.data(), 8); Slice prefix_a = Slice(a.data(), 8);
Slice prefix_b = Slice(b.data(), 8); Slice prefix_b = Slice(b.data(), 8);
int prefix_comp = prefix_a.compare(prefix_b); int prefix_comp = prefix_a.compare(prefix_b);
@ -103,9 +105,9 @@ class SimpleSuffixReverseComparator : public Comparator {
} }
} }
virtual void FindShortestSeparator(std::string* start, virtual void FindShortestSeparator(std::string* start,
const Slice& limit) const {} const Slice& limit) const override {}
virtual void FindShortSuccessor(std::string* key) const {} virtual void FindShortSuccessor(std::string* key) const override {}
}; };
// Returns a user key comparator that can be used for comparing two uint64_t // Returns a user key comparator that can be used for comparing two uint64_t

@ -116,24 +116,22 @@ class BackupEngineImpl : public BackupEngine {
BackupEngineImpl(Env* db_env, const BackupableDBOptions& options, BackupEngineImpl(Env* db_env, const BackupableDBOptions& options,
bool read_only = false); bool read_only = false);
~BackupEngineImpl(); ~BackupEngineImpl();
Status CreateNewBackup(DB* db, bool flush_before_backup = false); Status CreateNewBackup(DB* db, bool flush_before_backup = false) override;
Status PurgeOldBackups(uint32_t num_backups_to_keep); Status PurgeOldBackups(uint32_t num_backups_to_keep) override;
Status DeleteBackup(BackupID backup_id); Status DeleteBackup(BackupID backup_id) override;
void StopBackup() { void StopBackup() override {
stop_backup_.store(true, std::memory_order_release); stop_backup_.store(true, std::memory_order_release);
} }
Status GarbageCollect(); Status GarbageCollect() override;
void GetBackupInfo(std::vector<BackupInfo>* backup_info); void GetBackupInfo(std::vector<BackupInfo>* backup_info) override;
void GetCorruptedBackups(std::vector<BackupID>* corrupt_backup_ids); void GetCorruptedBackups(std::vector<BackupID>* corrupt_backup_ids) override;
Status RestoreDBFromBackup(BackupID backup_id, const std::string& db_dir, Status RestoreDBFromBackup(
const std::string& wal_dir, BackupID backup_id, const std::string& db_dir, const std::string& wal_dir,
const RestoreOptions& restore_options = const RestoreOptions& restore_options = RestoreOptions()) override;
RestoreOptions()); Status RestoreDBFromLatestBackup(
Status RestoreDBFromLatestBackup(const std::string& db_dir, const std::string& db_dir, const std::string& wal_dir,
const std::string& wal_dir, const RestoreOptions& restore_options = RestoreOptions()) override {
const RestoreOptions& restore_options =
RestoreOptions()) {
return RestoreDBFromBackup(latest_backup_id_, db_dir, wal_dir, return RestoreDBFromBackup(latest_backup_id_, db_dir, wal_dir,
restore_options); restore_options);
} }
@ -1291,24 +1289,25 @@ class BackupEngineReadOnlyImpl : public BackupEngineReadOnly {
virtual ~BackupEngineReadOnlyImpl() {} virtual ~BackupEngineReadOnlyImpl() {}
virtual void GetBackupInfo(std::vector<BackupInfo>* backup_info) { virtual void GetBackupInfo(std::vector<BackupInfo>* backup_info) override {
backup_engine_->GetBackupInfo(backup_info); backup_engine_->GetBackupInfo(backup_info);
} }
virtual void GetCorruptedBackups(std::vector<BackupID>* corrupt_backup_ids) { virtual void GetCorruptedBackups(
std::vector<BackupID>* corrupt_backup_ids) override {
backup_engine_->GetCorruptedBackups(corrupt_backup_ids); backup_engine_->GetCorruptedBackups(corrupt_backup_ids);
} }
virtual Status RestoreDBFromBackup( virtual 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()) { 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( virtual 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()) { 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);
} }

@ -34,7 +34,7 @@ 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 { virtual SequenceNumber GetLatestSequenceNumber() const override {
return ++sequence_number_; return ++sequence_number_;
} }
@ -86,7 +86,7 @@ class DummyDB : public StackableDB {
return path_; return path_;
} }
virtual uint64_t LogNumber() const { virtual uint64_t LogNumber() const override {
// what business do you have calling this method? // what business do you have calling this method?
ASSERT_TRUE(false); ASSERT_TRUE(false);
return 0; return 0;
@ -96,13 +96,13 @@ class DummyDB : public StackableDB {
return alive_ ? kAliveLogFile : kArchivedLogFile; return alive_ ? kAliveLogFile : kArchivedLogFile;
} }
virtual SequenceNumber StartSequence() const { virtual SequenceNumber StartSequence() const override {
// backupabledb should not need this method // backupabledb should not need this method
ASSERT_TRUE(false); ASSERT_TRUE(false);
return 0; return 0;
} }
virtual uint64_t SizeFileBytes() const { virtual uint64_t SizeFileBytes() const override {
// backupabledb should not need this method // backupabledb should not need this method
ASSERT_TRUE(false); ASSERT_TRUE(false);
return 0; return 0;
@ -140,7 +140,7 @@ class TestEnv : public EnvWrapper {
class DummySequentialFile : public SequentialFile { class DummySequentialFile : public SequentialFile {
public: public:
DummySequentialFile() : SequentialFile(), rnd_(5) {} DummySequentialFile() : SequentialFile(), rnd_(5) {}
virtual Status Read(size_t n, Slice* result, char* scratch) { virtual Status Read(size_t n, Slice* result, char* scratch) override {
size_t read_size = (n > size_left) ? size_left : n; size_t read_size = (n > size_left) ? size_left : n;
for (size_t i = 0; i < read_size; ++i) { for (size_t i = 0; i < read_size; ++i) {
scratch[i] = rnd_.Next() & 255; scratch[i] = rnd_.Next() & 255;
@ -150,7 +150,7 @@ class TestEnv : public EnvWrapper {
return Status::OK(); return Status::OK();
} }
virtual Status Skip(uint64_t n) { virtual 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();
} }
@ -159,9 +159,8 @@ class TestEnv : public EnvWrapper {
Random rnd_; Random rnd_;
}; };
Status NewSequentialFile(const std::string& f, Status NewSequentialFile(const std::string& f, unique_ptr<SequentialFile>* r,
unique_ptr<SequentialFile>* r, const EnvOptions& options) override {
const EnvOptions& options) {
MutexLock l(&mutex_); MutexLock l(&mutex_);
if (dummy_sequential_file_) { if (dummy_sequential_file_) {
r->reset(new TestEnv::DummySequentialFile()); r->reset(new TestEnv::DummySequentialFile());
@ -172,7 +171,7 @@ class TestEnv : public EnvWrapper {
} }
Status NewWritableFile(const std::string& f, unique_ptr<WritableFile>* r, Status NewWritableFile(const std::string& f, unique_ptr<WritableFile>* r,
const EnvOptions& options) { const EnvOptions& options) override {
MutexLock l(&mutex_); MutexLock l(&mutex_);
written_files_.push_back(f); written_files_.push_back(f);
if (limit_written_files_ <= 0) { if (limit_written_files_ <= 0) {

@ -38,7 +38,7 @@ class CheckpointImpl : public Checkpoint {
// The directory should not already exist and will be created by this API. // The directory should not already exist and will be created by this API.
// The directory will be an absolute path // The directory will be an absolute path
using Checkpoint::CreateCheckpoint; using Checkpoint::CreateCheckpoint;
virtual Status CreateCheckpoint(const std::string& checkpoint_dir); virtual Status CreateCheckpoint(const std::string& checkpoint_dir) override;
private: private:
DB* db_; DB* db_;

@ -401,11 +401,12 @@ class SimpleSortedIndex : public Index {
return BytewiseComparator(); return BytewiseComparator();
} }
virtual bool UsefulIndex(const Filter& filter) const { virtual bool UsefulIndex(const Filter& filter) const override {
return filter.GetInterval(field_) != nullptr; return filter.GetInterval(field_) != nullptr;
} }
// REQUIRES: UsefulIndex(filter) == true // REQUIRES: UsefulIndex(filter) == true
virtual Direction Position(const Filter& filter, Iterator* iterator) const { virtual Direction Position(const Filter& filter,
Iterator* iterator) const override {
auto interval = filter.GetInterval(field_); auto interval = filter.GetInterval(field_);
assert(interval != nullptr); // because index is useful assert(interval != nullptr); // because index is useful
Direction direction; Direction direction;
@ -428,9 +429,9 @@ class SimpleSortedIndex : public Index {
return direction; return direction;
} }
// REQUIRES: UsefulIndex(filter) == true // REQUIRES: UsefulIndex(filter) == true
virtual bool ShouldContinueLooking(const Filter& filter, virtual bool ShouldContinueLooking(
const Slice& secondary_key, const Filter& filter, const Slice& secondary_key,
Index::Direction direction) const { Index::Direction direction) const override {
auto interval = filter.GetInterval(field_); auto interval = filter.GetInterval(field_);
assert(interval != nullptr); // because index is useful assert(interval != nullptr); // because index is useful
@ -521,17 +522,17 @@ class CursorWithFilterIndexed : public Cursor {
virtual bool Valid() const override { virtual bool Valid() const override {
return valid_ && secondary_index_iter_->Valid(); return valid_ && secondary_index_iter_->Valid();
} }
virtual void Next() { virtual void Next() override {
assert(Valid()); assert(Valid());
Advance(); Advance();
AdvanceUntilSatisfies(); AdvanceUntilSatisfies();
} }
// temporary object. copy it if you want to use it // temporary object. copy it if you want to use it
virtual const JSONDocument& document() const { virtual const JSONDocument& document() const override {
assert(Valid()); assert(Valid());
return *current_json_document_; return *current_json_document_;
} }
virtual Status status() const { virtual Status status() const override {
if (!status_.ok()) { if (!status_.ok()) {
return status_; return status_;
} }
@ -726,7 +727,7 @@ class DocumentDBImpl : public DocumentDB {
} }
virtual Status CreateIndex(const WriteOptions& write_options, virtual Status CreateIndex(const WriteOptions& write_options,
const IndexDescriptor& index) { const IndexDescriptor& index) override {
auto index_obj = auto index_obj =
Index::CreateIndexFromDescription(*index.description, index.name); Index::CreateIndexFromDescription(*index.description, index.name);
if (index_obj == nullptr) { if (index_obj == nullptr) {
@ -769,7 +770,7 @@ class DocumentDBImpl : public DocumentDB {
return DocumentDB::Write(write_options, &batch); return DocumentDB::Write(write_options, &batch);
} }
virtual Status DropIndex(const std::string& name) { virtual Status DropIndex(const std::string& name) override {
MutexLock l(&write_mutex_); MutexLock l(&write_mutex_);
auto index_iter = name_to_index_.find(name); auto index_iter = name_to_index_.find(name);
@ -795,7 +796,7 @@ class DocumentDBImpl : public DocumentDB {
} }
virtual Status Insert(const WriteOptions& options, virtual Status Insert(const WriteOptions& options,
const JSONDocument& document) { const JSONDocument& document) override {
WriteBatch batch; WriteBatch batch;
if (!document.IsObject()) { if (!document.IsObject()) {
@ -888,7 +889,7 @@ class DocumentDBImpl : public DocumentDB {
virtual Status Update(const ReadOptions& read_options, virtual Status Update(const ReadOptions& read_options,
const WriteOptions& write_options, const WriteOptions& write_options,
const JSONDocument& filter, const JSONDocument& filter,
const JSONDocument& updates) { const JSONDocument& updates) override {
MutexLock l(&write_mutex_); MutexLock l(&write_mutex_);
std::unique_ptr<Cursor> cursor( std::unique_ptr<Cursor> cursor(
ConstructFilterCursor(read_options, nullptr, filter)); ConstructFilterCursor(read_options, nullptr, filter));

@ -30,27 +30,25 @@ class GeoDBImpl : public GeoDB {
// Associate the GPS location with the identified by 'id'. The value // Associate the GPS location with the identified by 'id'. The value
// is a blob that is associated with this object. // is a blob that is associated with this object.
virtual Status Insert(const GeoObject& object); virtual Status Insert(const GeoObject& object) override;
// Retrieve the value of the object located at the specified GPS // Retrieve the value of the object located at the specified GPS
// location and is identified by the 'id'. // location and is identified by the 'id'.
virtual Status GetByPosition(const GeoPosition& pos, virtual Status GetByPosition(const GeoPosition& pos, const Slice& id,
const Slice& id, std::string* value) override;
std::string* value);
// Retrieve the value of the object identified by the 'id'. This method // Retrieve the value of the object identified by the 'id'. This method
// could be potentially slower than GetByPosition // could be potentially slower than GetByPosition
virtual Status GetById(const Slice& id, GeoObject* object); virtual Status GetById(const Slice& id, GeoObject* object) override;
// Delete the specified object // Delete the specified object
virtual Status Remove(const Slice& id); virtual Status Remove(const Slice& id) override;
// Returns a list of all items within a circular radius from the // Returns a list of all items within a circular radius from the
// specified gps location // specified gps location
virtual Status SearchRadial(const GeoPosition& pos, virtual Status SearchRadial(const GeoPosition& pos, double radius,
double radius,
std::vector<GeoObject>* values, std::vector<GeoObject>* values,
int number_of_values); int number_of_values) override;
private: private:
DB* db_; DB* db_;

@ -13,7 +13,7 @@ namespace rocksdb {
class RedisListException: public std::exception { class RedisListException: public std::exception {
public: public:
const char* what() const throw() { const char* what() const throw() override {
return "Invalid operation or corrupt data in Redis List."; return "Invalid operation or corrupt data in Redis List.";
} }
}; };

@ -244,7 +244,7 @@ Status DBWithTTLImpl::Write(const WriteOptions& opts, WriteBatch* updates) {
WriteBatch updates_ttl; WriteBatch updates_ttl;
Status batch_rewrite_status; Status batch_rewrite_status;
virtual Status PutCF(uint32_t column_family_id, const Slice& key, virtual Status PutCF(uint32_t column_family_id, const Slice& key,
const Slice& value) { const Slice& value) override {
std::string value_with_ts; std::string value_with_ts;
Status st = AppendTS(value, &value_with_ts, env_); Status st = AppendTS(value, &value_with_ts, env_);
if (!st.ok()) { if (!st.ok()) {
@ -256,7 +256,7 @@ Status DBWithTTLImpl::Write(const WriteOptions& opts, WriteBatch* updates) {
return Status::OK(); return Status::OK();
} }
virtual Status MergeCF(uint32_t column_family_id, const Slice& key, virtual Status MergeCF(uint32_t column_family_id, const Slice& key,
const Slice& value) { const Slice& value) override {
std::string value_with_ts; std::string value_with_ts;
Status st = AppendTS(value, &value_with_ts, env_); Status st = AppendTS(value, &value_with_ts, env_);
if (!st.ok()) { if (!st.ok()) {
@ -267,11 +267,14 @@ Status DBWithTTLImpl::Write(const WriteOptions& opts, WriteBatch* updates) {
} }
return Status::OK(); return Status::OK();
} }
virtual Status DeleteCF(uint32_t column_family_id, const Slice& key) { virtual Status DeleteCF(uint32_t column_family_id,
const Slice& key) override {
WriteBatchInternal::Delete(&updates_ttl, column_family_id, key); WriteBatchInternal::Delete(&updates_ttl, column_family_id, key);
return Status::OK(); return Status::OK();
} }
virtual void LogData(const Slice& blob) { updates_ttl.PutLogData(blob); } virtual void LogData(const Slice& blob) override {
updates_ttl.PutLogData(blob);
}
private: private:
Env* env_; Env* env_;

@ -71,7 +71,7 @@ class DBWithTTLImpl : public DBWithTTL {
virtual Iterator* NewIterator(const ReadOptions& opts, virtual Iterator* NewIterator(const ReadOptions& opts,
ColumnFamilyHandle* column_family) override; ColumnFamilyHandle* column_family) override;
virtual DB* GetBaseDB() { return db_; } virtual DB* GetBaseDB() override { return db_; }
static bool IsStale(const Slice& value, int32_t ttl, Env* env); static bool IsStale(const Slice& value, int32_t ttl, Env* env);
@ -95,26 +95,26 @@ class TtlIterator : public Iterator {
~TtlIterator() { delete iter_; } ~TtlIterator() { delete iter_; }
bool Valid() const { return iter_->Valid(); } bool Valid() const override { return iter_->Valid(); }
void SeekToFirst() { iter_->SeekToFirst(); } void SeekToFirst() override { iter_->SeekToFirst(); }
void SeekToLast() { iter_->SeekToLast(); } void SeekToLast() override { iter_->SeekToLast(); }
void Seek(const Slice& target) { iter_->Seek(target); } void Seek(const Slice& target) override { iter_->Seek(target); }
void Next() { iter_->Next(); } void Next() override { iter_->Next(); }
void Prev() { iter_->Prev(); } void Prev() override { iter_->Prev(); }
Slice key() const { return iter_->key(); } Slice key() const override { return iter_->key(); }
int32_t timestamp() const { int32_t timestamp() const {
return DecodeFixed32(iter_->value().data() + iter_->value().size() - return DecodeFixed32(iter_->value().data() + iter_->value().size() -
DBWithTTLImpl::kTSLength); DBWithTTLImpl::kTSLength);
} }
Slice value() const { Slice value() const override {
// TODO: handle timestamp corruption like in general iterator semantics // TODO: handle timestamp corruption like in general iterator semantics
assert(DBWithTTLImpl::SanityCheckTimestamp(iter_->value()).ok()); assert(DBWithTTLImpl::SanityCheckTimestamp(iter_->value()).ok());
Slice trimmed_value = iter_->value(); Slice trimmed_value = iter_->value();
@ -122,7 +122,7 @@ class TtlIterator : public Iterator {
return trimmed_value; return trimmed_value;
} }
Status status() const { return iter_->status(); } Status status() const override { return iter_->status(); }
private: private:
Iterator* iter_; Iterator* iter_;
@ -187,7 +187,7 @@ class TtlCompactionFilterFactory : public CompactionFilterFactory {
: ttl_(ttl), env_(env), user_comp_filter_factory_(comp_filter_factory) {} : ttl_(ttl), env_(env), user_comp_filter_factory_(comp_filter_factory) {}
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter( virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& context) { const CompactionFilter::Context& context) override {
return std::unique_ptr<TtlCompactionFilter>(new TtlCompactionFilter( return std::unique_ptr<TtlCompactionFilter>(new TtlCompactionFilter(
ttl_, env_, nullptr, ttl_, env_, nullptr,
std::move(user_comp_filter_factory_->CreateCompactionFilter(context)))); std::move(user_comp_filter_factory_->CreateCompactionFilter(context))));

@ -29,7 +29,7 @@ class SpecialTimeEnv : public EnvWrapper {
} }
void Sleep(int64_t sleep_time) { current_time_ += sleep_time; } void Sleep(int64_t sleep_time) { current_time_ += sleep_time; }
virtual Status GetCurrentTime(int64_t* current_time) { virtual Status GetCurrentTime(int64_t* current_time) override {
*current_time = current_time_; *current_time = current_time_;
return Status::OK(); return Status::OK();
} }

@ -139,7 +139,7 @@ class BaseDeltaIterator : public Iterator {
: delta_iterator_->Entry().value; : delta_iterator_->Entry().value;
} }
Status status() const { Status status() const override {
if (!status_.ok()) { if (!status_.ok()) {
return status_; return status_;
} }
@ -358,7 +358,7 @@ class WBWIIteratorImpl : public WBWIIterator {
virtual bool Valid() const override { return valid_; } virtual bool Valid() const override { return valid_; }
virtual void SeekToFirst() { virtual void SeekToFirst() override {
valid_ = true; valid_ = true;
WriteBatchIndexEntry search_entry(WriteBatchIndexEntry::kFlagMin, WriteBatchIndexEntry search_entry(WriteBatchIndexEntry::kFlagMin,
column_family_id_); column_family_id_);
@ -366,7 +366,7 @@ class WBWIIteratorImpl : public WBWIIterator {
ReadEntry(); ReadEntry();
} }
virtual void SeekToLast() { virtual void SeekToLast() override {
valid_ = true; valid_ = true;
WriteBatchIndexEntry search_entry(WriteBatchIndexEntry::kFlagMin, WriteBatchIndexEntry search_entry(WriteBatchIndexEntry::kFlagMin,
column_family_id_ + 1); column_family_id_ + 1);

Loading…
Cancel
Save