Skip to content

Commit

Permalink
Apply modernize-use-override (2nd iteration)
Browse files Browse the repository at this point in the history
Summary:
Use C++11’s override and remove virtual where applicable.
Change are automatically generated.

Reviewed By: Orvid

Differential Revision: D14090024

fbshipit-source-id: 1e9432e87d2657e1ff0028e15370a85d1739ba2a
  • Loading branch information
Michael Liu authored and facebook-github-bot committed Feb 14, 2019
1 parent c8c8104 commit ca89ac2
Show file tree
Hide file tree
Showing 106 changed files with 1,250 additions and 1,456 deletions.
3 changes: 1 addition & 2 deletions cache/cache_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ class CacheTest : public testing::TestWithParam<std::string> {
current_ = this;
}

~CacheTest() {
}
~CacheTest() override {}

std::shared_ptr<Cache> NewCache(size_t capacity) {
auto type = GetParam();
Expand Down
49 changes: 23 additions & 26 deletions cache/clock_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -240,32 +240,29 @@ class ClockCacheShard : public CacheShard {
typedef tbb::concurrent_hash_map<CacheKey, CacheHandle*, CacheKey> HashTable;

ClockCacheShard();
~ClockCacheShard();
~ClockCacheShard() override;

// Interfaces
virtual void SetCapacity(size_t capacity) override;
virtual void SetStrictCapacityLimit(bool strict_capacity_limit) override;
virtual Status Insert(const Slice& key, uint32_t hash, void* value,
size_t charge,
void (*deleter)(const Slice& key, void* value),
Cache::Handle** handle,
Cache::Priority priority) override;
virtual Cache::Handle* Lookup(const Slice& key, uint32_t hash) override;
void SetCapacity(size_t capacity) override;
void SetStrictCapacityLimit(bool strict_capacity_limit) override;
Status Insert(const Slice& key, uint32_t hash, void* value, size_t charge,
void (*deleter)(const Slice& key, void* value),
Cache::Handle** handle, Cache::Priority priority) override;
Cache::Handle* Lookup(const Slice& key, uint32_t hash) override;
// If the entry in in cache, increase reference count and return true.
// Return false otherwise.
//
// Not necessary to hold mutex_ before being called.
virtual bool Ref(Cache::Handle* handle) override;
virtual bool Release(Cache::Handle* handle,
bool force_erase = false) override;
virtual void Erase(const Slice& key, uint32_t hash) override;
bool Ref(Cache::Handle* handle) override;
bool Release(Cache::Handle* handle, bool force_erase = false) override;
void Erase(const Slice& key, uint32_t hash) override;
bool EraseAndConfirm(const Slice& key, uint32_t hash,
CleanupContext* context);
virtual size_t GetUsage() const override;
virtual size_t GetPinnedUsage() const override;
virtual void EraseUnRefEntries() override;
virtual void ApplyToAllCacheEntries(void (*callback)(void*, size_t),
bool thread_safe) override;
size_t GetUsage() const override;
size_t GetPinnedUsage() const override;
void EraseUnRefEntries() override;
void ApplyToAllCacheEntries(void (*callback)(void*, size_t),
bool thread_safe) override;

private:
static const uint32_t kInCacheBit = 1;
Expand Down Expand Up @@ -685,31 +682,31 @@ class ClockCache : public ShardedCache {
SetStrictCapacityLimit(strict_capacity_limit);
}

virtual ~ClockCache() { delete[] shards_; }
~ClockCache() override { delete[] shards_; }

virtual const char* Name() const override { return "ClockCache"; }
const char* Name() const override { return "ClockCache"; }

virtual CacheShard* GetShard(int shard) override {
CacheShard* GetShard(int shard) override {
return reinterpret_cast<CacheShard*>(&shards_[shard]);
}

virtual const CacheShard* GetShard(int shard) const override {
const CacheShard* GetShard(int shard) const override {
return reinterpret_cast<CacheShard*>(&shards_[shard]);
}

virtual void* Value(Handle* handle) override {
void* Value(Handle* handle) override {
return reinterpret_cast<const CacheHandle*>(handle)->value;
}

virtual size_t GetCharge(Handle* handle) const override {
size_t GetCharge(Handle* handle) const override {
return reinterpret_cast<const CacheHandle*>(handle)->charge;
}

virtual uint32_t GetHash(Handle* handle) const override {
uint32_t GetHash(Handle* handle) const override {
return reinterpret_cast<const CacheHandle*>(handle)->hash;
}

virtual void DisownData() override { shards_ = nullptr; }
void DisownData() override { shards_ = nullptr; }

private:
ClockCacheShard* shards_;
Expand Down
2 changes: 1 addition & 1 deletion cache/lru_cache_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace rocksdb {
class LRUCacheTest : public testing::Test {
public:
LRUCacheTest() {}
~LRUCacheTest() { DeleteCache(); }
~LRUCacheTest() override { DeleteCache(); }

void DeleteCache() {
if (cache_ != nullptr) {
Expand Down
82 changes: 34 additions & 48 deletions db/c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,10 @@ struct rocksdb_compactionfilter_t : public CompactionFilter {
const char* (*name_)(void*);
unsigned char ignore_snapshots_;

virtual ~rocksdb_compactionfilter_t() {
(*destructor_)(state_);
}
~rocksdb_compactionfilter_t() override { (*destructor_)(state_); }

virtual bool Filter(int level, const Slice& key, const Slice& existing_value,
std::string* new_value,
bool* value_changed) const override {
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 @@ -231,9 +228,9 @@ struct rocksdb_compactionfilter_t : public CompactionFilter {
return result;
}

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

virtual bool IgnoreSnapshots() const override { return ignore_snapshots_; }
bool IgnoreSnapshots() const override { return ignore_snapshots_; }
};

struct rocksdb_compactionfilterfactory_t : public CompactionFilterFactory {
Expand All @@ -243,17 +240,17 @@ struct rocksdb_compactionfilterfactory_t : public CompactionFilterFactory {
void*, rocksdb_compactionfiltercontext_t* context);
const char* (*name_)(void*);

virtual ~rocksdb_compactionfilterfactory_t() { (*destructor_)(state_); }
~rocksdb_compactionfilterfactory_t() override { (*destructor_)(state_); }

virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& context) override {
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 override { return (*name_)(state_); }
const char* Name() const override { return (*name_)(state_); }
};

struct rocksdb_comparator_t : public Comparator {
Expand All @@ -265,20 +262,17 @@ struct rocksdb_comparator_t : public Comparator {
const char* b, size_t blen);
const char* (*name_)(void*);

virtual ~rocksdb_comparator_t() {
(*destructor_)(state_);
}
~rocksdb_comparator_t() override { (*destructor_)(state_); }

virtual int Compare(const Slice& a, const Slice& b) const override {
int Compare(const Slice& a, const Slice& b) const override {
return (*compare_)(state_, a.data(), a.size(), b.data(), b.size());
}

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

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

struct rocksdb_filterpolicy_t : public FilterPolicy {
Expand All @@ -298,14 +292,11 @@ struct rocksdb_filterpolicy_t : public FilterPolicy {
void*,
const char* filter, size_t filter_length);

virtual ~rocksdb_filterpolicy_t() {
(*destructor_)(state_);
}
~rocksdb_filterpolicy_t() override { (*destructor_)(state_); }

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

virtual void CreateFilter(const Slice* keys, int n,
std::string* dst) const override {
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 @@ -323,8 +314,7 @@ struct rocksdb_filterpolicy_t : public FilterPolicy {
}
}

virtual bool KeyMayMatch(const Slice& key,
const Slice& filter) const override {
bool KeyMayMatch(const Slice& key, const Slice& filter) const override {
return (*key_match_)(state_, key.data(), key.size(),
filter.data(), filter.size());
}
Expand All @@ -349,14 +339,12 @@ struct rocksdb_mergeoperator_t : public MergeOperator {
void*,
const char* value, size_t value_length);

virtual ~rocksdb_mergeoperator_t() {
(*destructor_)(state_);
}
~rocksdb_mergeoperator_t() override { (*destructor_)(state_); }

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

virtual bool FullMergeV2(const MergeOperationInput& merge_in,
MergeOperationOutput* merge_out) const override {
bool FullMergeV2(const MergeOperationInput& merge_in,
MergeOperationOutput* merge_out) const override {
size_t n = merge_in.operand_list.size();
std::vector<const char*> operand_pointers(n);
std::vector<size_t> operand_sizes(n);
Expand Down Expand Up @@ -390,10 +378,10 @@ struct rocksdb_mergeoperator_t : public MergeOperator {
return success;
}

virtual bool PartialMergeMulti(const Slice& key,
const std::deque<Slice>& operand_list,
std::string* new_value,
Logger* /*logger*/) const override {
bool PartialMergeMulti(const Slice& key,
const std::deque<Slice>& operand_list,
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 @@ -444,23 +432,21 @@ struct rocksdb_slicetransform_t : public SliceTransform {
void*,
const char* key, size_t length);

virtual ~rocksdb_slicetransform_t() {
(*destructor_)(state_);
}
~rocksdb_slicetransform_t() override { (*destructor_)(state_); }

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

virtual Slice Transform(const Slice& src) const override {
Slice Transform(const Slice& src) const override {
size_t len;
char* dst = (*transform_)(state_, src.data(), src.size(), &len);
return Slice(dst, len);
}

virtual bool InDomain(const Slice& src) const override {
bool InDomain(const Slice& src) const override {
return (*in_domain_)(state_, src.data(), src.size());
}

virtual bool InRange(const Slice& src) const override {
bool InRange(const Slice& src) const override {
return (*in_range_)(state_, src.data(), src.size());
}
};
Expand Down Expand Up @@ -1495,10 +1481,10 @@ class H : public WriteBatch::Handler {
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) override {
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) override {
void Delete(const Slice& key) override {
(*deleted_)(state_, key.data(), key.size());
}
};
Expand Down Expand Up @@ -2966,7 +2952,7 @@ rocksdb_filterpolicy_t* rocksdb_filterpolicy_create_bloom_format(int bits_per_ke
// supplied C functions.
struct Wrapper : public rocksdb_filterpolicy_t {
const FilterPolicy* rep_;
~Wrapper() { delete rep_; }
~Wrapper() override { delete rep_; }
const char* Name() const override { return rep_->Name(); }
void CreateFilter(const Slice* keys, int n,
std::string* dst) const override {
Expand Down Expand Up @@ -3421,7 +3407,7 @@ void rocksdb_slicetransform_destroy(rocksdb_slicetransform_t* st) {

struct Wrapper : public rocksdb_slicetransform_t {
const SliceTransform* rep_;
~Wrapper() { delete rep_; }
~Wrapper() override { delete rep_; }
const char* Name() const override { return rep_->Name(); }
Slice Transform(const Slice& src) const override {
return rep_->Transform(src);
Expand Down
2 changes: 1 addition & 1 deletion db/column_family_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class ColumnFamilyTestBase : public testing::Test {
DestroyDB(dbname_, Options(db_options_, column_family_options_));
}

virtual ~ColumnFamilyTestBase() {
~ColumnFamilyTestBase() override {
std::vector<ColumnFamilyDescriptor> column_families;
for (auto h : handles_) {
ColumnFamilyDescriptor cfdescriptor;
Expand Down
12 changes: 6 additions & 6 deletions db/compact_files_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ class CompactFilesTest : public testing::Test {
class FlushedFileCollector : public EventListener {
public:
FlushedFileCollector() {}
~FlushedFileCollector() {}
~FlushedFileCollector() override {}

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

virtual const char* Name() const override { return "FilterWithGet"; }
const char* Name() const override { return "FilterWithGet"; }

private:
DB* db_;
Expand Down
Loading

0 comments on commit ca89ac2

Please sign in to comment.