Skip to content

Commit

Permalink
rocksdb: Add missing override
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Igor Sugak committed Feb 26, 2015
1 parent 1e06a40 commit 62247ff
Show file tree
Hide file tree
Showing 71 changed files with 928 additions and 927 deletions.
106 changes: 44 additions & 62 deletions db/c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,9 @@ struct rocksdb_compactionfilter_t : public CompactionFilter {
(*destructor_)(state_);
}

virtual bool Filter(
int level,
const Slice& key,
const Slice& existing_value,
std::string* new_value,
bool* value_changed) const {
virtual bool Filter(int level, const Slice& key, const Slice& existing_value,
std::string* new_value,
bool* value_changed) const override {
char* c_new_value = nullptr;
size_t new_value_length = 0;
unsigned char c_value_changed = 0;
Expand All @@ -147,9 +144,7 @@ struct rocksdb_compactionfilter_t : public CompactionFilter {
return result;
}

virtual const char* Name() const {
return (*name_)(state_);
}
virtual const char* Name() const override { return (*name_)(state_); }
};

struct rocksdb_compactionfilterfactory_t : public CompactionFilterFactory {
Expand All @@ -162,14 +157,14 @@ struct rocksdb_compactionfilterfactory_t : public CompactionFilterFactory {
virtual ~rocksdb_compactionfilterfactory_t() { (*destructor_)(state_); }

virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& context) {
const CompactionFilter::Context& context) override {
rocksdb_compactionfiltercontext_t ccontext;
ccontext.rep = context;
CompactionFilter* cf = (*create_compaction_filter_)(state_, &ccontext);
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 {
Expand All @@ -186,15 +181,12 @@ struct rocksdb_compactionfilterv2_t : public CompactionFilterV2 {
(*destructor_)(state_);
}

virtual const char* Name() const {
return (*name_)(state_);
}
virtual const char* Name() const override { return (*name_)(state_); }

virtual std::vector<bool> Filter(int level,
const SliceVector& keys,
const SliceVector& existing_values,
std::vector<std::string>* new_values,
std::vector<bool>* values_changed) const {
virtual std::vector<bool> Filter(
int level, const SliceVector& keys, const SliceVector& existing_values,
std::vector<std::string>* new_values,
std::vector<bool>* values_changed) const override {
// Make a vector pointing to the underlying key data.
size_t num_keys = keys.size();
std::vector<const char*> keys_list(num_keys);
Expand Down Expand Up @@ -256,12 +248,10 @@ struct rocksdb_compactionfilterfactoryv2_t : public CompactionFilterFactoryV2 {
(*destructor_)(state_);
}

virtual const char* Name() const {
return (*name_)(state_);
}
virtual const char* Name() const override { return (*name_)(state_); }

virtual std::unique_ptr<CompactionFilterV2> CreateCompactionFilterV2(
const CompactionFilterContext& context) {
const CompactionFilterContext& context) override {
struct rocksdb_compactionfiltercontext_t c_context;
c_context.rep.is_full_compaction = context.is_full_compaction;
c_context.rep.is_manual_compaction = context.is_manual_compaction;
Expand All @@ -283,17 +273,16 @@ struct rocksdb_comparator_t : public Comparator {
(*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());
}

virtual const char* Name() const {
return (*name_)(state_);
}
virtual const char* Name() const override { return (*name_)(state_); }

// No-ops since the C binding does not support key shortening methods.
virtual void FindShortestSeparator(std::string*, const Slice&) const { }
virtual void FindShortSuccessor(std::string* key) const { }
virtual void FindShortestSeparator(std::string*,
const Slice&) const override {}
virtual void FindShortSuccessor(std::string* key) const override {}
};

struct rocksdb_filterpolicy_t : public FilterPolicy {
Expand All @@ -317,11 +306,10 @@ struct rocksdb_filterpolicy_t : public FilterPolicy {
(*destructor_)(state_);
}

virtual const char* Name() const {
return (*name_)(state_);
}
virtual const char* Name() const override { 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<size_t> key_sizes(n);
for (int i = 0; i < n; i++) {
Expand All @@ -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(),
filter.data(), filter.size());
}
Expand Down Expand Up @@ -368,17 +357,12 @@ struct rocksdb_mergeoperator_t : public MergeOperator {
(*destructor_)(state_);
}

virtual const char* Name() const {
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 const char* Name() const override { 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 override {
size_t n = operand_list.size();
std::vector<const char*> operand_pointers(n);
std::vector<size_t> operand_sizes(n);
Expand Down Expand Up @@ -414,7 +398,8 @@ struct rocksdb_mergeoperator_t : public MergeOperator {

virtual bool PartialMergeMulti(const Slice& key,
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();
std::vector<const char*> operand_pointers(operand_count);
std::vector<size_t> operand_sizes(operand_count);
Expand Down Expand Up @@ -465,21 +450,19 @@ struct rocksdb_slicetransform_t : public SliceTransform {
(*destructor_)(state_);
}

virtual const char* Name() const {
return (*name_)(state_);
}
virtual const char* Name() const override { return (*name_)(state_); }

virtual Slice Transform(const Slice& src) const {
virtual Slice Transform(const Slice& src) const override {
size_t len;
char* dst = (*transform_)(state_, src.data(), src.size(), &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());
}

virtual bool InRange(const Slice& src) const {
virtual bool InRange(const Slice& src) const override {
return (*in_range_)(state_, src.data(), src.size());
}
};
Expand Down Expand Up @@ -1126,10 +1109,10 @@ void rocksdb_writebatch_iterate(
void* state_;
void (*put_)(void*, const char* k, size_t klen, const char* v, size_t vlen);
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());
}
virtual void Delete(const Slice& key) {
virtual void Delete(const Slice& key) override {
(*deleted_)(state_, key.data(), key.size());
}
};
Expand Down Expand Up @@ -1913,11 +1896,12 @@ rocksdb_filterpolicy_t* rocksdb_filterpolicy_create_bloom(int bits_per_key) {
struct Wrapper : public rocksdb_filterpolicy_t {
const FilterPolicy* rep_;
~Wrapper() { delete rep_; }
const char* Name() const { return rep_->Name(); }
void CreateFilter(const Slice* keys, int n, std::string* dst) const {
const char* Name() const override { return rep_->Name(); }
void CreateFilter(const Slice* keys, int n,
std::string* dst) const override {
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);
}
static void DoNothing(void*) { }
Expand Down Expand Up @@ -2099,16 +2083,14 @@ rocksdb_slicetransform_t* rocksdb_slicetransform_create_fixed_prefix(size_t pref
struct Wrapper : public rocksdb_slicetransform_t {
const SliceTransform* rep_;
~Wrapper() { delete rep_; }
const char* Name() const { return rep_->Name(); }
Slice Transform(const Slice& src) const {
const char* Name() const override { return rep_->Name(); }
Slice Transform(const Slice& src) const override {
return rep_->Transform(src);
}
bool InDomain(const Slice& src) const {
bool InDomain(const Slice& src) const override {
return rep_->InDomain(src);
}
bool InRange(const Slice& src) const {
return rep_->InRange(src);
}
bool InRange(const Slice& src) const override { return rep_->InRange(src); }
static void DoNothing(void*) { }
};
Wrapper* wrapper = new Wrapper;
Expand Down
2 changes: 1 addition & 1 deletion db/column_family.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ColumnFamilyHandleImpl : public ColumnFamilyHandle {
virtual ColumnFamilyData* cfd() const { return cfd_; }
virtual const Comparator* user_comparator() const;

virtual uint32_t GetID() const;
virtual uint32_t GetID() const override;
virtual const std::string& GetName() const override;

private:
Expand Down
6 changes: 3 additions & 3 deletions db/column_family_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class EnvCounter : public EnvWrapper {
return num_new_writable_file_;
}
Status NewWritableFile(const std::string& f, unique_ptr<WritableFile>* r,
const EnvOptions& soptions) {
const EnvOptions& soptions) override {
++num_new_writable_file_;
return EnvWrapper::NewWritableFile(f, r, soptions);
}
Expand Down Expand Up @@ -329,8 +329,8 @@ class ColumnFamilyTest {
class DumbLogger : public Logger {
public:
using Logger::Logv;
virtual void Logv(const char* format, va_list ap) {}
virtual size_t GetLogFileSize() const { return 0; }
virtual void Logv(const char* format, va_list ap) override {}
virtual size_t GetLogFileSize() const override { return 0; }
};

TEST(ColumnFamilyTest, DontReuseColumnFamilyID) {
Expand Down
2 changes: 1 addition & 1 deletion db/compaction_picker.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ class NullCompactionPicker : public CompactionPicker {

// Given the current number of levels, returns the highest allowed level
// 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;
}

Expand Down
44 changes: 23 additions & 21 deletions db/comparator_db_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,30 @@ typedef std::map<std::string, std::string, MapComparator> KVMap;
class KVIter : public Iterator {
public:
explicit KVIter(const KVMap* map) : map_(map), iter_(map_->end()) {}
virtual bool Valid() const { return iter_ != map_->end(); }
virtual void SeekToFirst() { iter_ = map_->begin(); }
virtual void SeekToLast() {
virtual bool Valid() const override { return iter_ != map_->end(); }
virtual void SeekToFirst() override { iter_ = map_->begin(); }
virtual void SeekToLast() override {
if (map_->empty()) {
iter_ = map_->end();
} else {
iter_ = map_->find(map_->rbegin()->first);
}
}
virtual void Seek(const Slice& k) { iter_ = map_->lower_bound(k.ToString()); }
virtual void Next() { ++iter_; }
virtual void Prev() {
virtual void Seek(const Slice& k) override {
iter_ = map_->lower_bound(k.ToString());
}
virtual void Next() override { ++iter_; }
virtual void Prev() override {
if (iter_ == map_->begin()) {
iter_ = map_->end();
return;
}
--iter_;
}

virtual Slice key() const { return iter_->first; }
virtual Slice value() const { return iter_->second; }
virtual Status status() const { return Status::OK(); }
virtual Slice key() const override { return iter_->first; }
virtual Slice value() const override { return iter_->second; }
virtual Status status() const override { return Status::OK(); }

private:
const KVMap* const map_;
Expand Down Expand Up @@ -171,9 +173,9 @@ class DoubleComparator : public Comparator {
public:
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 db = std::stod(b.ToString());
if (da == db) {
Expand All @@ -185,18 +187,18 @@ class DoubleComparator : public Comparator {
}
}
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 {
public:
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 hb = Hash(b.data(), b.size(), 66);
if (ha == hb) {
Expand All @@ -208,18 +210,18 @@ class HashComparator : public Comparator {
}
}
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 {
public:
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(b.size() >= 2);
size_t size_a1 = static_cast<size_t>(a[0]);
Expand All @@ -240,9 +242,9 @@ class TwoStrComparator : public Comparator {
return a2.compare(b2);
}
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

Expand Down
Loading

0 comments on commit 62247ff

Please sign in to comment.