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
This commit is contained in:
Igor Sugak 2015-02-26 11:28:41 -08:00
parent 1e06a40685
commit 62247ffa3b
71 changed files with 928 additions and 927 deletions

106
db/c.cc
View File

@ -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;
@ -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 {
@ -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 {
@ -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);
@ -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;
@ -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 {
@ -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++) {
@ -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());
}
@ -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);
@ -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);
@ -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());
}
};
@ -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());
}
};
@ -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*) { }
@ -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;

View File

@ -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:

View File

@ -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);
}
@ -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) {

View File

@ -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;
}

View File

@ -33,18 +33,20 @@ 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;
@ -52,9 +54,9 @@ class KVIter : public Iterator {
--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_;
@ -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) {
@ -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) {
@ -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]);
@ -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

View File

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

View File

@ -891,7 +891,7 @@ Status DBImpl::RecoverLogFiles(const std::vector<uint64_t>& log_numbers,
Logger* info_log;
const char* fname;
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,
info_log, "%s%s: dropping %d bytes; %s",
(this->status == nullptr ? "(ignoring error) " : ""),

View File

@ -62,30 +62,33 @@ class DBImpl : public DB {
using DB::Put;
virtual Status Put(const WriteOptions& options,
ColumnFamilyHandle* column_family, const Slice& key,
const Slice& value);
const Slice& value) override;
using DB::Merge;
virtual Status Merge(const WriteOptions& options,
ColumnFamilyHandle* column_family, const Slice& key,
const Slice& value);
const Slice& value) override;
using DB::Delete;
virtual Status Delete(const WriteOptions& options,
ColumnFamilyHandle* column_family, const Slice& key);
ColumnFamilyHandle* column_family,
const Slice& key) override;
using DB::Write;
virtual Status Write(const WriteOptions& options, WriteBatch* updates);
virtual Status Write(const WriteOptions& options,
WriteBatch* updates) override;
using DB::Get;
virtual Status Get(const ReadOptions& options,
ColumnFamilyHandle* column_family, const Slice& key,
std::string* value);
std::string* value) override;
using DB::MultiGet;
virtual std::vector<Status> MultiGet(
const ReadOptions& options,
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,
const std::string& column_family,
ColumnFamilyHandle** handle);
virtual Status DropColumnFamily(ColumnFamilyHandle* column_family);
ColumnFamilyHandle** handle) override;
virtual Status DropColumnFamily(ColumnFamilyHandle* column_family) override;
// 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
@ -94,75 +97,81 @@ class DBImpl : public DB {
using DB::KeyMayExist;
virtual bool KeyMayExist(const ReadOptions& options,
ColumnFamilyHandle* column_family, const Slice& key,
std::string* value, bool* value_found = nullptr);
std::string* value,
bool* value_found = nullptr) override;
using DB::NewIterator;
virtual Iterator* NewIterator(const ReadOptions& options,
ColumnFamilyHandle* column_family);
ColumnFamilyHandle* column_family) override;
virtual Status NewIterators(
const ReadOptions& options,
const std::vector<ColumnFamilyHandle*>& column_families,
std::vector<Iterator*>* iterators);
virtual const Snapshot* GetSnapshot();
virtual void ReleaseSnapshot(const Snapshot* snapshot);
std::vector<Iterator*>* iterators) override;
virtual const Snapshot* GetSnapshot() override;
virtual void ReleaseSnapshot(const Snapshot* snapshot) override;
using DB::GetProperty;
virtual bool GetProperty(ColumnFamilyHandle* column_family,
const Slice& property, std::string* value);
const Slice& property, std::string* value) override;
using DB::GetIntProperty;
virtual bool GetIntProperty(ColumnFamilyHandle* column_family,
const Slice& property, uint64_t* value) override;
using DB::GetApproximateSizes;
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;
virtual Status CompactRange(ColumnFamilyHandle* column_family,
const Slice* begin, const Slice* end,
bool reduce_level = false, int target_level = -1,
uint32_t target_path_id = 0);
uint32_t target_path_id = 0) override;
using DB::CompactFiles;
virtual Status CompactFiles(
const CompactionOptions& compact_options,
ColumnFamilyHandle* column_family,
const std::vector<std::string>& input_file_names,
const int output_level, const int output_path_id = -1);
virtual Status CompactFiles(const CompactionOptions& compact_options,
ColumnFamilyHandle* column_family,
const std::vector<std::string>& input_file_names,
const int output_level,
const int output_path_id = -1) override;
using DB::SetOptions;
Status SetOptions(ColumnFamilyHandle* column_family,
const std::unordered_map<std::string, std::string>& options_map);
Status SetOptions(
ColumnFamilyHandle* column_family,
const std::unordered_map<std::string, std::string>& options_map) override;
using DB::NumberLevels;
virtual int NumberLevels(ColumnFamilyHandle* column_family);
virtual int NumberLevels(ColumnFamilyHandle* column_family) override;
using DB::MaxMemCompactionLevel;
virtual int MaxMemCompactionLevel(ColumnFamilyHandle* column_family);
virtual int MaxMemCompactionLevel(ColumnFamilyHandle* column_family) override;
using DB::Level0StopWriteTrigger;
virtual int Level0StopWriteTrigger(ColumnFamilyHandle* column_family);
virtual const std::string& GetName() const;
virtual Env* GetEnv() const;
virtual int Level0StopWriteTrigger(
ColumnFamilyHandle* column_family) override;
virtual const std::string& GetName() const override;
virtual Env* GetEnv() const override;
using DB::GetOptions;
virtual const Options& GetOptions(ColumnFamilyHandle* column_family) const;
virtual const Options& GetOptions(
ColumnFamilyHandle* column_family) const override;
using DB::Flush;
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
virtual Status DisableFileDeletions();
virtual Status EnableFileDeletions(bool force);
virtual Status DisableFileDeletions() override;
virtual Status EnableFileDeletions(bool force) override;
virtual int IsFileDeletionsEnabled() const;
// All the returned filenames start with "/"
virtual Status GetLiveFiles(std::vector<std::string>&,
uint64_t* manifest_file_size,
bool flush_memtable = true);
virtual Status GetSortedWalFiles(VectorLogPtr& files);
bool flush_memtable = true) override;
virtual Status GetSortedWalFiles(VectorLogPtr& files) override;
virtual Status GetUpdatesSince(
SequenceNumber seq_number, unique_ptr<TransactionLogIterator>* iter,
const TransactionLogIterator::ReadOptions&
read_options = TransactionLogIterator::ReadOptions());
virtual Status DeleteFile(std::string name);
read_options = TransactionLogIterator::ReadOptions()) override;
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.
// 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
virtual Status CheckConsistency();
virtual Status GetDbIdentity(std::string& identity);
virtual Status GetDbIdentity(std::string& identity) override;
Status RunManualCompaction(ColumnFamilyData* cfd, int input_level,
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.
void PurgeObsoleteFiles(const JobContext& background_contet);
ColumnFamilyHandle* DefaultColumnFamily() const;
ColumnFamilyHandle* DefaultColumnFamily() const override;
const SnapshotList& snapshots() const { return snapshots_; }

View File

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

View File

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

View File

@ -111,12 +111,11 @@ class InternalKeyComparator : public Comparator {
}
virtual ~InternalKeyComparator() {}
virtual const char* Name() const;
virtual int Compare(const Slice& a, const Slice& b) const;
virtual void FindShortestSeparator(
std::string* start,
const Slice& limit) const;
virtual void FindShortSuccessor(std::string* key) const;
virtual const char* Name() const override;
virtual int Compare(const Slice& a, const Slice& b) const override;
virtual void FindShortestSeparator(std::string* start,
const Slice& limit) const override;
virtual void FindShortSuccessor(std::string* key) const override;
const Comparator* user_comparator() const { return user_comparator_; }
@ -371,19 +370,19 @@ class InternalKeySliceTransform : public SliceTransform {
explicit InternalKeySliceTransform(const SliceTransform* 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);
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);
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);
return transform_->InRange(user_key);
}

View File

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

View File

@ -19,7 +19,7 @@ namespace rocksdb {
class IntComparator : public Comparator {
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(b.size() == 8);
int64_t diff = *reinterpret_cast<const int64_t*>(a.data()) -
@ -33,13 +33,12 @@ class IntComparator : public Comparator {
}
}
const char* Name() const {
return "IntComparator";
}
const char* Name() const override { 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 {

View File

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

View File

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

View File

@ -55,8 +55,8 @@ class LogTest {
reader_contents_ = Slice(contents_.data(), 0);
};
virtual Status Close() { return Status::OK(); }
virtual Status Flush() {
virtual Status Close() override { return Status::OK(); }
virtual Status Flush() override {
ASSERT_TRUE(reader_contents_.size() <= last_flush_);
size_t offset = last_flush_ - reader_contents_.size();
reader_contents_ = Slice(
@ -66,8 +66,8 @@ class LogTest {
return Status::OK();
}
virtual Status Sync() { return Status::OK(); }
virtual Status Append(const Slice& slice) {
virtual Status Sync() override { return Status::OK(); }
virtual Status Append(const Slice& slice) override {
contents_.append(slice.data(), slice.size());
return Status::OK();
}
@ -99,7 +99,7 @@ class LogTest {
force_eof_position_(0),
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";
if (force_error_) {
@ -138,7 +138,7 @@ class LogTest {
return Status::OK();
}
virtual Status Skip(uint64_t n) {
virtual Status Skip(uint64_t n) override {
if (n > contents_.size()) {
contents_.clear();
return Status::NotFound("in-memory file skipepd past end");
@ -156,7 +156,7 @@ class LogTest {
std::string message_;
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;
message_.append(status.ToString());
}

View File

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

View File

@ -59,7 +59,7 @@ class MemTable {
const InternalKeyComparator comparator;
explicit KeyComparator(const InternalKeyComparator& c) : comparator(c) { }
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,
const Slice& key) const override;
};

View File

@ -57,7 +57,8 @@ class CountMergeOperator : public AssociativeMergeOperator {
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 {
++num_partial_merge_calls;
return mergeOperator_->PartialMergeMulti(key, operand_list, new_value,
logger);

View File

@ -70,7 +70,7 @@ class TestKeyComparator : public Comparator {
// Compare needs to be aware of the possibility of a and/or b is
// 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_b = SliceToTestKey(b);
if (key_a->prefix != key_b->prefix) {
@ -106,13 +106,10 @@ class TestKeyComparator : public Comparator {
return "TestKeyComparator";
}
virtual void FindShortestSeparator(
std::string* start,
const Slice& limit) const {
}
virtual void FindShortSuccessor(std::string* key) const {}
virtual void FindShortestSeparator(std::string* start,
const Slice& limit) const override {}
virtual void FindShortSuccessor(std::string* key) const override {}
};
namespace {

View File

@ -189,7 +189,7 @@ class Repairer {
Env* env;
std::shared_ptr<Logger> info_log;
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.
Log(InfoLogLevel::ERROR_LEVEL, info_log,
"Log #%" PRIu64 ": dropping %d bytes; %s", lognum,

View File

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

View File

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

View File

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

View File

@ -27,20 +27,20 @@ class LogFileImpl : public LogFile {
sizeFileBytes_(sizeBytes) {
}
std::string PathName() const {
std::string PathName() const override {
if (type_ == kArchivedLogFile) {
return ArchivedLogFileName("", 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 {
return LogNumber() < that.LogNumber();
@ -62,13 +62,13 @@ class TransactionLogIteratorImpl : public TransactionLogIterator {
const EnvOptions& soptions, const SequenceNumber seqNum,
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:
const std::string& dir_;
@ -88,7 +88,7 @@ class TransactionLogIteratorImpl : public TransactionLogIterator {
struct LogReporter : public log::Reader::Reporter {
Env* env;
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,
s.ToString().c_str());
}

View File

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

View File

@ -606,7 +606,7 @@ class VersionSet {
struct LogReporter : public log::Reader::Reporter {
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;
}
};

View File

@ -416,7 +416,7 @@ Status WalManager::ReadFirstLine(const std::string& fname,
Status* status;
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,
"[WalManager] %s%s: dropping %d bytes; %s",
(this->ignore_error ? "(ignoring error) " : ""), fname,

View File

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

View File

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

View File

@ -246,91 +246,114 @@ class HdfsEnv : public Env {
virtual Status NewSequentialFile(const std::string& fname,
unique_ptr<SequentialFile>* result,
const EnvOptions& options);
const EnvOptions& options) override;
virtual Status NewRandomAccessFile(const std::string& fname,
unique_ptr<RandomAccessFile>* result,
const EnvOptions& options) {
const EnvOptions& options) override {
return notsup;
}
virtual Status NewWritableFile(const std::string& fname,
unique_ptr<WritableFile>* result,
const EnvOptions& options) {
const EnvOptions& options) override {
return notsup;
}
virtual Status NewRandomRWFile(const std::string& fname,
unique_ptr<RandomRWFile>* result,
const EnvOptions& options) {
const EnvOptions& options) override {
return notsup;
}
virtual Status NewDirectory(const std::string& name,
unique_ptr<Directory>* result) {
unique_ptr<Directory>* result) override {
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,
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,
uint64_t* time) {
uint64_t* time) override {
return notsup;
}
virtual Status RenameFile(const std::string& src, const std::string& target){return notsup;}
virtual Status LinkFile(const std::string& src, const std::string& target) {
virtual Status RenameFile(const std::string& src,
const std::string& target) override {
return notsup;
}
virtual Status LockFile(const std::string& fname, FileLock** lock){return notsup;}
virtual Status LinkFile(const std::string& src,
const std::string& target) override {
return notsup;
}
virtual Status UnlockFile(FileLock* lock){return notsup;}
virtual Status LockFile(const std::string& fname, FileLock** lock) override {
return notsup;
}
virtual Status UnlockFile(FileLock* lock) override { return notsup; }
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,
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;
}
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,
std::string* outputpath) {return notsup;}
std::string* outputpath) override {
return notsup;
}
virtual void SetBackgroundThreads(int number, Priority pri = LOW) {}
virtual void IncBackgroundThreadsIfNeeded(int number, Priority pri) {}
virtual std::string TimeToString(uint64_t number) { return "";}
virtual void SetBackgroundThreads(int number, Priority pri = LOW) override {}
virtual void IncBackgroundThreadsIfNeeded(int number, Priority pri) override {
}
virtual std::string TimeToString(uint64_t number) override { return ""; }
};
}

View File

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

View File

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

View File

@ -21,18 +21,18 @@ namespace rocksdb {
// For testing: emit an array with one hash value per key
class TestHashFilter : public FilterPolicy {
public:
virtual const char* Name() const {
return "TestHashFilter";
}
virtual const char* Name() const override { 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++) {
uint32_t h = Hash(keys[i].data(), keys[i].size(), 1);
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);
for (unsigned int i = 0; i + 4 <= filter.size(); i += 4) {
if (h == DecodeFixed32(filter.data() + i)) {

View File

@ -395,13 +395,13 @@ class BlockBasedTableBuilder::BlockBasedTablePropertiesCollector
whole_key_filtering_(whole_key_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
// individual key/value pairs.
return Status::OK();
}
virtual Status Finish(UserCollectedProperties* properties) {
virtual Status Finish(UserCollectedProperties* properties) override {
std::string val;
PutFixed32(&val, static_cast<uint32_t>(index_type_));
properties->insert({BlockBasedTablePropertyNames::kIndexType, val});
@ -413,11 +413,11 @@ class BlockBasedTableBuilder::BlockBasedTablePropertiesCollector
}
// 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";
}
virtual UserCollectedProperties GetReadableProperties() const {
virtual UserCollectedProperties GetReadableProperties() const override {
// Intentionally left blank.
return UserCollectedProperties();
}

View File

@ -22,28 +22,28 @@ class MapIterator : public Iterator {
public:
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_;
}
virtual void Seek(const Slice& target) {
virtual void Seek(const Slice& target) override {
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:
const Data& data_;

View File

@ -62,18 +62,18 @@ class TestFilterBitsReader : public FilterBitsReader {
class TestHashFilter : public FilterPolicy {
public:
virtual const char* Name() const {
return "TestHashFilter";
}
virtual const char* Name() const override { 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++) {
uint32_t h = Hash(keys[i].data(), keys[i].size(), 1);
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);
for (unsigned int i = 0; i + 4 <= filter.size(); i += 4) {
if (h == DecodeFixed32(filter.data() + i)) {

View File

@ -49,15 +49,22 @@ namespace {
class EmptyIterator : public Iterator {
public:
explicit EmptyIterator(const Status& s) : status_(s) { }
virtual bool Valid() const { return false; }
virtual void Seek(const Slice& target) { }
virtual void SeekToFirst() { }
virtual void SeekToLast() { }
virtual void Next() { assert(false); }
virtual void Prev() { assert(false); }
Slice key() const { assert(false); return Slice(); }
Slice value() const { assert(false); return Slice(); }
virtual Status status() const { return status_; }
virtual bool Valid() const override { return false; }
virtual void Seek(const Slice& target) override {}
virtual void SeekToFirst() override {}
virtual void SeekToLast() override {}
virtual void Next() override { assert(false); }
virtual void Prev() override { assert(false); }
Slice key() const override {
assert(false);
return Slice();
}
Slice value() const override {
assert(false);
return Slice();
}
virtual Status status() const override { return status_; }
private:
Status status_;
};

View File

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

View File

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

View File

@ -60,23 +60,23 @@ class MockTableIterator : public Iterator {
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_;
}
void Seek(const Slice& target) {
void Seek(const Slice& target) override {
std::string str_target(target.data(), target.size());
itr_ = table_.lower_bound(str_target);
}
void Next() { ++itr_; }
void Next() override { ++itr_; }
void Prev() {
void Prev() override {
if (itr_ == table_.begin()) {
itr_ = table_.end();
} 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:
const MockFileContents& table_;
@ -139,13 +139,13 @@ class MockTableFactory : public TableFactory {
const EnvOptions& env_options,
const InternalKeyComparator& internal_key,
unique_ptr<RandomAccessFile>&& file, uint64_t file_size,
unique_ptr<TableReader>* table_reader) const;
unique_ptr<TableReader>* table_reader) const override;
TableBuilder* NewTableBuilder(
const ImmutableCFOptions& ioptions,
const InternalKeyComparator& internal_key, WritableFile* file,
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
// 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,
MockFileContents file_contents);
virtual Status SanitizeOptions(const DBOptions& db_opts,
const ColumnFamilyOptions& cf_opts) const {
virtual Status SanitizeOptions(
const DBOptions& db_opts,
const ColumnFamilyOptions& cf_opts) const override {
return Status::OK();
}

View File

@ -56,23 +56,23 @@ class PlainTableIterator : public Iterator {
explicit PlainTableIterator(PlainTableReader* table, bool use_prefix_seek);
~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:
PlainTableReader* table_;

View File

@ -64,17 +64,17 @@ class PlainTableReader: public TableReader {
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,
GetContext* get_context) override;
uint64_t ApproximateOffsetOf(const Slice& key);
uint64_t ApproximateOffsetOf(const Slice& key) override;
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_;
}

View File

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

View File

@ -29,24 +29,22 @@ class TwoLevelIterator: public Iterator {
second_level_iter_.DeleteIter(false);
}
virtual void Seek(const Slice& target);
virtual void SeekToFirst();
virtual void SeekToLast();
virtual void Next();
virtual void Prev();
virtual void Seek(const Slice& target) override;
virtual void SeekToFirst() override;
virtual void SeekToLast() override;
virtual void Next() override;
virtual void Prev() override;
virtual bool Valid() const {
return second_level_iter_.Valid();
}
virtual Slice key() const {
virtual bool Valid() const override { return second_level_iter_.Valid(); }
virtual Slice key() const override {
assert(Valid());
return second_level_iter_.key();
}
virtual Slice value() const {
virtual Slice value() const override {
assert(Valid());
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
if (!first_level_iter_.status().ok()) {
return first_level_iter_.status();

View File

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

View File

@ -41,7 +41,7 @@ class AutoRollLogger : public Logger {
}
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
// again every time the log rolls over.
@ -52,11 +52,9 @@ class AutoRollLogger : public Logger {
return status_;
}
size_t GetLogFileSize() const {
return logger_->GetLogFileSize();
}
size_t GetLogFileSize() const override { return logger_->GetLogFileSize(); }
void Flush() {
void Flush() override {
if (logger_) {
logger_->Flush();
}

View File

@ -471,34 +471,33 @@ class ShardedLRUCache : public Cache {
delete[] shards_;
}
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);
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);
return shards_[Shard(hash)].Lookup(key, hash);
}
virtual void Release(Handle* handle) {
virtual void Release(Handle* handle) override {
LRUHandle* h = reinterpret_cast<LRUHandle*>(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);
shards_[Shard(hash)].Erase(key, hash);
}
virtual void* Value(Handle* handle) {
virtual void* Value(Handle* handle) override {
return reinterpret_cast<LRUHandle*>(handle)->value;
}
virtual uint64_t NewId() {
virtual uint64_t NewId() override {
MutexLock l(&id_mutex_);
return ++(last_id_);
}
virtual size_t GetCapacity() const {
return capacity_;
}
virtual size_t GetCapacity() const override { 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.
// for (size_t i = 0; i < num_shard_bits_; ++i)
int num_shards = 1 << num_shard_bits_;
@ -509,9 +508,7 @@ class ShardedLRUCache : public Cache {
return usage;
}
virtual void DisownData() {
shards_ = nullptr;
}
virtual void DisownData() override { shards_ = nullptr; }
virtual void ApplyToAllCacheEntries(void (*callback)(void*, size_t),
bool thread_safe) override {

View File

@ -23,17 +23,16 @@ class BytewiseComparatorImpl : public Comparator {
public:
BytewiseComparatorImpl() { }
virtual const char* Name() const {
virtual const char* Name() const override {
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);
}
virtual void FindShortestSeparator(
std::string* start,
const Slice& limit) const {
virtual void FindShortestSeparator(std::string* start,
const Slice& limit) const override {
// Find length of common prefix
size_t min_length = std::min(start->size(), limit.size());
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
size_t n = key->size();
for (size_t i = 0; i < n; i++) {
@ -74,11 +73,11 @@ class ReverseBytewiseComparatorImpl : public BytewiseComparatorImpl {
public:
ReverseBytewiseComparatorImpl() { }
virtual const char* Name() const {
virtual const char* Name() const override {
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);
}
};

View File

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

View File

@ -252,33 +252,32 @@ class HashLinkListRep : public MemTableRep {
}
// Returns true iff the iterator is positioned at a valid node.
virtual bool Valid() const {
return iter_.Valid();
}
virtual bool Valid() const override { return iter_.Valid(); }
// Returns the key at the current position.
// REQUIRES: Valid()
virtual const char* key() const {
virtual const char* key() const override {
assert(Valid());
return iter_.key();
}
// Advances to the next position.
// REQUIRES: Valid()
virtual void Next() {
virtual void Next() override {
assert(Valid());
iter_.Next();
}
// Advances to the previous position.
// REQUIRES: Valid()
virtual void Prev() {
virtual void Prev() override {
assert(Valid());
iter_.Prev();
}
// 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 =
(memtable_key != nullptr) ?
memtable_key : EncodeKey(&tmp_, internal_key);
@ -287,15 +286,11 @@ class HashLinkListRep : public MemTableRep {
// Position at the first entry in collection.
// Final state of iterator is Valid() iff collection is not empty.
virtual void SeekToFirst() {
iter_.SeekToFirst();
}
virtual void SeekToFirst() override { iter_.SeekToFirst(); }
// Position at the last entry in collection.
// Final state of iterator is Valid() iff collection is not empty.
virtual void SeekToLast() {
iter_.SeekToLast();
}
virtual void SeekToLast() override { iter_.SeekToLast(); }
private:
MemtableSkipList::Iterator iter_;
// To destruct with the iterator.
@ -315,41 +310,40 @@ class HashLinkListRep : public MemTableRep {
virtual ~LinkListIterator() {}
// Returns true iff the iterator is positioned at a valid node.
virtual bool Valid() const {
return node_ != nullptr;
}
virtual bool Valid() const override { return node_ != nullptr; }
// Returns the key at the current position.
// REQUIRES: Valid()
virtual const char* key() const {
virtual const char* key() const override {
assert(Valid());
return node_->key;
}
// Advances to the next position.
// REQUIRES: Valid()
virtual void Next() {
virtual void Next() override {
assert(Valid());
node_ = node_->Next();
}
// Advances to the previous position.
// REQUIRES: Valid()
virtual void Prev() {
virtual void Prev() override {
// Prefix iterator does not support total order.
// We simply set the iterator to invalid state
Reset(nullptr);
}
// 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_,
internal_key);
}
// Position at the first entry in collection.
// 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.
// We simply set the iterator to invalid state
Reset(nullptr);
@ -357,7 +351,7 @@ class HashLinkListRep : public MemTableRep {
// Position at the last entry in collection.
// 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.
// We simply set the iterator to invalid state
Reset(nullptr);
@ -386,7 +380,7 @@ class HashLinkListRep : public MemTableRep {
memtable_rep_(memtable_rep) {}
// 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* 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_) {
return skip_list_iter_->Valid();
}
return HashLinkListRep::LinkListIterator::Valid();
}
virtual const char* key() const {
virtual const char* key() const override {
if (skip_list_iter_) {
return skip_list_iter_->key();
}
return HashLinkListRep::LinkListIterator::key();
}
virtual void Next() {
virtual void Next() override {
if (skip_list_iter_) {
skip_list_iter_->Next();
} else {
@ -448,18 +442,18 @@ class HashLinkListRep : public MemTableRep {
// instantiating an empty bucket over which to iterate.
public:
EmptyIterator() { }
virtual bool Valid() const {
return false;
}
virtual const char* key() const {
virtual bool Valid() const override { return false; }
virtual const char* key() const override {
assert(false);
return nullptr;
}
virtual void Next() { }
virtual void Prev() { }
virtual void Seek(const Slice& user_key, const char* memtable_key) { }
virtual void SeekToFirst() { }
virtual void SeekToLast() { }
virtual void Next() override {}
virtual void Prev() override {}
virtual void Seek(const Slice& user_key,
const char* memtable_key) override {}
virtual void SeekToFirst() override {}
virtual void SeekToLast() override {}
private:
};
};

View File

@ -94,33 +94,34 @@ class HashSkipListRep : public MemTableRep {
}
// 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();
}
// Returns the key at the current position.
// REQUIRES: Valid()
virtual const char* key() const {
virtual const char* key() const override {
assert(Valid());
return iter_.key();
}
// Advances to the next position.
// REQUIRES: Valid()
virtual void Next() {
virtual void Next() override {
assert(Valid());
iter_.Next();
}
// Advances to the previous position.
// REQUIRES: Valid()
virtual void Prev() {
virtual void Prev() override {
assert(Valid());
iter_.Prev();
}
// 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) {
const char* encoded_key =
(memtable_key != nullptr) ?
@ -131,7 +132,7 @@ class HashSkipListRep : public MemTableRep {
// Position at the first entry in collection.
// Final state of iterator is Valid() iff collection is not empty.
virtual void SeekToFirst() {
virtual void SeekToFirst() override {
if (list_ != nullptr) {
iter_.SeekToFirst();
}
@ -139,7 +140,7 @@ class HashSkipListRep : public MemTableRep {
// Position at the last entry in collection.
// Final state of iterator is Valid() iff collection is not empty.
virtual void SeekToLast() {
virtual void SeekToLast() override {
if (list_ != nullptr) {
iter_.SeekToLast();
}
@ -173,7 +174,7 @@ class HashSkipListRep : public MemTableRep {
memtable_rep_(memtable_rep) {}
// 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));
Reset(memtable_rep_.GetBucket(transformed));
HashSkipListRep::Iterator::Seek(k, memtable_key);
@ -181,7 +182,7 @@ class HashSkipListRep : public MemTableRep {
// Position at the first entry in collection.
// 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.
// We simply set the iterator to invalid state
Reset(nullptr);
@ -189,7 +190,7 @@ class HashSkipListRep : public MemTableRep {
// Position at the last entry in collection.
// 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.
// We simply set the iterator to invalid state
Reset(nullptr);
@ -204,19 +205,18 @@ class HashSkipListRep : public MemTableRep {
// instantiating an empty bucket over which to iterate.
public:
EmptyIterator() { }
virtual bool Valid() const {
return false;
}
virtual const char* key() const {
virtual bool Valid() const override { return false; }
virtual const char* key() const override {
assert(false);
return nullptr;
}
virtual void Next() { }
virtual void Prev() { }
virtual void Next() override {}
virtual void Prev() override {}
virtual void Seek(const Slice& internal_key,
const char* memtable_key) { }
virtual void SeekToFirst() { }
virtual void SeekToLast() { }
const char* memtable_key) override {}
virtual void SeekToFirst() override {}
virtual void SeekToLast() override {}
private:
};
};

View File

@ -1343,7 +1343,7 @@ void ChangeCompactionStyleCommand::DoCommand() {
namespace {
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";
}
};
@ -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 : ";
commonPutMerge(key, value);
}
virtual void Merge(const Slice& key, const Slice& value) {
virtual void Merge(const Slice& key, const Slice& value) override {
row_ << "MERGE : ";
commonPutMerge(key, value);
}
virtual void Delete(const Slice& key) {
virtual void Delete(const Slice& key) override {
row_ <<",DELETE : ";
row_ << LDBCommand::StringToHex(key.ToString()) << " ";
}

View File

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

View File

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

View File

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

View File

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

View File

@ -29,56 +29,58 @@ class MockEnv : public EnvWrapper {
// Partial implementation of the Env interface.
virtual Status NewSequentialFile(const std::string& fname,
unique_ptr<SequentialFile>* result,
const EnvOptions& soptions);
const EnvOptions& soptions) override;
virtual Status NewRandomAccessFile(const std::string& fname,
unique_ptr<RandomAccessFile>* result,
const EnvOptions& soptions);
const EnvOptions& soptions) override;
virtual Status NewWritableFile(const std::string& fname,
unique_ptr<WritableFile>* result,
const EnvOptions& env_options);
const EnvOptions& env_options) override;
virtual Status NewRandomRWFile(const std::string& fname,
unique_ptr<RandomRWFile>* result,
const EnvOptions& options);
const EnvOptions& options) override;
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,
std::vector<std::string>* result);
std::vector<std::string>* result) override;
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,
uint64_t* time);
uint64_t* time) override;
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,
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
Status Truncate(const std::string& fname, size_t size);

View File

@ -51,7 +51,7 @@ class PosixLogger : public Logger {
virtual ~PosixLogger() {
fclose(file_);
}
virtual void Flush() {
virtual void Flush() override {
if (flush_pending_) {
flush_pending_ = false;
fflush(file_);
@ -60,7 +60,7 @@ class PosixLogger : public Logger {
}
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_)();
// We try twice: the first time with a fixed-size stack allocated buffer,
@ -156,9 +156,7 @@ class PosixLogger : public Logger {
break;
}
}
size_t GetLogFileSize() const {
return log_size_;
}
size_t GetLogFileSize() const override { return log_size_; }
};
} // namespace rocksdb

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -30,27 +30,25 @@ class GeoDBImpl : public GeoDB {
// Associate the GPS location with the identified by 'id'. The value
// 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
// location and is identified by the 'id'.
virtual Status GetByPosition(const GeoPosition& pos,
const Slice& id,
std::string* value);
virtual Status GetByPosition(const GeoPosition& pos, const Slice& id,
std::string* value) override;
// Retrieve the value of the object identified by the 'id'. This method
// 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
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
// specified gps location
virtual Status SearchRadial(const GeoPosition& pos,
double radius,
virtual Status SearchRadial(const GeoPosition& pos, double radius,
std::vector<GeoObject>* values,
int number_of_values);
int number_of_values) override;
private:
DB* db_;

View File

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

View File

@ -244,7 +244,7 @@ Status DBWithTTLImpl::Write(const WriteOptions& opts, WriteBatch* updates) {
WriteBatch updates_ttl;
Status batch_rewrite_status;
virtual Status PutCF(uint32_t column_family_id, const Slice& key,
const Slice& value) {
const Slice& value) override {
std::string value_with_ts;
Status st = AppendTS(value, &value_with_ts, env_);
if (!st.ok()) {
@ -256,7 +256,7 @@ Status DBWithTTLImpl::Write(const WriteOptions& opts, WriteBatch* updates) {
return Status::OK();
}
virtual Status MergeCF(uint32_t column_family_id, const Slice& key,
const Slice& value) {
const Slice& value) override {
std::string value_with_ts;
Status st = AppendTS(value, &value_with_ts, env_);
if (!st.ok()) {
@ -267,11 +267,14 @@ Status DBWithTTLImpl::Write(const WriteOptions& opts, WriteBatch* updates) {
}
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);
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:
Env* env_;

View File

@ -71,7 +71,7 @@ class DBWithTTLImpl : public DBWithTTL {
virtual Iterator* NewIterator(const ReadOptions& opts,
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);
@ -95,26 +95,26 @@ class TtlIterator : public Iterator {
~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 {
return DecodeFixed32(iter_->value().data() + iter_->value().size() -
DBWithTTLImpl::kTSLength);
}
Slice value() const {
Slice value() const override {
// TODO: handle timestamp corruption like in general iterator semantics
assert(DBWithTTLImpl::SanityCheckTimestamp(iter_->value()).ok());
Slice trimmed_value = iter_->value();
@ -122,7 +122,7 @@ class TtlIterator : public Iterator {
return trimmed_value;
}
Status status() const { return iter_->status(); }
Status status() const override { return iter_->status(); }
private:
Iterator* iter_;
@ -187,7 +187,7 @@ class TtlCompactionFilterFactory : public CompactionFilterFactory {
: ttl_(ttl), env_(env), user_comp_filter_factory_(comp_filter_factory) {}
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& context) {
const CompactionFilter::Context& context) override {
return std::unique_ptr<TtlCompactionFilter>(new TtlCompactionFilter(
ttl_, env_, nullptr,
std::move(user_comp_filter_factory_->CreateCompactionFilter(context))));

View File

@ -29,7 +29,7 @@ class SpecialTimeEnv : public EnvWrapper {
}
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_;
return Status::OK();
}

View File

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