fix compilation with g++ option `-Wsuggest-override` (#4272)

Summary:
Fixes compilation warnings (which are turned into compilation errors by default) when compiling with g++ option `-Wsuggest-override`.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/4272

Differential Revision: D9322556

Pulled By: siying

fbshipit-source-id: abd57a29ec8f544bee77c0bb438f31be830b7244
main
jsteemann 6 years ago committed by Facebook Github Bot
parent bf07e90cf2
commit 33ad9060d3
  1. 24
      db/range_del_aggregator.cc
  2. 2
      db/snapshot_checker.h
  3. 10
      util/testutil.h
  4. 10
      utilities/env_mirror.cc
  5. 10
      utilities/persistent_cache/persistent_cache_tier.h

@ -50,7 +50,7 @@ class UncollapsedRangeDelMap : public RangeDelMap {
: rep_(TombstoneStartKeyComparator(ucmp)), ucmp_(ucmp) {} : rep_(TombstoneStartKeyComparator(ucmp)), ucmp_(ucmp) {}
bool ShouldDelete(const ParsedInternalKey& parsed, bool ShouldDelete(const ParsedInternalKey& parsed,
RangeDelPositioningMode mode) { RangeDelPositioningMode mode) override {
(void)mode; (void)mode;
assert(mode == RangeDelPositioningMode::kFullScan); assert(mode == RangeDelPositioningMode::kFullScan);
for (const auto& tombstone : rep_) { for (const auto& tombstone : rep_) {
@ -65,7 +65,7 @@ class UncollapsedRangeDelMap : public RangeDelMap {
return false; return false;
} }
bool IsRangeOverlapped(const Slice& start, const Slice& end) { bool IsRangeOverlapped(const Slice& start, const Slice& end) override {
for (const auto& tombstone : rep_) { for (const auto& tombstone : rep_) {
if (ucmp_->Compare(start, tombstone.end_key_) < 0 && if (ucmp_->Compare(start, tombstone.end_key_) < 0 &&
ucmp_->Compare(tombstone.start_key_, end) <= 0 && ucmp_->Compare(tombstone.start_key_, end) <= 0 &&
@ -76,13 +76,13 @@ class UncollapsedRangeDelMap : public RangeDelMap {
return false; return false;
} }
void AddTombstone(RangeTombstone tombstone) { rep_.emplace(tombstone); } void AddTombstone(RangeTombstone tombstone) override { rep_.emplace(tombstone); }
size_t Size() const { return rep_.size(); } size_t Size() const override { return rep_.size(); }
void InvalidatePosition() {} // no-op void InvalidatePosition() override {} // no-op
std::unique_ptr<RangeDelIterator> NewIterator() { std::unique_ptr<RangeDelIterator> NewIterator() override {
return std::unique_ptr<RangeDelIterator>(new Iterator(this->rep_)); return std::unique_ptr<RangeDelIterator>(new Iterator(this->rep_));
} }
}; };
@ -176,7 +176,7 @@ class CollapsedRangeDelMap : public RangeDelMap {
} }
bool ShouldDelete(const ParsedInternalKey& parsed, bool ShouldDelete(const ParsedInternalKey& parsed,
RangeDelPositioningMode mode) { RangeDelPositioningMode mode) override {
if (iter_ == rep_.end() && if (iter_ == rep_.end() &&
(mode == RangeDelPositioningMode::kForwardTraversal || (mode == RangeDelPositioningMode::kForwardTraversal ||
mode == RangeDelPositioningMode::kBackwardTraversal)) { mode == RangeDelPositioningMode::kBackwardTraversal)) {
@ -227,14 +227,14 @@ class CollapsedRangeDelMap : public RangeDelMap {
return parsed.sequence < iter_->second; return parsed.sequence < iter_->second;
} }
bool IsRangeOverlapped(const Slice&, const Slice&) { bool IsRangeOverlapped(const Slice&, const Slice&) override {
// Unimplemented because the only client of this method, file ingestion, // Unimplemented because the only client of this method, file ingestion,
// uses uncollapsed maps. // uses uncollapsed maps.
fprintf(stderr, "CollapsedRangeDelMap::IsRangeOverlapped unimplemented"); fprintf(stderr, "CollapsedRangeDelMap::IsRangeOverlapped unimplemented");
abort(); abort();
} }
void AddTombstone(RangeTombstone t) { void AddTombstone(RangeTombstone t) override {
if (ucmp_->Compare(t.start_key_, t.end_key_) >= 0 || t.seq_ == 0) { if (ucmp_->Compare(t.start_key_, t.end_key_) >= 0 || t.seq_ == 0) {
// The tombstone covers no keys. Nothing to do. // The tombstone covers no keys. Nothing to do.
return; return;
@ -344,11 +344,11 @@ class CollapsedRangeDelMap : public RangeDelMap {
} }
} }
size_t Size() const { return rep_.size() - 1; } size_t Size() const override { return rep_.size() - 1; }
void InvalidatePosition() { iter_ = rep_.end(); } void InvalidatePosition() override { iter_ = rep_.end(); }
std::unique_ptr<RangeDelIterator> NewIterator() { std::unique_ptr<RangeDelIterator> NewIterator() override {
return std::unique_ptr<RangeDelIterator>(new Iterator(this->rep_)); return std::unique_ptr<RangeDelIterator>(new Iterator(this->rep_));
} }
}; };

@ -20,7 +20,7 @@ class DisableGCSnapshotChecker : public SnapshotChecker {
public: public:
virtual ~DisableGCSnapshotChecker() {} virtual ~DisableGCSnapshotChecker() {}
virtual bool IsInSnapshot(SequenceNumber /*sequence*/, virtual bool IsInSnapshot(SequenceNumber /*sequence*/,
SequenceNumber /*snapshot_sequence*/) const { SequenceNumber /*snapshot_sequence*/) const override {
// By returning false, we prevent all the values from being GCed // By returning false, we prevent all the values from being GCed
return false; return false;
} }

@ -247,7 +247,7 @@ class RandomRWStringSink : public RandomRWFile {
public: public:
explicit RandomRWStringSink(StringSink* ss) : ss_(ss) {} explicit RandomRWStringSink(StringSink* ss) : ss_(ss) {}
Status Write(uint64_t offset, const Slice& data) { Status Write(uint64_t offset, const Slice& data) override {
if (offset + data.size() > ss_->contents_.size()) { if (offset + data.size() > ss_->contents_.size()) {
ss_->contents_.resize(offset + data.size(), '\0'); ss_->contents_.resize(offset + data.size(), '\0');
} }
@ -258,7 +258,7 @@ class RandomRWStringSink : public RandomRWFile {
} }
Status Read(uint64_t offset, size_t n, Slice* result, Status Read(uint64_t offset, size_t n, Slice* result,
char* /*scratch*/) const { char* /*scratch*/) const override {
*result = Slice(nullptr, 0); *result = Slice(nullptr, 0);
if (offset < ss_->contents_.size()) { if (offset < ss_->contents_.size()) {
size_t str_res_sz = size_t str_res_sz =
@ -268,11 +268,11 @@ class RandomRWStringSink : public RandomRWFile {
return Status::OK(); return Status::OK();
} }
Status Flush() { return Status::OK(); } Status Flush() override { return Status::OK(); }
Status Sync() { return Status::OK(); } Status Sync() override { return Status::OK(); }
Status Close() { return Status::OK(); } Status Close() override { return Status::OK(); }
const std::string& contents() const { return ss_->contents(); } const std::string& contents() const { return ss_->contents(); }

@ -20,7 +20,7 @@ class SequentialFileMirror : public SequentialFile {
std::string fname; std::string fname;
explicit SequentialFileMirror(std::string f) : fname(f) {} explicit SequentialFileMirror(std::string f) : fname(f) {}
Status Read(size_t n, Slice* result, char* scratch) { Status Read(size_t n, Slice* result, char* scratch) override {
Slice aslice; Slice aslice;
Status as = a_->Read(n, &aslice, scratch); Status as = a_->Read(n, &aslice, scratch);
if (as == Status::OK()) { if (as == Status::OK()) {
@ -44,13 +44,13 @@ class SequentialFileMirror : public SequentialFile {
return as; return as;
} }
Status Skip(uint64_t n) { Status Skip(uint64_t n) override {
Status as = a_->Skip(n); Status as = a_->Skip(n);
Status bs = b_->Skip(n); Status bs = b_->Skip(n);
assert(as == bs); assert(as == bs);
return as; return as;
} }
Status InvalidateCache(size_t offset, size_t length) { Status InvalidateCache(size_t offset, size_t length) override {
Status as = a_->InvalidateCache(offset, length); Status as = a_->InvalidateCache(offset, length);
Status bs = b_->InvalidateCache(offset, length); Status bs = b_->InvalidateCache(offset, length);
assert(as == bs); assert(as == bs);
@ -64,7 +64,7 @@ class RandomAccessFileMirror : public RandomAccessFile {
std::string fname; std::string fname;
explicit RandomAccessFileMirror(std::string f) : fname(f) {} explicit RandomAccessFileMirror(std::string f) : fname(f) {}
Status Read(uint64_t offset, size_t n, Slice* result, char* scratch) const { Status Read(uint64_t offset, size_t n, Slice* result, char* scratch) const override {
Status as = a_->Read(offset, n, result, scratch); Status as = a_->Read(offset, n, result, scratch);
if (as == Status::OK()) { if (as == Status::OK()) {
char* bscratch = new char[n]; char* bscratch = new char[n];
@ -86,7 +86,7 @@ class RandomAccessFileMirror : public RandomAccessFile {
return as; return as;
} }
size_t GetUniqueId(char* id, size_t max_size) const { size_t GetUniqueId(char* id, size_t max_size) const override {
// NOTE: not verified // NOTE: not verified
return a_->GetUniqueId(id, max_size); return a_->GetUniqueId(id, max_size);
} }

@ -251,20 +251,20 @@ class PersistentCacheTier : public PersistentCache {
// Print stats to string recursively // Print stats to string recursively
virtual std::string PrintStats(); virtual std::string PrintStats();
virtual PersistentCache::StatsType Stats(); virtual PersistentCache::StatsType Stats() override;
// Insert to page cache // Insert to page cache
virtual Status Insert(const Slice& page_key, const char* data, virtual Status Insert(const Slice& page_key, const char* data,
const size_t size) = 0; const size_t size) override = 0;
// Lookup page cache by page identifier // Lookup page cache by page identifier
virtual Status Lookup(const Slice& page_key, std::unique_ptr<char[]>* data, virtual Status Lookup(const Slice& page_key, std::unique_ptr<char[]>* data,
size_t* size) = 0; size_t* size) override = 0;
// Does it store compressed data ? // Does it store compressed data ?
virtual bool IsCompressed() = 0; virtual bool IsCompressed() override = 0;
virtual std::string GetPrintableOptions() const = 0; virtual std::string GetPrintableOptions() const override = 0;
// Return a reference to next tier // Return a reference to next tier
virtual Tier& next_tier() { return next_tier_; } virtual Tier& next_tier() { return next_tier_; }

Loading…
Cancel
Save