Apply modernize-use-override (2nd iteration)

Summary:
Use C++11’s override and remove virtual where applicable.
Change are automatically generated.

Reviewed By: Orvid

Differential Revision: D14090024

fbshipit-source-id: 1e9432e87d2657e1ff0028e15370a85d1739ba2a
This commit is contained in:
Michael Liu 2019-02-14 13:52:47 -08:00 committed by Facebook Github Bot
parent c8c8104d7e
commit ca89ac2ba9
106 changed files with 1237 additions and 1443 deletions

3
cache/cache_test.cc vendored
View File

@ -73,8 +73,7 @@ class CacheTest : public testing::TestWithParam<std::string> {
current_ = this;
}
~CacheTest() {
}
~CacheTest() override {}
std::shared_ptr<Cache> NewCache(size_t capacity) {
auto type = GetParam();

45
cache/clock_cache.cc vendored
View File

@ -240,31 +240,28 @@ class ClockCacheShard : public CacheShard {
typedef tbb::concurrent_hash_map<CacheKey, CacheHandle*, CacheKey> HashTable;
ClockCacheShard();
~ClockCacheShard();
~ClockCacheShard() override;
// Interfaces
virtual void SetCapacity(size_t capacity) override;
virtual void SetStrictCapacityLimit(bool strict_capacity_limit) override;
virtual Status Insert(const Slice& key, uint32_t hash, void* value,
size_t charge,
void SetCapacity(size_t capacity) override;
void SetStrictCapacityLimit(bool strict_capacity_limit) override;
Status Insert(const Slice& key, uint32_t hash, void* value, size_t charge,
void (*deleter)(const Slice& key, void* value),
Cache::Handle** handle,
Cache::Priority priority) override;
virtual Cache::Handle* Lookup(const Slice& key, uint32_t hash) override;
Cache::Handle** handle, Cache::Priority priority) override;
Cache::Handle* Lookup(const Slice& key, uint32_t hash) override;
// If the entry in in cache, increase reference count and return true.
// Return false otherwise.
//
// Not necessary to hold mutex_ before being called.
virtual bool Ref(Cache::Handle* handle) override;
virtual bool Release(Cache::Handle* handle,
bool force_erase = false) override;
virtual void Erase(const Slice& key, uint32_t hash) override;
bool Ref(Cache::Handle* handle) override;
bool Release(Cache::Handle* handle, bool force_erase = false) override;
void Erase(const Slice& key, uint32_t hash) override;
bool EraseAndConfirm(const Slice& key, uint32_t hash,
CleanupContext* context);
virtual size_t GetUsage() const override;
virtual size_t GetPinnedUsage() const override;
virtual void EraseUnRefEntries() override;
virtual void ApplyToAllCacheEntries(void (*callback)(void*, size_t),
size_t GetUsage() const override;
size_t GetPinnedUsage() const override;
void EraseUnRefEntries() override;
void ApplyToAllCacheEntries(void (*callback)(void*, size_t),
bool thread_safe) override;
private:
@ -685,31 +682,31 @@ class ClockCache : public ShardedCache {
SetStrictCapacityLimit(strict_capacity_limit);
}
virtual ~ClockCache() { delete[] shards_; }
~ClockCache() override { delete[] shards_; }
virtual const char* Name() const override { return "ClockCache"; }
const char* Name() const override { return "ClockCache"; }
virtual CacheShard* GetShard(int shard) override {
CacheShard* GetShard(int shard) override {
return reinterpret_cast<CacheShard*>(&shards_[shard]);
}
virtual const CacheShard* GetShard(int shard) const override {
const CacheShard* GetShard(int shard) const override {
return reinterpret_cast<CacheShard*>(&shards_[shard]);
}
virtual void* Value(Handle* handle) override {
void* Value(Handle* handle) override {
return reinterpret_cast<const CacheHandle*>(handle)->value;
}
virtual size_t GetCharge(Handle* handle) const override {
size_t GetCharge(Handle* handle) const override {
return reinterpret_cast<const CacheHandle*>(handle)->charge;
}
virtual uint32_t GetHash(Handle* handle) const override {
uint32_t GetHash(Handle* handle) const override {
return reinterpret_cast<const CacheHandle*>(handle)->hash;
}
virtual void DisownData() override { shards_ = nullptr; }
void DisownData() override { shards_ = nullptr; }
private:
ClockCacheShard* shards_;

View File

@ -15,7 +15,7 @@ namespace rocksdb {
class LRUCacheTest : public testing::Test {
public:
LRUCacheTest() {}
~LRUCacheTest() { DeleteCache(); }
~LRUCacheTest() override { DeleteCache(); }
void DeleteCache() {
if (cache_ != nullptr) {

74
db/c.cc
View File

@ -208,13 +208,10 @@ struct rocksdb_compactionfilter_t : public CompactionFilter {
const char* (*name_)(void*);
unsigned char ignore_snapshots_;
virtual ~rocksdb_compactionfilter_t() {
(*destructor_)(state_);
}
~rocksdb_compactionfilter_t() override { (*destructor_)(state_); }
virtual bool Filter(int level, const Slice& key, const Slice& existing_value,
std::string* new_value,
bool* value_changed) const override {
bool Filter(int level, const Slice& key, const Slice& existing_value,
std::string* new_value, bool* value_changed) const override {
char* c_new_value = nullptr;
size_t new_value_length = 0;
unsigned char c_value_changed = 0;
@ -231,9 +228,9 @@ struct rocksdb_compactionfilter_t : public CompactionFilter {
return result;
}
virtual const char* Name() const override { return (*name_)(state_); }
const char* Name() const override { return (*name_)(state_); }
virtual bool IgnoreSnapshots() const override { return ignore_snapshots_; }
bool IgnoreSnapshots() const override { return ignore_snapshots_; }
};
struct rocksdb_compactionfilterfactory_t : public CompactionFilterFactory {
@ -243,9 +240,9 @@ struct rocksdb_compactionfilterfactory_t : public CompactionFilterFactory {
void*, rocksdb_compactionfiltercontext_t* context);
const char* (*name_)(void*);
virtual ~rocksdb_compactionfilterfactory_t() { (*destructor_)(state_); }
~rocksdb_compactionfilterfactory_t() override { (*destructor_)(state_); }
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& context) override {
rocksdb_compactionfiltercontext_t ccontext;
ccontext.rep = context;
@ -253,7 +250,7 @@ struct rocksdb_compactionfilterfactory_t : public CompactionFilterFactory {
return std::unique_ptr<CompactionFilter>(cf);
}
virtual const char* Name() const override { return (*name_)(state_); }
const char* Name() const override { return (*name_)(state_); }
};
struct rocksdb_comparator_t : public Comparator {
@ -265,20 +262,17 @@ struct rocksdb_comparator_t : public Comparator {
const char* b, size_t blen);
const char* (*name_)(void*);
virtual ~rocksdb_comparator_t() {
(*destructor_)(state_);
}
~rocksdb_comparator_t() override { (*destructor_)(state_); }
virtual int Compare(const Slice& a, const Slice& b) const override {
int Compare(const Slice& a, const Slice& b) const override {
return (*compare_)(state_, a.data(), a.size(), b.data(), b.size());
}
virtual const char* Name() const override { return (*name_)(state_); }
const char* Name() const override { return (*name_)(state_); }
// No-ops since the C binding does not support key shortening methods.
virtual void FindShortestSeparator(std::string*,
const Slice&) const override {}
virtual void FindShortSuccessor(std::string* /*key*/) const override {}
void FindShortestSeparator(std::string*, const Slice&) const override {}
void FindShortSuccessor(std::string* /*key*/) const override {}
};
struct rocksdb_filterpolicy_t : public FilterPolicy {
@ -298,14 +292,11 @@ struct rocksdb_filterpolicy_t : public FilterPolicy {
void*,
const char* filter, size_t filter_length);
virtual ~rocksdb_filterpolicy_t() {
(*destructor_)(state_);
}
~rocksdb_filterpolicy_t() override { (*destructor_)(state_); }
virtual const char* Name() const override { return (*name_)(state_); }
const char* Name() const override { return (*name_)(state_); }
virtual void CreateFilter(const Slice* keys, int n,
std::string* dst) const override {
void CreateFilter(const Slice* keys, int n, std::string* dst) const override {
std::vector<const char*> key_pointers(n);
std::vector<size_t> key_sizes(n);
for (int i = 0; i < n; i++) {
@ -323,8 +314,7 @@ struct rocksdb_filterpolicy_t : public FilterPolicy {
}
}
virtual bool KeyMayMatch(const Slice& key,
const Slice& filter) const override {
bool KeyMayMatch(const Slice& key, const Slice& filter) const override {
return (*key_match_)(state_, key.data(), key.size(),
filter.data(), filter.size());
}
@ -349,13 +339,11 @@ struct rocksdb_mergeoperator_t : public MergeOperator {
void*,
const char* value, size_t value_length);
virtual ~rocksdb_mergeoperator_t() {
(*destructor_)(state_);
}
~rocksdb_mergeoperator_t() override { (*destructor_)(state_); }
virtual const char* Name() const override { return (*name_)(state_); }
const char* Name() const override { return (*name_)(state_); }
virtual bool FullMergeV2(const MergeOperationInput& merge_in,
bool FullMergeV2(const MergeOperationInput& merge_in,
MergeOperationOutput* merge_out) const override {
size_t n = merge_in.operand_list.size();
std::vector<const char*> operand_pointers(n);
@ -390,7 +378,7 @@ struct rocksdb_mergeoperator_t : public MergeOperator {
return success;
}
virtual bool PartialMergeMulti(const Slice& key,
bool PartialMergeMulti(const Slice& key,
const std::deque<Slice>& operand_list,
std::string* new_value,
Logger* /*logger*/) const override {
@ -444,23 +432,21 @@ struct rocksdb_slicetransform_t : public SliceTransform {
void*,
const char* key, size_t length);
virtual ~rocksdb_slicetransform_t() {
(*destructor_)(state_);
}
~rocksdb_slicetransform_t() override { (*destructor_)(state_); }
virtual const char* Name() const override { return (*name_)(state_); }
const char* Name() const override { return (*name_)(state_); }
virtual Slice Transform(const Slice& src) const override {
Slice Transform(const Slice& src) const override {
size_t len;
char* dst = (*transform_)(state_, src.data(), src.size(), &len);
return Slice(dst, len);
}
virtual bool InDomain(const Slice& src) const override {
bool InDomain(const Slice& src) const override {
return (*in_domain_)(state_, src.data(), src.size());
}
virtual bool InRange(const Slice& src) const override {
bool InRange(const Slice& src) const override {
return (*in_range_)(state_, src.data(), src.size());
}
};
@ -1495,10 +1481,10 @@ class H : public WriteBatch::Handler {
void* state_;
void (*put_)(void*, const char* k, size_t klen, const char* v, size_t vlen);
void (*deleted_)(void*, const char* k, size_t klen);
virtual void Put(const Slice& key, const Slice& value) override {
void Put(const Slice& key, const Slice& value) override {
(*put_)(state_, key.data(), key.size(), value.data(), value.size());
}
virtual void Delete(const Slice& key) override {
void Delete(const Slice& key) override {
(*deleted_)(state_, key.data(), key.size());
}
};
@ -2966,7 +2952,7 @@ rocksdb_filterpolicy_t* rocksdb_filterpolicy_create_bloom_format(int bits_per_ke
// supplied C functions.
struct Wrapper : public rocksdb_filterpolicy_t {
const FilterPolicy* rep_;
~Wrapper() { delete rep_; }
~Wrapper() override { delete rep_; }
const char* Name() const override { return rep_->Name(); }
void CreateFilter(const Slice* keys, int n,
std::string* dst) const override {
@ -3421,7 +3407,7 @@ void rocksdb_slicetransform_destroy(rocksdb_slicetransform_t* st) {
struct Wrapper : public rocksdb_slicetransform_t {
const SliceTransform* rep_;
~Wrapper() { delete rep_; }
~Wrapper() override { delete rep_; }
const char* Name() const override { return rep_->Name(); }
Slice Transform(const Slice& src) const override {
return rep_->Transform(src);

View File

@ -69,7 +69,7 @@ class ColumnFamilyTestBase : public testing::Test {
DestroyDB(dbname_, Options(db_options_, column_family_options_));
}
virtual ~ColumnFamilyTestBase() {
~ColumnFamilyTestBase() override {
std::vector<ColumnFamilyDescriptor> column_families;
for (auto h : handles_) {
ColumnFamilyDescriptor cfdescriptor;

View File

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

View File

@ -112,39 +112,39 @@ class LoggingForwardVectorIterator : public InternalIterator {
assert(keys_.size() == values_.size());
}
virtual bool Valid() const override { return current_ < keys_.size(); }
bool Valid() const override { return current_ < keys_.size(); }
virtual void SeekToFirst() override {
void SeekToFirst() override {
log.emplace_back(Action::Type::SEEK_TO_FIRST);
current_ = 0;
}
virtual void SeekToLast() override { assert(false); }
void SeekToLast() override { assert(false); }
virtual void Seek(const Slice& target) override {
void Seek(const Slice& target) override {
log.emplace_back(Action::Type::SEEK, target.ToString());
current_ = std::lower_bound(keys_.begin(), keys_.end(), target.ToString()) -
keys_.begin();
}
virtual void SeekForPrev(const Slice& /*target*/) override { assert(false); }
void SeekForPrev(const Slice& /*target*/) override { assert(false); }
virtual void Next() override {
void Next() override {
assert(Valid());
log.emplace_back(Action::Type::NEXT);
current_++;
}
virtual void Prev() override { assert(false); }
void Prev() override { assert(false); }
virtual Slice key() const override {
Slice key() const override {
assert(Valid());
return Slice(keys_[current_]);
}
virtual Slice value() const override {
Slice value() const override {
assert(Valid());
return Slice(values_[current_]);
}
virtual Status status() const override { return Status::OK(); }
Status status() const override { return Status::OK(); }
std::vector<Action> log;
@ -158,22 +158,20 @@ class FakeCompaction : public CompactionIterator::CompactionProxy {
public:
FakeCompaction() = default;
virtual int level(size_t /*compaction_input_level*/) const override {
return 0;
}
virtual bool KeyNotExistsBeyondOutputLevel(
int level(size_t /*compaction_input_level*/) const override { return 0; }
bool KeyNotExistsBeyondOutputLevel(
const Slice& /*user_key*/,
std::vector<size_t>* /*level_ptrs*/) const override {
return is_bottommost_level || key_not_exists_beyond_output_level;
}
virtual bool bottommost_level() const override { return is_bottommost_level; }
virtual int number_levels() const override { return 1; }
virtual Slice GetLargestUserKey() const override {
bool bottommost_level() const override { return is_bottommost_level; }
int number_levels() const override { return 1; }
Slice GetLargestUserKey() const override {
return "\xff\xff\xff\xff\xff\xff\xff\xff\xff";
}
virtual bool allow_ingest_behind() const override { return false; }
bool allow_ingest_behind() const override { return false; }
virtual bool preserve_deletes() const override { return false; }
bool preserve_deletes() const override { return false; }
bool key_not_exists_beyond_output_level = false;
@ -377,9 +375,8 @@ TEST_P(CompactionIteratorTest, RangeDeletionWithSnapshots) {
TEST_P(CompactionIteratorTest, CompactionFilterSkipUntil) {
class Filter : public CompactionFilter {
virtual Decision FilterV2(int /*level*/, const Slice& key, ValueType t,
const Slice& existing_value,
std::string* /*new_value*/,
Decision FilterV2(int /*level*/, const Slice& key, ValueType t,
const Slice& existing_value, std::string* /*new_value*/,
std::string* skip_until) const override {
std::string k = key.ToString();
std::string v = existing_value.ToString();
@ -560,9 +557,8 @@ TEST_P(CompactionIteratorTest, ShuttingDownInMerge) {
TEST_P(CompactionIteratorTest, SingleMergeOperand) {
class Filter : public CompactionFilter {
virtual Decision FilterV2(int /*level*/, const Slice& key, ValueType t,
const Slice& existing_value,
std::string* /*new_value*/,
Decision FilterV2(int /*level*/, const Slice& key, ValueType t,
const Slice& existing_value, std::string* /*new_value*/,
std::string* /*skip_until*/) const override {
std::string k = key.ToString();
std::string v = existing_value.ToString();

View File

@ -113,7 +113,7 @@ class CompactionJobStatsTest : public testing::Test,
Reopen(options);
}
~CompactionJobStatsTest() {
~CompactionJobStatsTest() override {
rocksdb::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->LoadDependency({});
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks();
@ -426,7 +426,7 @@ class CompactionJobStatsChecker : public EventListener {
// Once a compaction completed, this function will verify the returned
// CompactionJobInfo with the oldest CompactionJobInfo added earlier
// in "expected_stats_" which has not yet being used for verification.
virtual void OnCompactionCompleted(DB* /*db*/, const CompactionJobInfo& ci) {
void OnCompactionCompleted(DB* /*db*/, const CompactionJobInfo& ci) override {
if (verify_next_comp_io_stats_) {
ASSERT_GT(ci.stats.file_write_nanos, 0);
ASSERT_GT(ci.stats.file_range_sync_nanos, 0);
@ -523,7 +523,7 @@ class CompactionJobDeletionStatsChecker : public CompactionJobStatsChecker {
public:
// Verifies whether two CompactionJobStats match.
void Verify(const CompactionJobStats& current_stats,
const CompactionJobStats& stats) {
const CompactionJobStats& stats) override {
ASSERT_EQ(
current_stats.num_input_deletion_records,
stats.num_input_deletion_records);

View File

@ -22,9 +22,7 @@ namespace rocksdb {
class CountingLogger : public Logger {
public:
using Logger::Logv;
virtual void Logv(const char* /*format*/, va_list /*ap*/) override {
log_count++;
}
void Logv(const char* /*format*/, va_list /*ap*/) override { log_count++; }
size_t log_count;
};
@ -68,8 +66,7 @@ class CompactionPickerTest : public testing::Test {
std::numeric_limits<uint64_t>::max());
}
~CompactionPickerTest() {
}
~CompactionPickerTest() override {}
void NewVersionStorage(int num_levels, CompactionStyle style) {
DeleteVersionStorage();

View File

@ -27,24 +27,24 @@ class KVIter : public Iterator {
public:
explicit KVIter(const stl_wrappers::KVMap* map)
: map_(map), iter_(map_->end()) {}
virtual bool Valid() const override { return iter_ != map_->end(); }
virtual void SeekToFirst() override { iter_ = map_->begin(); }
virtual void SeekToLast() override {
bool Valid() const override { return iter_ != map_->end(); }
void SeekToFirst() override { iter_ = map_->begin(); }
void SeekToLast() override {
if (map_->empty()) {
iter_ = map_->end();
} else {
iter_ = map_->find(map_->rbegin()->first);
}
}
virtual void Seek(const Slice& k) override {
void Seek(const Slice& k) override {
iter_ = map_->lower_bound(k.ToString());
}
virtual void SeekForPrev(const Slice& k) override {
void SeekForPrev(const Slice& k) override {
iter_ = map_->upper_bound(k.ToString());
Prev();
}
virtual void Next() override { ++iter_; }
virtual void Prev() override {
void Next() override { ++iter_; }
void Prev() override {
if (iter_ == map_->begin()) {
iter_ = map_->end();
return;
@ -52,9 +52,9 @@ class KVIter : public Iterator {
--iter_;
}
virtual Slice key() const override { return iter_->first; }
virtual Slice value() const override { return iter_->second; }
virtual Status status() const override { return Status::OK(); }
Slice key() const override { return iter_->first; }
Slice value() const override { return iter_->second; }
Status status() const override { return Status::OK(); }
private:
const stl_wrappers::KVMap* const map_;
@ -171,9 +171,9 @@ class DoubleComparator : public Comparator {
public:
DoubleComparator() {}
virtual const char* Name() const override { return "DoubleComparator"; }
const char* Name() const override { return "DoubleComparator"; }
virtual int Compare(const Slice& a, const Slice& b) const override {
int Compare(const Slice& a, const Slice& b) const override {
#ifndef CYGWIN
double da = std::stod(a.ToString());
double db = std::stod(b.ToString());
@ -189,19 +189,19 @@ class DoubleComparator : public Comparator {
return -1;
}
}
virtual void FindShortestSeparator(std::string* /*start*/,
void FindShortestSeparator(std::string* /*start*/,
const Slice& /*limit*/) const override {}
virtual void FindShortSuccessor(std::string* /*key*/) const override {}
void FindShortSuccessor(std::string* /*key*/) const override {}
};
class HashComparator : public Comparator {
public:
HashComparator() {}
virtual const char* Name() const override { return "HashComparator"; }
const char* Name() const override { return "HashComparator"; }
virtual int Compare(const Slice& a, const Slice& b) const override {
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) {
@ -212,19 +212,19 @@ class HashComparator : public Comparator {
return -1;
}
}
virtual void FindShortestSeparator(std::string* /*start*/,
void FindShortestSeparator(std::string* /*start*/,
const Slice& /*limit*/) const override {}
virtual void FindShortSuccessor(std::string* /*key*/) const override {}
void FindShortSuccessor(std::string* /*key*/) const override {}
};
class TwoStrComparator : public Comparator {
public:
TwoStrComparator() {}
virtual const char* Name() const override { return "TwoStrComparator"; }
const char* Name() const override { return "TwoStrComparator"; }
virtual int Compare(const Slice& a, const Slice& b) const override {
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]);
@ -244,10 +244,10 @@ class TwoStrComparator : public Comparator {
}
return a2.compare(b2);
}
virtual void FindShortestSeparator(std::string* /*start*/,
void FindShortestSeparator(std::string* /*start*/,
const Slice& /*limit*/) const override {}
virtual void FindShortSuccessor(std::string* /*key*/) const override {}
void FindShortSuccessor(std::string* /*key*/) const override {}
};
} // namespace
@ -272,7 +272,7 @@ class ComparatorDBTest
EXPECT_OK(DestroyDB(dbname_, last_options_));
}
~ComparatorDBTest() {
~ComparatorDBTest() override {
delete db_;
EXPECT_OK(DestroyDB(dbname_, last_options_));
comparator = BytewiseComparator();

View File

@ -62,7 +62,7 @@ class CorruptionTest : public testing::Test {
options_.create_if_missing = false;
}
~CorruptionTest() {
~CorruptionTest() override {
delete db_;
DestroyDB(dbname_, Options());
}

View File

@ -31,7 +31,7 @@ class CuckooTableDBTest : public testing::Test {
Reopen();
}
~CuckooTableDBTest() {
~CuckooTableDBTest() override {
delete db_;
EXPECT_OK(DestroyDB(dbname_, Options()));
}

View File

@ -852,17 +852,16 @@ class TestEnv : public EnvWrapper {
public:
using Logger::Logv;
TestLogger(TestEnv *env_ptr) : Logger() { env = env_ptr; }
~TestLogger() {
~TestLogger() override {
if (!closed_) {
CloseHelper();
}
}
virtual void Logv(const char* /*format*/, va_list /*ap*/) override{};
void Logv(const char* /*format*/, va_list /*ap*/) override{};
protected:
virtual Status CloseImpl() override {
return CloseHelper();
}
Status CloseImpl() override { return CloseHelper(); }
private:
Status CloseHelper() {
env->CloseCountInc();;
@ -875,8 +874,8 @@ class TestEnv : public EnvWrapper {
int GetCloseCount() { return close_count; }
virtual Status NewLogger(const std::string& /*fname*/,
std::shared_ptr<Logger>* result) {
Status NewLogger(const std::string& /*fname*/,
std::shared_ptr<Logger>* result) override {
result->reset(new TestLogger(this));
return Status::OK();
}

View File

@ -395,9 +395,9 @@ class MockCache : public LRUCache {
false /*strict_capacity_limit*/, 0.0 /*high_pri_pool_ratio*/) {
}
virtual Status Insert(const Slice& key, void* value, size_t charge,
void (*deleter)(const Slice& key, void* value),
Handle** handle, Priority priority) override {
Status Insert(const Slice& key, void* value, size_t charge,
void (*deleter)(const Slice& key, void* value), Handle** handle,
Priority priority) override {
if (priority == Priority::LOW) {
low_pri_insert_count++;
} else {

View File

@ -32,7 +32,7 @@ class DBBloomFilterTestWithParam
public:
DBBloomFilterTestWithParam() : DBTestBase("/db_bloom_filter_tests") {}
~DBBloomFilterTestWithParam() {}
~DBBloomFilterTestWithParam() override {}
void SetUp() override {
use_block_based_filter_ = std::get<0>(GetParam());
@ -642,7 +642,7 @@ class WrappedBloom : public FilterPolicy {
explicit WrappedBloom(int bits_per_key)
: filter_(NewBloomFilterPolicy(bits_per_key)), counter_(0) {}
~WrappedBloom() { delete filter_; }
~WrappedBloom() override { delete filter_; }
const char* Name() const override { return "WrappedRocksDbFilterPolicy"; }
@ -823,7 +823,7 @@ class BloomStatsTestWithParam
DestroyAndReopen(options_);
}
~BloomStatsTestWithParam() {
~BloomStatsTestWithParam() override {
get_perf_context()->Reset();
Destroy(options_);
}

View File

@ -63,31 +63,31 @@ INSTANTIATE_TEST_CASE_P(DBTestCompactionFilterWithCompactOption,
class KeepFilter : public CompactionFilter {
public:
virtual bool Filter(int /*level*/, const Slice& /*key*/,
const Slice& /*value*/, std::string* /*new_value*/,
bool Filter(int /*level*/, const Slice& /*key*/, const Slice& /*value*/,
std::string* /*new_value*/,
bool* /*value_changed*/) const override {
cfilter_count++;
return false;
}
virtual const char* Name() const override { return "KeepFilter"; }
const char* Name() const override { return "KeepFilter"; }
};
class DeleteFilter : public CompactionFilter {
public:
virtual bool Filter(int /*level*/, const Slice& /*key*/,
const Slice& /*value*/, std::string* /*new_value*/,
bool Filter(int /*level*/, const Slice& /*key*/, const Slice& /*value*/,
std::string* /*new_value*/,
bool* /*value_changed*/) const override {
cfilter_count++;
return true;
}
virtual const char* Name() const override { return "DeleteFilter"; }
const char* Name() const override { return "DeleteFilter"; }
};
class DeleteISFilter : public CompactionFilter {
public:
virtual bool Filter(int /*level*/, const Slice& key, const Slice& /*value*/,
bool Filter(int /*level*/, const Slice& key, const Slice& /*value*/,
std::string* /*new_value*/,
bool* /*value_changed*/) const override {
cfilter_count++;
@ -98,19 +98,17 @@ class DeleteISFilter : public CompactionFilter {
return false;
}
virtual bool IgnoreSnapshots() const override { return true; }
bool IgnoreSnapshots() const override { return true; }
virtual const char* Name() const override { return "DeleteFilter"; }
const char* Name() const override { return "DeleteFilter"; }
};
// Skip x if floor(x/10) is even, use range skips. Requires that keys are
// zero-padded to length 10.
class SkipEvenFilter : public CompactionFilter {
public:
virtual Decision FilterV2(int /*level*/, const Slice& key,
ValueType /*value_type*/,
const Slice& /*existing_value*/,
std::string* /*new_value*/,
Decision FilterV2(int /*level*/, const Slice& key, ValueType /*value_type*/,
const Slice& /*existing_value*/, std::string* /*new_value*/,
std::string* skip_until) const override {
cfilter_count++;
int i = std::stoi(key.ToString());
@ -124,22 +122,22 @@ class SkipEvenFilter : public CompactionFilter {
return Decision::kKeep;
}
virtual bool IgnoreSnapshots() const override { return true; }
bool IgnoreSnapshots() const override { return true; }
virtual const char* Name() const override { return "DeleteFilter"; }
const char* Name() const override { return "DeleteFilter"; }
};
class DelayFilter : public CompactionFilter {
public:
explicit DelayFilter(DBTestBase* d) : db_test(d) {}
virtual bool Filter(int /*level*/, const Slice& /*key*/,
const Slice& /*value*/, std::string* /*new_value*/,
bool Filter(int /*level*/, const Slice& /*key*/, const Slice& /*value*/,
std::string* /*new_value*/,
bool* /*value_changed*/) const override {
db_test->env_->addon_time_.fetch_add(1000);
return true;
}
virtual const char* Name() const override { return "DelayFilter"; }
const char* Name() const override { return "DelayFilter"; }
private:
DBTestBase* db_test;
@ -149,13 +147,13 @@ class ConditionalFilter : public CompactionFilter {
public:
explicit ConditionalFilter(const std::string* filtered_value)
: filtered_value_(filtered_value) {}
virtual bool Filter(int /*level*/, const Slice& /*key*/, const Slice& value,
bool Filter(int /*level*/, const Slice& /*key*/, const Slice& value,
std::string* /*new_value*/,
bool* /*value_changed*/) const override {
return value.ToString() == *filtered_value_;
}
virtual const char* Name() const override { return "ConditionalFilter"; }
const char* Name() const override { return "ConditionalFilter"; }
private:
const std::string* filtered_value_;
@ -165,16 +163,15 @@ class ChangeFilter : public CompactionFilter {
public:
explicit ChangeFilter() {}
virtual bool Filter(int /*level*/, const Slice& /*key*/,
const Slice& /*value*/, std::string* new_value,
bool* value_changed) const override {
bool Filter(int /*level*/, const Slice& /*key*/, const Slice& /*value*/,
std::string* new_value, bool* value_changed) const override {
assert(new_value != nullptr);
*new_value = NEW_VALUE;
*value_changed = true;
return false;
}
virtual const char* Name() const override { return "ChangeFilter"; }
const char* Name() const override { return "ChangeFilter"; }
};
class KeepFilterFactory : public CompactionFilterFactory {
@ -185,7 +182,7 @@ class KeepFilterFactory : public CompactionFilterFactory {
check_context_cf_id_(check_context_cf_id),
compaction_filter_created_(false) {}
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& context) override {
if (check_context_) {
EXPECT_EQ(expect_full_compaction_.load(), context.is_full_compaction);
@ -200,7 +197,7 @@ class KeepFilterFactory : public CompactionFilterFactory {
bool compaction_filter_created() const { return compaction_filter_created_; }
virtual const char* Name() const override { return "KeepFilterFactory"; }
const char* Name() const override { return "KeepFilterFactory"; }
bool check_context_;
bool check_context_cf_id_;
std::atomic_bool expect_full_compaction_;
@ -211,7 +208,7 @@ class KeepFilterFactory : public CompactionFilterFactory {
class DeleteFilterFactory : public CompactionFilterFactory {
public:
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& context) override {
if (context.is_manual_compaction) {
return std::unique_ptr<CompactionFilter>(new DeleteFilter());
@ -220,13 +217,13 @@ class DeleteFilterFactory : public CompactionFilterFactory {
}
}
virtual const char* Name() const override { return "DeleteFilterFactory"; }
const char* Name() const override { return "DeleteFilterFactory"; }
};
// Delete Filter Factory which ignores snapshots
class DeleteISFilterFactory : public CompactionFilterFactory {
public:
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& context) override {
if (context.is_manual_compaction) {
return std::unique_ptr<CompactionFilter>(new DeleteISFilter());
@ -235,12 +232,12 @@ class DeleteISFilterFactory : public CompactionFilterFactory {
}
}
virtual const char* Name() const override { return "DeleteFilterFactory"; }
const char* Name() const override { return "DeleteFilterFactory"; }
};
class SkipEvenFilterFactory : public CompactionFilterFactory {
public:
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& context) override {
if (context.is_manual_compaction) {
return std::unique_ptr<CompactionFilter>(new SkipEvenFilter());
@ -249,18 +246,18 @@ class SkipEvenFilterFactory : public CompactionFilterFactory {
}
}
virtual const char* Name() const override { return "SkipEvenFilterFactory"; }
const char* Name() const override { return "SkipEvenFilterFactory"; }
};
class DelayFilterFactory : public CompactionFilterFactory {
public:
explicit DelayFilterFactory(DBTestBase* d) : db_test(d) {}
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& /*context*/) override {
return std::unique_ptr<CompactionFilter>(new DelayFilter(db_test));
}
virtual const char* Name() const override { return "DelayFilterFactory"; }
const char* Name() const override { return "DelayFilterFactory"; }
private:
DBTestBase* db_test;
@ -271,15 +268,13 @@ class ConditionalFilterFactory : public CompactionFilterFactory {
explicit ConditionalFilterFactory(const Slice& filtered_value)
: filtered_value_(filtered_value.ToString()) {}
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& /*context*/) override {
return std::unique_ptr<CompactionFilter>(
new ConditionalFilter(&filtered_value_));
}
virtual const char* Name() const override {
return "ConditionalFilterFactory";
}
const char* Name() const override { return "ConditionalFilterFactory"; }
private:
std::string filtered_value_;
@ -289,12 +284,12 @@ class ChangeFilterFactory : public CompactionFilterFactory {
public:
explicit ChangeFilterFactory() {}
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& /*context*/) override {
return std::unique_ptr<CompactionFilter>(new ChangeFilter());
}
virtual const char* Name() const override { return "ChangeFilterFactory"; }
const char* Name() const override { return "ChangeFilterFactory"; }
};
#ifndef ROCKSDB_LITE
@ -845,7 +840,7 @@ class TestNotSupportedFilter : public CompactionFilter {
return true;
}
virtual const char* Name() const override { return "NotSupported"; }
const char* Name() const override { return "NotSupported"; }
bool IgnoreSnapshots() const override { return false; }
};

View File

@ -55,9 +55,9 @@ namespace {
class FlushedFileCollector : public EventListener {
public:
FlushedFileCollector() {}
~FlushedFileCollector() {}
~FlushedFileCollector() override {}
virtual void OnFlushCompleted(DB* /*db*/, const FlushJobInfo& info) override {
void OnFlushCompleted(DB* /*db*/, const FlushJobInfo& info) override {
std::lock_guard<std::mutex> lock(mutex_);
flushed_files_.push_back(info.file_path);
}
@ -87,9 +87,9 @@ public:
}
}
~CompactionStatsCollector() {}
~CompactionStatsCollector() override {}
virtual void OnCompactionCompleted(DB* /* db */,
void OnCompactionCompleted(DB* /* db */,
const CompactionJobInfo& info) override {
int k = static_cast<int>(info.compaction_reason);
int num_of_reasons = static_cast<int>(CompactionReason::kNumOfReasons);
@ -97,14 +97,13 @@ public:
compaction_completed_[k]++;
}
virtual void OnExternalFileIngested(DB* /* db */,
const ExternalFileIngestionInfo& /* info */) override {
void OnExternalFileIngested(
DB* /* db */, const ExternalFileIngestionInfo& /* info */) override {
int k = static_cast<int>(CompactionReason::kExternalSstIngestion);
compaction_completed_[k]++;
}
virtual void OnFlushCompleted(DB* /* db */,
const FlushJobInfo& /* info */) override {
void OnFlushCompleted(DB* /* db */, const FlushJobInfo& /* info */) override {
int k = static_cast<int>(CompactionReason::kFlush);
compaction_completed_[k]++;
}
@ -4187,14 +4186,14 @@ class NoopMergeOperator : public MergeOperator {
public:
NoopMergeOperator() {}
virtual bool FullMergeV2(const MergeOperationInput& /*merge_in*/,
bool FullMergeV2(const MergeOperationInput& /*merge_in*/,
MergeOperationOutput* merge_out) const override {
std::string val("bar");
merge_out->new_value = val;
return true;
}
virtual const char* Name() const override { return "Noop"; }
const char* Name() const override { return "Noop"; }
};
TEST_F(DBCompactionTest, PartialManualCompaction) {

View File

@ -512,7 +512,7 @@ Status DBImpl::RecoverLogFiles(const std::vector<uint64_t>& log_numbers,
Logger* info_log;
const char* fname;
Status* status; // nullptr if immutable_db_options_.paranoid_checks==false
virtual void Corruption(size_t bytes, const Status& s) override {
void Corruption(size_t bytes, const Status& s) override {
ROCKS_LOG_WARN(info_log, "%s%s: dropping %d bytes; %s",
(this->status == nullptr ? "(ignoring error) " : ""),
fname, static_cast<int>(bytes), s.ToString().c_str());

View File

@ -152,7 +152,7 @@ class DBIter final: public Iterator {
iter_->SetPinnedItersMgr(&pinned_iters_mgr_);
}
}
virtual ~DBIter() {
~DBIter() override {
// Release pinned data if any
if (pinned_iters_mgr_.PinningEnabled()) {
pinned_iters_mgr_.ReleasePinnedData();
@ -175,17 +175,16 @@ class DBIter final: public Iterator {
return &range_del_agg_;
}
virtual bool Valid() const override { return valid_; }
virtual Slice key() const override {
bool Valid() const override { return valid_; }
Slice key() const override {
assert(valid_);
if(start_seqnum_ > 0) {
return saved_key_.GetInternalKey();
} else {
return saved_key_.GetUserKey();
}
}
virtual Slice value() const override {
Slice value() const override {
assert(valid_);
if (current_entry_is_merged_) {
// If pinned_value_ is set then the result of merge operator is one of
@ -197,7 +196,7 @@ class DBIter final: public Iterator {
return iter_->value();
}
}
virtual Status status() const override {
Status status() const override {
if (status_.ok()) {
return iter_->status();
} else {
@ -210,8 +209,7 @@ class DBIter final: public Iterator {
return is_blob_;
}
virtual Status GetProperty(std::string prop_name,
std::string* prop) override {
Status GetProperty(std::string prop_name, std::string* prop) override {
if (prop == nullptr) {
return Status::InvalidArgument("prop is nullptr");
}
@ -232,12 +230,12 @@ class DBIter final: public Iterator {
return Status::InvalidArgument("Unidentified property.");
}
virtual void Next() override;
virtual void Prev() override;
virtual void Seek(const Slice& target) override;
virtual void SeekForPrev(const Slice& target) override;
virtual void SeekToFirst() override;
virtual void SeekToLast() override;
void Next() override;
void Prev() override;
void Seek(const Slice& target) override;
void SeekForPrev(const Slice& target) override;
void SeekToFirst() override;
void SeekToLast() override;
Env* env() { return env_; }
void set_sequence(uint64_t s) { sequence_ = s; }
void set_valid(bool v) { valid_ = v; }

View File

@ -116,12 +116,12 @@ class TestIterator : public InternalIterator {
// Number of operations done on this iterator since construction.
size_t steps() const { return steps_; }
virtual bool Valid() const override {
bool Valid() const override {
assert(initialized_);
return valid_;
}
virtual void SeekToFirst() override {
void SeekToFirst() override {
assert(initialized_);
++steps_;
DeleteCurrentIfNeeded();
@ -129,7 +129,7 @@ class TestIterator : public InternalIterator {
iter_ = 0;
}
virtual void SeekToLast() override {
void SeekToLast() override {
assert(initialized_);
++steps_;
DeleteCurrentIfNeeded();
@ -137,7 +137,7 @@ class TestIterator : public InternalIterator {
iter_ = data_.size() - 1;
}
virtual void Seek(const Slice& target) override {
void Seek(const Slice& target) override {
assert(initialized_);
SeekToFirst();
++steps_;
@ -154,13 +154,13 @@ class TestIterator : public InternalIterator {
}
}
virtual void SeekForPrev(const Slice& target) override {
void SeekForPrev(const Slice& target) override {
assert(initialized_);
DeleteCurrentIfNeeded();
SeekForPrevImpl(target, &cmp);
}
virtual void Next() override {
void Next() override {
assert(initialized_);
assert(valid_);
assert(iter_ < data_.size());
@ -174,7 +174,7 @@ class TestIterator : public InternalIterator {
valid_ = iter_ < data_.size();
}
virtual void Prev() override {
void Prev() override {
assert(initialized_);
assert(valid_);
assert(iter_ < data_.size());
@ -188,23 +188,23 @@ class TestIterator : public InternalIterator {
}
}
virtual Slice key() const override {
Slice key() const override {
assert(initialized_);
return data_[iter_].first;
}
virtual Slice value() const override {
Slice value() const override {
assert(initialized_);
return data_[iter_].second;
}
virtual Status status() const override {
Status status() const override {
assert(initialized_);
return Status::OK();
}
virtual bool IsKeyPinned() const override { return true; }
virtual bool IsValuePinned() const override { return true; }
bool IsKeyPinned() const override { return true; }
bool IsValuePinned() const override { return true; }
private:
bool initialized_;

View File

@ -50,13 +50,14 @@ class DBIteratorTest : public DBTestBase,
class FlushBlockEveryKeyPolicy : public FlushBlockPolicy {
public:
virtual bool Update(const Slice& /*key*/, const Slice& /*value*/) override {
bool Update(const Slice& /*key*/, const Slice& /*value*/) override {
if (!start_) {
start_ = true;
return false;
}
return true;
}
private:
bool start_ = false;
};

View File

@ -249,22 +249,20 @@ TEST_F(DBTestXactLogIterator, 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) override {
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) override {
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) override {
void LogData(const Slice& blob) override {
seen += "LogData(" + blob.ToString() + ")";
}
virtual Status DeleteCF(uint32_t cf, const Slice& key) override {
Status DeleteCF(uint32_t cf, const Slice& key) override {
seen += "Delete(" + ToString(cf) + ", " + key.ToString() + ")";
return Status::OK();
}

View File

@ -25,13 +25,13 @@ class MockMemTableRep : public MemTableRep {
explicit MockMemTableRep(Allocator* allocator, MemTableRep* rep)
: MemTableRep(allocator), rep_(rep), num_insert_with_hint_(0) {}
virtual KeyHandle Allocate(const size_t len, char** buf) override {
KeyHandle Allocate(const size_t len, char** buf) override {
return rep_->Allocate(len, buf);
}
virtual void Insert(KeyHandle handle) override { rep_->Insert(handle); }
void Insert(KeyHandle handle) override { rep_->Insert(handle); }
virtual void InsertWithHint(KeyHandle handle, void** hint) override {
void InsertWithHint(KeyHandle handle, void** hint) override {
num_insert_with_hint_++;
EXPECT_NE(nullptr, hint);
last_hint_in_ = *hint;
@ -39,21 +39,18 @@ class MockMemTableRep : public MemTableRep {
last_hint_out_ = *hint;
}
virtual bool Contains(const char* key) const override {
return rep_->Contains(key);
}
bool Contains(const char* key) const override { return rep_->Contains(key); }
virtual void Get(const LookupKey& k, void* callback_args,
bool (*callback_func)(void* arg,
const char* entry)) override {
void Get(const LookupKey& k, void* callback_args,
bool (*callback_func)(void* arg, const char* entry)) override {
rep_->Get(k, callback_args, callback_func);
}
virtual size_t ApproximateMemoryUsage() override {
size_t ApproximateMemoryUsage() override {
return rep_->ApproximateMemoryUsage();
}
virtual Iterator* GetIterator(Arena* arena) override {
Iterator* GetIterator(Arena* arena) override {
return rep_->GetIterator(arena);
}
@ -70,7 +67,7 @@ class MockMemTableRep : public MemTableRep {
class MockMemTableRepFactory : public MemTableRepFactory {
public:
virtual MemTableRep* CreateMemTableRep(const MemTableRep::KeyComparator& cmp,
MemTableRep* CreateMemTableRep(const MemTableRep::KeyComparator& cmp,
Allocator* allocator,
const SliceTransform* transform,
Logger* logger) override {
@ -81,7 +78,7 @@ class MockMemTableRepFactory : public MemTableRepFactory {
return mock_rep_;
}
virtual MemTableRep* CreateMemTableRep(const MemTableRep::KeyComparator& cmp,
MemTableRep* CreateMemTableRep(const MemTableRep::KeyComparator& cmp,
Allocator* allocator,
const SliceTransform* transform,
Logger* logger,
@ -90,7 +87,7 @@ class MockMemTableRepFactory : public MemTableRepFactory {
return CreateMemTableRep(cmp, allocator, transform, logger);
}
virtual const char* Name() const override { return "MockMemTableRepFactory"; }
const char* Name() const override { return "MockMemTableRepFactory"; }
MockMemTableRep* rep() { return mock_rep_; }
@ -106,9 +103,9 @@ class MockMemTableRepFactory : public MemTableRepFactory {
class TestPrefixExtractor : public SliceTransform {
public:
virtual const char* Name() const override { return "TestPrefixExtractor"; }
const char* Name() const override { return "TestPrefixExtractor"; }
virtual Slice Transform(const Slice& key) const override {
Slice Transform(const Slice& key) const override {
const char* p = separator(key);
if (p == nullptr) {
return Slice();
@ -116,11 +113,11 @@ class TestPrefixExtractor : public SliceTransform {
return Slice(key.data(), p - key.data() + 1);
}
virtual bool InDomain(const Slice& key) const override {
bool InDomain(const Slice& key) const override {
return separator(key) != nullptr;
}
virtual bool InRange(const Slice& /*key*/) const override { return false; }
bool InRange(const Slice& /*key*/) const override { return false; }
private:
const char* separator(const Slice& key) const {

View File

@ -340,7 +340,7 @@ class MergeOperatorHook : public MergeOperator {
explicit MergeOperatorHook(std::shared_ptr<MergeOperator> _merge_op)
: merge_op_(_merge_op) {}
virtual bool FullMergeV2(const MergeOperationInput& merge_in,
bool FullMergeV2(const MergeOperationInput& merge_in,
MergeOperationOutput* merge_out) const override {
before_merge_();
bool res = merge_op_->FullMergeV2(merge_in, merge_out);
@ -348,7 +348,7 @@ class MergeOperatorHook : public MergeOperator {
return res;
}
virtual const char* Name() const override { return merge_op_->Name(); }
const char* Name() const override { return merge_op_->Name(); }
std::shared_ptr<MergeOperator> merge_op_;
std::function<void()> before_merge_ = []() {};

View File

@ -1094,7 +1094,7 @@ class CountingUserTblPropCollector : public TablePropertiesCollector {
return Status::OK();
}
virtual UserCollectedProperties GetReadableProperties() const override {
UserCollectedProperties GetReadableProperties() const override {
return UserCollectedProperties{};
}
@ -1110,7 +1110,7 @@ class CountingUserTblPropCollectorFactory
uint32_t expected_column_family_id)
: expected_column_family_id_(expected_column_family_id),
num_created_(0) {}
virtual TablePropertiesCollector* CreateTablePropertiesCollector(
TablePropertiesCollector* CreateTablePropertiesCollector(
TablePropertiesCollectorFactory::Context context) override {
EXPECT_EQ(expected_column_family_id_, context.column_family_id);
num_created_++;
@ -1158,7 +1158,7 @@ class CountingDeleteTabPropCollector : public TablePropertiesCollector {
class CountingDeleteTabPropCollectorFactory
: public TablePropertiesCollectorFactory {
public:
virtual TablePropertiesCollector* CreateTablePropertiesCollector(
TablePropertiesCollector* CreateTablePropertiesCollector(
TablePropertiesCollectorFactory::Context /*context*/) override {
return new CountingDeleteTabPropCollector();
}

View File

@ -1111,14 +1111,14 @@ class MockMergeOperator : public MergeOperator {
// Mock non-associative operator. Non-associativity is expressed by lack of
// implementation for any `PartialMerge*` functions.
public:
virtual bool FullMergeV2(const MergeOperationInput& merge_in,
bool FullMergeV2(const MergeOperationInput& merge_in,
MergeOperationOutput* merge_out) const override {
assert(merge_out != nullptr);
merge_out->new_value = merge_in.operand_list.back().ToString();
return true;
}
virtual const char* Name() const override { return "MockMergeOperator"; }
const char* Name() const override { return "MockMergeOperator"; }
};
TEST_F(DBRangeDelTest, KeyAtOverlappingEndpointReappears) {

View File

@ -25,9 +25,9 @@ class DBSSTTest : public DBTestBase {
class FlushedFileCollector : public EventListener {
public:
FlushedFileCollector() {}
~FlushedFileCollector() {}
~FlushedFileCollector() override {}
virtual void OnFlushCompleted(DB* /*db*/, const FlushJobInfo& info) override {
void OnFlushCompleted(DB* /*db*/, const FlushJobInfo& info) override {
std::lock_guard<std::mutex> lock(mutex_);
flushed_files_.push_back(info.file_path);
}

View File

@ -940,13 +940,13 @@ TEST_F(DBTest, FlushSchedule) {
namespace {
class KeepFilter : public CompactionFilter {
public:
virtual bool Filter(int /*level*/, const Slice& /*key*/,
const Slice& /*value*/, std::string* /*new_value*/,
bool Filter(int /*level*/, const Slice& /*key*/, const Slice& /*value*/,
std::string* /*new_value*/,
bool* /*value_changed*/) const override {
return false;
}
virtual const char* Name() const override { return "KeepFilter"; }
const char* Name() const override { return "KeepFilter"; }
};
class KeepFilterFactory : public CompactionFilterFactory {
@ -954,7 +954,7 @@ class KeepFilterFactory : public CompactionFilterFactory {
explicit KeepFilterFactory(bool check_context = false)
: check_context_(check_context) {}
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& context) override {
if (check_context_) {
EXPECT_EQ(expect_full_compaction_.load(), context.is_full_compaction);
@ -963,7 +963,7 @@ class KeepFilterFactory : public CompactionFilterFactory {
return std::unique_ptr<CompactionFilter>(new KeepFilter());
}
virtual const char* Name() const override { return "KeepFilterFactory"; }
const char* Name() const override { return "KeepFilterFactory"; }
bool check_context_;
std::atomic_bool expect_full_compaction_;
std::atomic_bool expect_manual_compaction_;
@ -972,14 +972,14 @@ class KeepFilterFactory : public CompactionFilterFactory {
class DelayFilter : public CompactionFilter {
public:
explicit DelayFilter(DBTestBase* d) : db_test(d) {}
virtual bool Filter(int /*level*/, const Slice& /*key*/,
const Slice& /*value*/, std::string* /*new_value*/,
bool Filter(int /*level*/, const Slice& /*key*/, const Slice& /*value*/,
std::string* /*new_value*/,
bool* /*value_changed*/) const override {
db_test->env_->addon_time_.fetch_add(1000);
return true;
}
virtual const char* Name() const override { return "DelayFilter"; }
const char* Name() const override { return "DelayFilter"; }
private:
DBTestBase* db_test;
@ -988,12 +988,12 @@ class DelayFilter : public CompactionFilter {
class DelayFilterFactory : public CompactionFilterFactory {
public:
explicit DelayFilterFactory(DBTestBase* d) : db_test(d) {}
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& /*context*/) override {
return std::unique_ptr<CompactionFilter>(new DelayFilter(db_test));
}
virtual const char* Name() const override { return "DelayFilterFactory"; }
const char* Name() const override { return "DelayFilterFactory"; }
private:
DBTestBase* db_test;
@ -1775,17 +1775,14 @@ TEST_F(DBTest, OverlapInLevel0) {
TEST_F(DBTest, ComparatorCheck) {
class NewComparator : public Comparator {
public:
virtual const char* Name() const override {
return "rocksdb.NewComparator";
}
virtual int Compare(const Slice& a, const Slice& b) const override {
const char* Name() const override { return "rocksdb.NewComparator"; }
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 override {
void FindShortestSeparator(std::string* s, const Slice& l) const override {
BytewiseComparator()->FindShortestSeparator(s, l);
}
virtual void FindShortSuccessor(std::string* key) const override {
void FindShortSuccessor(std::string* key) const override {
BytewiseComparator()->FindShortSuccessor(key);
}
};
@ -1808,18 +1805,15 @@ TEST_F(DBTest, ComparatorCheck) {
TEST_F(DBTest, CustomComparator) {
class NumberComparator : public Comparator {
public:
virtual const char* Name() const override {
return "test.NumberComparator";
}
virtual int Compare(const Slice& a, const Slice& b) const override {
const char* Name() const override { return "test.NumberComparator"; }
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 override {
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 override {
void FindShortSuccessor(std::string* key) const override {
ToNumber(*key); // Check format
}
@ -2253,7 +2247,7 @@ static void MTThreadBody(void* arg) {
class MultiThreadedDBTest : public DBTest,
public ::testing::WithParamInterface<int> {
public:
virtual void SetUp() override { option_config_ = GetParam(); }
void SetUp() override { option_config_ = GetParam(); }
static std::vector<int> GenerateOptionConfigs() {
std::vector<int> optionConfigs;
@ -2398,7 +2392,7 @@ class ModelDB : public DB {
public:
KVMap map_;
virtual SequenceNumber GetSequenceNumber() const override {
SequenceNumber GetSequenceNumber() const override {
// no need to call this
assert(false);
return 0;
@ -2407,43 +2401,43 @@ 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) override {
Status Put(const WriteOptions& o, ColumnFamilyHandle* cf, const Slice& k,
const Slice& v) override {
WriteBatch batch;
batch.Put(cf, k, v);
return Write(o, &batch);
}
using DB::Close;
virtual Status Close() override { return Status::OK(); }
Status Close() override { return Status::OK(); }
using DB::Delete;
virtual Status Delete(const WriteOptions& o, ColumnFamilyHandle* cf,
Status Delete(const WriteOptions& o, ColumnFamilyHandle* cf,
const Slice& key) override {
WriteBatch batch;
batch.Delete(cf, key);
return Write(o, &batch);
}
using DB::SingleDelete;
virtual Status SingleDelete(const WriteOptions& o, ColumnFamilyHandle* cf,
Status SingleDelete(const WriteOptions& o, ColumnFamilyHandle* cf,
const Slice& key) override {
WriteBatch batch;
batch.SingleDelete(cf, key);
return Write(o, &batch);
}
using DB::Merge;
virtual Status Merge(const WriteOptions& o, ColumnFamilyHandle* cf,
const Slice& k, const Slice& v) override {
Status Merge(const WriteOptions& o, ColumnFamilyHandle* cf, const Slice& k,
const Slice& v) override {
WriteBatch batch;
batch.Merge(cf, k, v);
return Write(o, &batch);
}
using DB::Get;
virtual Status Get(const ReadOptions& /*options*/, ColumnFamilyHandle* /*cf*/,
Status Get(const ReadOptions& /*options*/, ColumnFamilyHandle* /*cf*/,
const Slice& key, PinnableSlice* /*value*/) override {
return Status::NotSupported(key);
}
using DB::MultiGet;
virtual std::vector<Status> MultiGet(
std::vector<Status> MultiGet(
const ReadOptions& /*options*/,
const std::vector<ColumnFamilyHandle*>& /*column_family*/,
const std::vector<Slice>& keys,
@ -2455,7 +2449,7 @@ class ModelDB : public DB {
#ifndef ROCKSDB_LITE
using DB::IngestExternalFile;
virtual Status IngestExternalFile(
Status IngestExternalFile(
ColumnFamilyHandle* /*column_family*/,
const std::vector<std::string>& /*external_files*/,
const IngestExternalFileOptions& /*options*/) override {
@ -2463,23 +2457,23 @@ class ModelDB : public DB {
}
using DB::IngestExternalFiles;
virtual Status IngestExternalFiles(
Status IngestExternalFiles(
const std::vector<IngestExternalFileArg>& /*args*/) override {
return Status::NotSupported("Not implemented");
}
virtual Status VerifyChecksum() override {
Status VerifyChecksum() override {
return Status::NotSupported("Not implemented.");
}
using DB::GetPropertiesOfAllTables;
virtual Status GetPropertiesOfAllTables(
Status GetPropertiesOfAllTables(
ColumnFamilyHandle* /*column_family*/,
TablePropertiesCollection* /*props*/) override {
return Status();
}
virtual Status GetPropertiesOfTablesInRange(
Status GetPropertiesOfTablesInRange(
ColumnFamilyHandle* /*column_family*/, const Range* /*range*/,
std::size_t /*n*/, TablePropertiesCollection* /*props*/) override {
return Status();
@ -2487,9 +2481,9 @@ class ModelDB : public DB {
#endif // ROCKSDB_LITE
using DB::KeyMayExist;
virtual bool KeyMayExist(const ReadOptions& /*options*/,
ColumnFamilyHandle* /*column_family*/,
const Slice& /*key*/, std::string* /*value*/,
bool KeyMayExist(const ReadOptions& /*options*/,
ColumnFamilyHandle* /*column_family*/, const Slice& /*key*/,
std::string* /*value*/,
bool* value_found = nullptr) override {
if (value_found != nullptr) {
*value_found = false;
@ -2497,8 +2491,7 @@ class ModelDB : public DB {
return true; // Not Supported directly
}
using DB::NewIterator;
virtual Iterator* NewIterator(
const ReadOptions& options,
Iterator* NewIterator(const ReadOptions& options,
ColumnFamilyHandle* /*column_family*/) override {
if (options.snapshot == nullptr) {
KVMap* saved = new KVMap;
@ -2510,38 +2503,33 @@ class ModelDB : public DB {
return new ModelIter(snapshot_state, false);
}
}
virtual Status NewIterators(
const ReadOptions& /*options*/,
Status NewIterators(const ReadOptions& /*options*/,
const std::vector<ColumnFamilyHandle*>& /*column_family*/,
std::vector<Iterator*>* /*iterators*/) override {
return Status::NotSupported("Not supported yet");
}
virtual const Snapshot* GetSnapshot() override {
const Snapshot* GetSnapshot() override {
ModelSnapshot* snapshot = new ModelSnapshot;
snapshot->map_ = map_;
return snapshot;
}
virtual void ReleaseSnapshot(const Snapshot* snapshot) override {
void ReleaseSnapshot(const Snapshot* snapshot) override {
delete reinterpret_cast<const ModelSnapshot*>(snapshot);
}
virtual Status Write(const WriteOptions& /*options*/,
WriteBatch* batch) override {
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) override {
void Put(const Slice& key, const Slice& value) override {
(*map_)[key.ToString()] = value.ToString();
}
virtual void Merge(const Slice& /*key*/,
const Slice& /*value*/) override {
void Merge(const Slice& /*key*/, const Slice& /*value*/) override {
// ignore merge for now
// (*map_)[key.ToString()] = value.ToString();
}
virtual void Delete(const Slice& key) override {
map_->erase(key.ToString());
}
void Delete(const Slice& key) override { map_->erase(key.ToString()); }
};
Handler handler;
handler.map_ = &map_;
@ -2549,32 +2537,29 @@ class ModelDB : public DB {
}
using DB::GetProperty;
virtual bool GetProperty(ColumnFamilyHandle* /*column_family*/,
const Slice& /*property*/,
std::string* /*value*/) override {
bool GetProperty(ColumnFamilyHandle* /*column_family*/,
const Slice& /*property*/, std::string* /*value*/) override {
return false;
}
using DB::GetIntProperty;
virtual bool GetIntProperty(ColumnFamilyHandle* /*column_family*/,
const Slice& /*property*/,
uint64_t* /*value*/) override {
bool GetIntProperty(ColumnFamilyHandle* /*column_family*/,
const Slice& /*property*/, uint64_t* /*value*/) override {
return false;
}
using DB::GetMapProperty;
virtual bool GetMapProperty(
ColumnFamilyHandle* /*column_family*/, const Slice& /*property*/,
bool GetMapProperty(ColumnFamilyHandle* /*column_family*/,
const Slice& /*property*/,
std::map<std::string, std::string>* /*value*/) override {
return false;
}
using DB::GetAggregatedIntProperty;
virtual bool GetAggregatedIntProperty(const Slice& /*property*/,
bool GetAggregatedIntProperty(const Slice& /*property*/,
uint64_t* /*value*/) override {
return false;
}
using DB::GetApproximateSizes;
virtual void GetApproximateSizes(ColumnFamilyHandle* /*column_family*/,
const Range* /*range*/, int n,
uint64_t* sizes,
void GetApproximateSizes(ColumnFamilyHandle* /*column_family*/,
const Range* /*range*/, int n, uint64_t* sizes,
uint8_t /*include_flags*/
= INCLUDE_FILES) override {
for (int i = 0; i < n; i++) {
@ -2582,28 +2567,28 @@ class ModelDB : public DB {
}
}
using DB::GetApproximateMemTableStats;
virtual void GetApproximateMemTableStats(
ColumnFamilyHandle* /*column_family*/, const Range& /*range*/,
uint64_t* const count, uint64_t* const size) override {
void GetApproximateMemTableStats(ColumnFamilyHandle* /*column_family*/,
const Range& /*range*/,
uint64_t* const count,
uint64_t* const size) override {
*count = 0;
*size = 0;
}
using DB::CompactRange;
virtual Status CompactRange(const CompactRangeOptions& /*options*/,
Status CompactRange(const CompactRangeOptions& /*options*/,
ColumnFamilyHandle* /*column_family*/,
const Slice* /*start*/,
const Slice* /*end*/) override {
const Slice* /*start*/, const Slice* /*end*/) override {
return Status::NotSupported("Not supported operation.");
}
virtual Status SetDBOptions(
Status SetDBOptions(
const std::unordered_map<std::string, std::string>& /*new_options*/)
override {
return Status::NotSupported("Not supported operation.");
}
using DB::CompactFiles;
virtual Status CompactFiles(
Status CompactFiles(
const CompactionOptions& /*compact_options*/,
ColumnFamilyHandle* /*column_family*/,
const std::vector<std::string>& /*input_file_names*/,
@ -2628,69 +2613,60 @@ class ModelDB : public DB {
}
using DB::NumberLevels;
virtual int NumberLevels(ColumnFamilyHandle* /*column_family*/) override {
return 1;
}
int NumberLevels(ColumnFamilyHandle* /*column_family*/) override { return 1; }
using DB::MaxMemCompactionLevel;
virtual int MaxMemCompactionLevel(
ColumnFamilyHandle* /*column_family*/) override {
int MaxMemCompactionLevel(ColumnFamilyHandle* /*column_family*/) override {
return 1;
}
using DB::Level0StopWriteTrigger;
virtual int Level0StopWriteTrigger(
ColumnFamilyHandle* /*column_family*/) override {
int Level0StopWriteTrigger(ColumnFamilyHandle* /*column_family*/) override {
return -1;
}
virtual const std::string& GetName() const override { return name_; }
const std::string& GetName() const override { return name_; }
virtual Env* GetEnv() const override { return nullptr; }
Env* GetEnv() const override { return nullptr; }
using DB::GetOptions;
virtual Options GetOptions(
ColumnFamilyHandle* /*column_family*/) const override {
Options GetOptions(ColumnFamilyHandle* /*column_family*/) const override {
return options_;
}
using DB::GetDBOptions;
virtual DBOptions GetDBOptions() const override { return options_; }
DBOptions GetDBOptions() const override { return options_; }
using DB::Flush;
virtual Status Flush(const rocksdb::FlushOptions& /*options*/,
Status Flush(const rocksdb::FlushOptions& /*options*/,
ColumnFamilyHandle* /*column_family*/) override {
Status ret;
return ret;
}
virtual Status Flush(
Status Flush(
const rocksdb::FlushOptions& /*options*/,
const std::vector<ColumnFamilyHandle*>& /*column_families*/) override {
return Status::OK();
}
virtual Status SyncWAL() override { return Status::OK(); }
Status SyncWAL() override { return Status::OK(); }
#ifndef ROCKSDB_LITE
virtual Status DisableFileDeletions() override { return Status::OK(); }
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*/,
Status EnableFileDeletions(bool /*force*/) override { return Status::OK(); }
Status GetLiveFiles(std::vector<std::string>&, uint64_t* /*size*/,
bool /*flush_memtable*/ = true) override {
return Status::OK();
}
virtual Status GetSortedWalFiles(VectorLogPtr& /*files*/) override {
Status GetSortedWalFiles(VectorLogPtr& /*files*/) override {
return Status::OK();
}
virtual Status DeleteFile(std::string /*name*/) override {
return Status::OK();
}
Status DeleteFile(std::string /*name*/) override { return Status::OK(); }
virtual Status GetUpdatesSince(
Status GetUpdatesSince(
rocksdb::SequenceNumber,
std::unique_ptr<rocksdb::TransactionLogIterator>*,
const TransactionLogIterator::ReadOptions& /*read_options*/ =
@ -2698,52 +2674,48 @@ class ModelDB : public DB {
return Status::NotSupported("Not supported in Model DB");
}
virtual void GetColumnFamilyMetaData(
ColumnFamilyHandle* /*column_family*/,
void GetColumnFamilyMetaData(ColumnFamilyHandle* /*column_family*/,
ColumnFamilyMetaData* /*metadata*/) override {}
#endif // ROCKSDB_LITE
virtual Status GetDbIdentity(std::string& /*identity*/) const override {
Status GetDbIdentity(std::string& /*identity*/) const override {
return Status::OK();
}
virtual SequenceNumber GetLatestSequenceNumber() const override { return 0; }
SequenceNumber GetLatestSequenceNumber() const override { return 0; }
virtual bool SetPreserveDeletesSequenceNumber(
SequenceNumber /*seqnum*/) override {
bool SetPreserveDeletesSequenceNumber(SequenceNumber /*seqnum*/) override {
return true;
}
virtual ColumnFamilyHandle* DefaultColumnFamily() const override {
return nullptr;
}
ColumnFamilyHandle* DefaultColumnFamily() const override { return nullptr; }
private:
class ModelIter : public Iterator {
public:
ModelIter(const KVMap* map, bool owned)
: map_(map), owned_(owned), iter_(map_->end()) {}
~ModelIter() {
~ModelIter() override {
if (owned_) delete map_;
}
virtual bool Valid() const override { return iter_ != map_->end(); }
virtual void SeekToFirst() override { iter_ = map_->begin(); }
virtual void SeekToLast() override {
bool Valid() const override { return iter_ != map_->end(); }
void SeekToFirst() override { iter_ = map_->begin(); }
void SeekToLast() override {
if (map_->empty()) {
iter_ = map_->end();
} else {
iter_ = map_->find(map_->rbegin()->first);
}
}
virtual void Seek(const Slice& k) override {
void Seek(const Slice& k) override {
iter_ = map_->lower_bound(k.ToString());
}
virtual void SeekForPrev(const Slice& k) override {
void SeekForPrev(const Slice& k) override {
iter_ = map_->upper_bound(k.ToString());
Prev();
}
virtual void Next() override { ++iter_; }
virtual void Prev() override {
void Next() override { ++iter_; }
void Prev() override {
if (iter_ == map_->begin()) {
iter_ = map_->end();
return;
@ -2751,9 +2723,9 @@ class ModelDB : public DB {
--iter_;
}
virtual Slice key() const override { return iter_->first; }
virtual Slice value() const override { return iter_->second; }
virtual Status status() const override { return Status::OK(); }
Slice key() const override { return iter_->first; }
Slice value() const override { return iter_->second; }
Status status() const override { return Status::OK(); }
private:
const KVMap* const map_;
@ -2821,7 +2793,7 @@ static bool CompareIterators(int step, DB* model, DB* db,
class DBTestRandomized : public DBTest,
public ::testing::WithParamInterface<int> {
public:
virtual void SetUp() override { option_config_ = GetParam(); }
void SetUp() override { option_config_ = GetParam(); }
static std::vector<int> GenerateOptionConfigs() {
std::vector<int> option_configs;
@ -5043,14 +5015,14 @@ class DelayedMergeOperator : public MergeOperator {
public:
explicit DelayedMergeOperator(DBTest* d) : db_test_(d) {}
virtual bool FullMergeV2(const MergeOperationInput& /*merge_in*/,
bool FullMergeV2(const MergeOperationInput& /*merge_in*/,
MergeOperationOutput* merge_out) const override {
db_test_->env_->addon_time_.fetch_add(1000);
merge_out->new_value = "";
return true;
}
virtual const char* Name() const override { return "DelayedMergeOperator"; }
const char* Name() const override { return "DelayedMergeOperator"; }
};
TEST_F(DBTest, MergeTestTime) {
@ -5186,7 +5158,7 @@ TEST_F(DBTest, EmptyCompactedDB) {
TEST_F(DBTest, SuggestCompactRangeTest) {
class CompactionFilterFactoryGetContext : public CompactionFilterFactory {
public:
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& context) override {
saved_context = context;
std::unique_ptr<CompactionFilter> empty_filter;

View File

@ -30,7 +30,7 @@ class PrefixFullBloomWithReverseComparator
public:
PrefixFullBloomWithReverseComparator()
: DBTestBase("/prefix_bloom_reverse") {}
virtual void SetUp() override { if_cache_filter_ = GetParam(); }
void SetUp() override { if_cache_filter_ = GetParam(); }
bool if_cache_filter_;
};
@ -515,8 +515,8 @@ TEST_F(DBTest2, WalFilterTest) {
apply_option_at_record_index_(apply_option_for_record_index),
current_record_index_(0) {}
virtual WalProcessingOption LogRecord(
const WriteBatch& /*batch*/, WriteBatch* /*new_batch*/,
WalProcessingOption LogRecord(const WriteBatch& /*batch*/,
WriteBatch* /*new_batch*/,
bool* /*batch_changed*/) const override {
WalFilter::WalProcessingOption option_to_return;
@ -535,7 +535,7 @@ TEST_F(DBTest2, WalFilterTest) {
return option_to_return;
}
virtual const char* Name() const override { return "TestWalFilter"; }
const char* Name() const override { return "TestWalFilter"; }
};
// Create 3 batches with two keys each
@ -687,7 +687,7 @@ TEST_F(DBTest2, WalFilterTestWithChangeBatch) {
: new_write_batch_(new_write_batch),
num_keys_to_add_in_new_batch_(num_keys_to_add_in_new_batch),
num_keys_added_(0) {}
virtual void Put(const Slice& key, const Slice& value) override {
void Put(const Slice& key, const Slice& value) override {
if (num_keys_added_ < num_keys_to_add_in_new_batch_) {
new_write_batch_->Put(key, value);
++num_keys_added_;
@ -711,7 +711,7 @@ TEST_F(DBTest2, WalFilterTestWithChangeBatch) {
num_keys_to_add_in_new_batch_(num_keys_to_add_in_new_batch),
current_record_index_(0) {}
virtual WalProcessingOption LogRecord(const WriteBatch& batch,
WalProcessingOption LogRecord(const WriteBatch& batch,
WriteBatch* new_batch,
bool* batch_changed) const override {
if (current_record_index_ >= change_records_from_index_) {
@ -729,9 +729,7 @@ TEST_F(DBTest2, WalFilterTestWithChangeBatch) {
return WalProcessingOption::kContinueProcessing;
}
virtual const char* Name() const override {
return "TestWalFilterWithChangeBatch";
}
const char* Name() const override { return "TestWalFilterWithChangeBatch"; }
};
std::vector<std::vector<std::string>> batch_keys(3);
@ -809,8 +807,7 @@ TEST_F(DBTest2, WalFilterTestWithChangeBatch) {
TEST_F(DBTest2, WalFilterTestWithChangeBatchExtraKeys) {
class TestWalFilterWithChangeBatchAddExtraKeys : public WalFilter {
public:
virtual WalProcessingOption LogRecord(const WriteBatch& batch,
WriteBatch* new_batch,
WalProcessingOption LogRecord(const WriteBatch& batch, WriteBatch* new_batch,
bool* batch_changed) const override {
*new_batch = batch;
new_batch->Put("key_extra", "value_extra");
@ -818,7 +815,7 @@ TEST_F(DBTest2, WalFilterTestWithChangeBatchExtraKeys) {
return WalProcessingOption::kContinueProcessing;
}
virtual const char* Name() const override {
const char* Name() const override {
return "WalFilterTestWithChangeBatchExtraKeys";
}
};
@ -884,16 +881,17 @@ TEST_F(DBTest2, WalFilterTestWithColumnFamilies) {
// for verification against the keys we expect.
std::map<uint32_t, std::vector<std::string>> cf_wal_keys_;
public:
virtual void ColumnFamilyLogNumberMap(
void ColumnFamilyLogNumberMap(
const std::map<uint32_t, uint64_t>& cf_lognumber_map,
const std::map<std::string, uint32_t>& cf_name_id_map) override {
cf_log_number_map_ = cf_lognumber_map;
cf_name_id_map_ = cf_name_id_map;
}
virtual WalProcessingOption LogRecordFound(
unsigned long long log_number, const std::string& /*log_file_name*/,
const WriteBatch& batch, WriteBatch* /*new_batch*/,
WalProcessingOption LogRecordFound(unsigned long long log_number,
const std::string& /*log_file_name*/,
const WriteBatch& batch,
WriteBatch* /*new_batch*/,
bool* /*batch_changed*/) override {
class LogRecordBatchHandler : public WriteBatch::Handler {
private:
@ -908,7 +906,7 @@ TEST_F(DBTest2, WalFilterTestWithColumnFamilies) {
cf_wal_keys_(cf_wal_keys),
log_number_(current_log_number){}
virtual Status PutCF(uint32_t column_family_id, const Slice& key,
Status PutCF(uint32_t column_family_id, const Slice& key,
const Slice& /*value*/) override {
auto it = cf_log_number_map_.find(column_family_id);
assert(it != cf_log_number_map_.end());
@ -929,7 +927,7 @@ TEST_F(DBTest2, WalFilterTestWithColumnFamilies) {
return WalProcessingOption::kContinueProcessing;
}
virtual const char* Name() const override {
const char* Name() const override {
return "WalFilterTestWithColumnFamilies";
}
@ -1452,7 +1450,7 @@ class PinL0IndexAndFilterBlocksTest
public testing::WithParamInterface<std::tuple<bool, bool>> {
public:
PinL0IndexAndFilterBlocksTest() : DBTestBase("/db_pin_l0_index_bloom_test") {}
virtual void SetUp() override {
void SetUp() override {
infinite_max_files_ = std::get<0>(GetParam());
disallow_preload_ = std::get<1>(GetParam());
}
@ -1755,7 +1753,7 @@ class MockPersistentCache : public PersistentCache {
"GetUniqueIdFromFile:FS_IOC_GETVERSION", UniqueIdCallback);
}
virtual ~MockPersistentCache() {}
~MockPersistentCache() override {}
PersistentCache::StatsType Stats() override {
return PersistentCache::StatsType();
@ -2646,9 +2644,7 @@ TEST_F(DBTest2, ReadCallbackTest) {
class TestReadCallback : public ReadCallback {
public:
explicit TestReadCallback(SequenceNumber snapshot) : snapshot_(snapshot) {}
virtual bool IsVisible(SequenceNumber seq) override {
return seq <= snapshot_;
}
bool IsVisible(SequenceNumber seq) override { return seq <= snapshot_; }
private:
SequenceNumber snapshot_;

View File

@ -27,7 +27,7 @@ class DBTestUniversalCompactionBase
public:
explicit DBTestUniversalCompactionBase(
const std::string& path) : DBTestBase(path) {}
virtual void SetUp() override {
void SetUp() override {
num_levels_ = std::get<0>(GetParam());
exclusive_manual_compaction_ = std::get<1>(GetParam());
}
@ -63,13 +63,13 @@ void VerifyCompactionResult(
class KeepFilter : public CompactionFilter {
public:
virtual bool Filter(int /*level*/, const Slice& /*key*/,
const Slice& /*value*/, std::string* /*new_value*/,
bool Filter(int /*level*/, const Slice& /*key*/, const Slice& /*value*/,
std::string* /*new_value*/,
bool* /*value_changed*/) const override {
return false;
}
virtual const char* Name() const override { return "KeepFilter"; }
const char* Name() const override { return "KeepFilter"; }
};
class KeepFilterFactory : public CompactionFilterFactory {
@ -77,7 +77,7 @@ class KeepFilterFactory : public CompactionFilterFactory {
explicit KeepFilterFactory(bool check_context = false)
: check_context_(check_context) {}
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& context) override {
if (check_context_) {
EXPECT_EQ(expect_full_compaction_.load(), context.is_full_compaction);
@ -86,7 +86,7 @@ class KeepFilterFactory : public CompactionFilterFactory {
return std::unique_ptr<CompactionFilter>(new KeepFilter());
}
virtual const char* Name() const override { return "KeepFilterFactory"; }
const char* Name() const override { return "KeepFilterFactory"; }
bool check_context_;
std::atomic_bool expect_full_compaction_;
std::atomic_bool expect_manual_compaction_;
@ -95,14 +95,14 @@ class KeepFilterFactory : public CompactionFilterFactory {
class DelayFilter : public CompactionFilter {
public:
explicit DelayFilter(DBTestBase* d) : db_test(d) {}
virtual bool Filter(int /*level*/, const Slice& /*key*/,
const Slice& /*value*/, std::string* /*new_value*/,
bool Filter(int /*level*/, const Slice& /*key*/, const Slice& /*value*/,
std::string* /*new_value*/,
bool* /*value_changed*/) const override {
db_test->env_->addon_time_.fetch_add(1000);
return true;
}
virtual const char* Name() const override { return "DelayFilter"; }
const char* Name() const override { return "DelayFilter"; }
private:
DBTestBase* db_test;
@ -111,12 +111,12 @@ class DelayFilter : public CompactionFilter {
class DelayFilterFactory : public CompactionFilterFactory {
public:
explicit DelayFilterFactory(DBTestBase* d) : db_test(d) {}
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& /*context*/) override {
return std::unique_ptr<CompactionFilter>(new DelayFilter(db_test));
}
virtual const char* Name() const override { return "DelayFilterFactory"; }
const char* Name() const override { return "DelayFilterFactory"; }
private:
DBTestBase* db_test;

View File

@ -134,7 +134,9 @@ class ExternalSSTFileBasicTest
write_global_seqno, verify_checksums_before_ingest, true_data);
}
~ExternalSSTFileBasicTest() { test::DestroyDir(env_, sst_files_dir_); }
~ExternalSSTFileBasicTest() override {
test::DestroyDir(env_, sst_files_dir_);
}
protected:
std::string sst_files_dir_;

View File

@ -283,7 +283,7 @@ class ExternalSSTFileTest
return db_->IngestExternalFile(files, opts);
}
~ExternalSSTFileTest() { test::DestroyDir(env_, sst_files_dir_); }
~ExternalSSTFileTest() override { test::DestroyDir(env_, sst_files_dir_); }
protected:
int last_file_id_ = 0;
@ -571,7 +571,7 @@ class SstFileWriterCollector : public TablePropertiesCollector {
return Status::OK();
}
virtual UserCollectedProperties GetReadableProperties() const override {
UserCollectedProperties GetReadableProperties() const override {
return UserCollectedProperties{};
}
@ -585,7 +585,7 @@ class SstFileWriterCollectorFactory : public TablePropertiesCollectorFactory {
public:
explicit SstFileWriterCollectorFactory(std::string prefix)
: prefix_(prefix), num_created_(0) {}
virtual TablePropertiesCollector* CreateTablePropertiesCollector(
TablePropertiesCollector* CreateTablePropertiesCollector(
TablePropertiesCollectorFactory::Context /*context*/) override {
num_created_++;
return new SstFileWriterCollector(prefix_);

View File

@ -83,7 +83,7 @@ class FaultInjectionTest
env_(nullptr),
db_(nullptr) {}
~FaultInjectionTest() {
~FaultInjectionTest() override {
rocksdb::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks();
}

View File

@ -47,7 +47,7 @@ class FileIndexerTest : public testing::Test {
FileIndexerTest()
: kNumLevels(4), files(new std::vector<FileMetaData*>[kNumLevels]) {}
~FileIndexerTest() {
~FileIndexerTest() override {
ClearFiles();
delete[] files;
}

View File

@ -46,7 +46,7 @@ class ForwardLevelIterator : public InternalIterator {
pinned_iters_mgr_(nullptr),
prefix_extractor_(prefix_extractor) {}
~ForwardLevelIterator() {
~ForwardLevelIterator() override {
// Reset current pointer
if (pinned_iters_mgr_ && pinned_iters_mgr_->PinningEnabled()) {
pinned_iters_mgr_->PinIterator(file_iter_);

View File

@ -46,22 +46,20 @@ class EventListenerTest : public DBTestBase {
};
struct TestPropertiesCollector : public rocksdb::TablePropertiesCollector {
virtual rocksdb::Status AddUserKey(const rocksdb::Slice& /*key*/,
rocksdb::Status AddUserKey(const rocksdb::Slice& /*key*/,
const rocksdb::Slice& /*value*/,
rocksdb::EntryType /*type*/,
rocksdb::SequenceNumber /*seq*/,
uint64_t /*file_size*/) override {
return Status::OK();
}
virtual rocksdb::Status Finish(
rocksdb::Status Finish(
rocksdb::UserCollectedProperties* properties) override {
properties->insert({"0", "1"});
return Status::OK();
}
virtual const char* Name() const override {
return "TestTablePropertiesCollector";
}
const char* Name() const override { return "TestTablePropertiesCollector"; }
rocksdb::UserCollectedProperties GetReadableProperties() const override {
rocksdb::UserCollectedProperties ret;
@ -72,7 +70,7 @@ struct TestPropertiesCollector : public rocksdb::TablePropertiesCollector {
class TestPropertiesCollectorFactory : public TablePropertiesCollectorFactory {
public:
virtual TablePropertiesCollector* CreateTablePropertiesCollector(
TablePropertiesCollector* CreateTablePropertiesCollector(
TablePropertiesCollectorFactory::Context /*context*/) override {
return new TestPropertiesCollector;
}
@ -603,7 +601,7 @@ class TableFileCreationListener : public EventListener {
Status NewWritableFile(const std::string& fname,
std::unique_ptr<WritableFile>* result,
const EnvOptions& options) {
const EnvOptions& options) override {
if (fname.size() > 4 && fname.substr(fname.size() - 4) == ".sst") {
if (!status_.ok()) {
return status_;

View File

@ -61,7 +61,7 @@ class LogTest : public ::testing::TestWithParam<int> {
force_eof_position_(0),
returned_partial_(false) { }
virtual Status Read(size_t n, Slice* result, char* scratch) override {
Status Read(size_t n, Slice* result, char* scratch) override {
EXPECT_TRUE(!returned_partial_) << "must not Read() after eof/error";
if (force_error_) {
@ -100,7 +100,7 @@ class LogTest : public ::testing::TestWithParam<int> {
return Status::OK();
}
virtual Status Skip(uint64_t n) override {
Status Skip(uint64_t n) override {
if (n > contents_.size()) {
contents_.clear();
return Status::NotFound("in-memory file skipepd past end");
@ -118,7 +118,7 @@ class LogTest : public ::testing::TestWithParam<int> {
std::string message_;
ReportCollector() : dropped_bytes_(0) { }
virtual void Corruption(size_t bytes, const Status& status) override {
void Corruption(size_t bytes, const Status& status) override {
dropped_bytes_ += bytes;
message_.append(status.ToString());
}
@ -661,7 +661,7 @@ class RetriableLogTest : public ::testing::TestWithParam<int> {
std::string message_;
ReportCollector() : dropped_bytes_(0) {}
virtual void Corruption(size_t bytes, const Status& status) override {
void Corruption(size_t bytes, const Status& status) override {
dropped_bytes_ += bytes;
message_.append(status.ToString());
}

View File

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

View File

@ -289,7 +289,7 @@ class MemTableIterator : public InternalIterator {
}
}
~MemTableIterator() {
~MemTableIterator() override {
#ifndef NDEBUG
// Assert that the MemTableIterator is never deleted while
// Pinning is Enabled.
@ -303,15 +303,14 @@ class MemTableIterator : public InternalIterator {
}
#ifndef NDEBUG
virtual void SetPinnedItersMgr(
PinnedIteratorsManager* pinned_iters_mgr) override {
void SetPinnedItersMgr(PinnedIteratorsManager* pinned_iters_mgr) override {
pinned_iters_mgr_ = pinned_iters_mgr;
}
PinnedIteratorsManager* pinned_iters_mgr_ = nullptr;
#endif
virtual bool Valid() const override { return valid_; }
virtual void Seek(const Slice& k) override {
bool Valid() const override { return valid_; }
void Seek(const Slice& k) override {
PERF_TIMER_GUARD(seek_on_memtable_time);
PERF_COUNTER_ADD(seek_on_memtable_count, 1);
if (bloom_ != nullptr) {
@ -327,7 +326,7 @@ class MemTableIterator : public InternalIterator {
iter_->Seek(k, nullptr);
valid_ = iter_->Valid();
}
virtual void SeekForPrev(const Slice& k) override {
void SeekForPrev(const Slice& k) override {
PERF_TIMER_GUARD(seek_on_memtable_time);
PERF_COUNTER_ADD(seek_on_memtable_count, 1);
if (bloom_ != nullptr) {
@ -349,44 +348,44 @@ class MemTableIterator : public InternalIterator {
Prev();
}
}
virtual void SeekToFirst() override {
void SeekToFirst() override {
iter_->SeekToFirst();
valid_ = iter_->Valid();
}
virtual void SeekToLast() override {
void SeekToLast() override {
iter_->SeekToLast();
valid_ = iter_->Valid();
}
virtual void Next() override {
void Next() override {
PERF_COUNTER_ADD(next_on_memtable_count, 1);
assert(Valid());
iter_->Next();
valid_ = iter_->Valid();
}
virtual void Prev() override {
void Prev() override {
PERF_COUNTER_ADD(prev_on_memtable_count, 1);
assert(Valid());
iter_->Prev();
valid_ = iter_->Valid();
}
virtual Slice key() const override {
Slice key() const override {
assert(Valid());
return GetLengthPrefixedSlice(iter_->key());
}
virtual Slice value() const override {
Slice value() const override {
assert(Valid());
Slice key_slice = GetLengthPrefixedSlice(iter_->key());
return GetLengthPrefixedSlice(key_slice.data() + key_slice.size());
}
virtual Status status() const override { return Status::OK(); }
Status status() const override { return Status::OK(); }
virtual bool IsKeyPinned() const override {
bool IsKeyPinned() const override {
// memtable data is always pinned
return true;
}
virtual bool IsValuePinned() const override {
bool IsValuePinned() const override {
// memtable value is always pinned, except if we allow inplace update.
return value_pinned_;
}

View File

@ -62,7 +62,7 @@ class MemTableListTest : public testing::Test {
}
}
~MemTableListTest() {
~MemTableListTest() override {
if (db) {
std::vector<ColumnFamilyDescriptor> cf_descs(handles.size());
for (int i = 0; i != static_cast<int>(handles.size()); ++i) {

View File

@ -20,7 +20,7 @@ class MergeHelperTest : public testing::Test {
public:
MergeHelperTest() { env_ = Env::Default(); }
~MergeHelperTest() = default;
~MergeHelperTest() override = default;
Status Run(SequenceNumber stop_before, bool at_bottom,
SequenceNumber latest_snapshot = 0) {

View File

@ -38,11 +38,8 @@ class CountMergeOperator : public AssociativeMergeOperator {
mergeOperator_ = MergeOperators::CreateUInt64AddOperator();
}
virtual bool Merge(const Slice& key,
const Slice* existing_value,
const Slice& value,
std::string* new_value,
Logger* logger) const override {
bool Merge(const Slice& key, const Slice* existing_value, const Slice& value,
std::string* new_value, Logger* logger) const override {
assert(new_value->empty());
++num_merge_operator_calls;
if (existing_value == nullptr) {
@ -58,7 +55,7 @@ class CountMergeOperator : public AssociativeMergeOperator {
logger);
}
virtual bool PartialMergeMulti(const Slice& key,
bool PartialMergeMulti(const Slice& key,
const std::deque<Slice>& operand_list,
std::string* new_value,
Logger* logger) const override {
@ -68,9 +65,7 @@ class CountMergeOperator : public AssociativeMergeOperator {
logger);
}
virtual const char* Name() const override {
return "UInt64AddOperator";
}
const char* Name() const override { return "UInt64AddOperator"; }
private:
std::shared_ptr<MergeOperator> mergeOperator_;
@ -230,7 +225,7 @@ class MergeBasedCounters : public Counters {
}
// mapped to a rocksdb Merge operation
virtual bool add(const std::string& key, uint64_t value) override {
bool add(const std::string& key, uint64_t value) override {
char encoded[sizeof(uint64_t)];
EncodeFixed64(encoded, value);
Slice slice(encoded, sizeof(uint64_t));

View File

@ -109,7 +109,7 @@ class PlainTableDBTest : public testing::Test,
public:
PlainTableDBTest() : env_(Env::Default()) {}
~PlainTableDBTest() {
~PlainTableDBTest() override {
delete db_;
EXPECT_OK(DestroyDB(dbname_, Options()));
}
@ -290,10 +290,10 @@ class TestPlainTableReader : public PlainTableReader {
EXPECT_EQ(column_family_name, props->column_family_name);
}
virtual ~TestPlainTableReader() {}
~TestPlainTableReader() override {}
private:
virtual bool MatchBloom(uint32_t hash) const override {
bool MatchBloom(uint32_t hash) const override {
bool ret = PlainTableReader::MatchBloom(hash);
if (*expect_bloom_not_match_) {
EXPECT_TRUE(!ret);

View File

@ -83,7 +83,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 override {
int Compare(const Slice& a, const Slice& b) const override {
const TestKey kkey_a = SliceToTestKey(a);
const TestKey kkey_b = SliceToTestKey(b);
const TestKey *key_a = &kkey_a;
@ -122,14 +122,12 @@ class TestKeyComparator : public Comparator {
return Compare(TestKeyToSlice(sa, a), TestKeyToSlice(sb, b)) < 0;
}
virtual const char* Name() const override {
return "TestKeyComparator";
}
const char* Name() const override { return "TestKeyComparator"; }
virtual void FindShortestSeparator(std::string* /*start*/,
void FindShortestSeparator(std::string* /*start*/,
const Slice& /*limit*/) const override {}
virtual void FindShortSuccessor(std::string* /*key*/) const override {}
void FindShortSuccessor(std::string* /*key*/) const override {}
};
namespace {
@ -195,27 +193,23 @@ class SamePrefixTransform : public SliceTransform {
explicit SamePrefixTransform(const Slice& prefix)
: prefix_(prefix), name_("rocksdb.SamePrefix." + prefix.ToString()) {}
virtual const char* Name() const override { return name_.c_str(); }
const char* Name() const override { return name_.c_str(); }
virtual Slice Transform(const Slice& src) const override {
Slice Transform(const Slice& src) const override {
assert(InDomain(src));
return prefix_;
}
virtual bool InDomain(const Slice& src) const override {
bool InDomain(const Slice& src) const override {
if (src.size() >= prefix_.size()) {
return Slice(src.data(), prefix_.size()) == prefix_;
}
return false;
}
virtual bool InRange(const Slice& dst) const override {
return dst == prefix_;
}
bool InRange(const Slice& dst) const override { return dst == prefix_; }
virtual bool FullLengthEnabled(size_t* /*len*/) const override {
return false;
}
bool FullLengthEnabled(size_t* /*len*/) const override { return false; }
};
} // namespace
@ -283,9 +277,8 @@ class PrefixTest : public testing::Test {
PrefixTest() : option_config_(kBegin) {
options.comparator = new TestKeyComparator();
}
~PrefixTest() {
delete options.comparator;
}
~PrefixTest() override { delete options.comparator; }
protected:
enum OptionConfig {
kBegin,

View File

@ -336,7 +336,7 @@ class Repairer {
Env* env;
std::shared_ptr<Logger> info_log;
uint64_t lognum;
virtual void Corruption(size_t bytes, const Status& s) override {
void Corruption(size_t bytes, const Status& s) override {
// We print error messages for corruption, but continue repairing.
ROCKS_LOG_ERROR(info_log, "Log #%" PRIu64 ": dropping %d bytes; %s",
lognum, static_cast<int>(bytes), s.ToString().c_str());

View File

@ -28,7 +28,7 @@ namespace rocksdb {
class TablePropertiesTest : public testing::Test,
public testing::WithParamInterface<bool> {
public:
virtual void SetUp() override { backward_mode_ = GetParam(); }
void SetUp() override { backward_mode_ = GetParam(); }
bool backward_mode_;
};
@ -106,7 +106,7 @@ class RegularKeysStartWithA: public TablePropertiesCollector {
return Status::OK();
}
virtual UserCollectedProperties GetReadableProperties() const override {
UserCollectedProperties GetReadableProperties() const override {
return UserCollectedProperties{};
}
@ -143,7 +143,7 @@ class RegularKeysStartWithABackwardCompatible
return Status::OK();
}
virtual UserCollectedProperties GetReadableProperties() const override {
UserCollectedProperties GetReadableProperties() const override {
return UserCollectedProperties{};
}
@ -172,7 +172,7 @@ class RegularKeysStartWithAInternal : public IntTblPropCollector {
return Status::OK();
}
virtual UserCollectedProperties GetReadableProperties() const override {
UserCollectedProperties GetReadableProperties() const override {
return UserCollectedProperties{};
}
@ -185,7 +185,7 @@ class RegularKeysStartWithAFactory : public IntTblPropCollectorFactory,
public:
explicit RegularKeysStartWithAFactory(bool backward_mode)
: backward_mode_(backward_mode) {}
virtual TablePropertiesCollector* CreateTablePropertiesCollector(
TablePropertiesCollector* CreateTablePropertiesCollector(
TablePropertiesCollectorFactory::Context context) override {
EXPECT_EQ(kTestColumnFamilyId, context.column_family_id);
if (!backward_mode_) {
@ -194,7 +194,7 @@ class RegularKeysStartWithAFactory : public IntTblPropCollectorFactory,
return new RegularKeysStartWithABackwardCompatible();
}
}
virtual IntTblPropCollector* CreateIntTblPropCollector(
IntTblPropCollector* CreateIntTblPropCollector(
uint32_t /*column_family_id*/) override {
return new RegularKeysStartWithAInternal();
}
@ -205,7 +205,7 @@ class RegularKeysStartWithAFactory : public IntTblPropCollectorFactory,
class FlushBlockEveryThreePolicy : public FlushBlockPolicy {
public:
virtual bool Update(const Slice& /*key*/, const Slice& /*value*/) override {
bool Update(const Slice& /*key*/, const Slice& /*value*/) override {
return (++count_ % 3U == 0);
}

View File

@ -168,23 +168,22 @@ class HashLinkListRep : public MemTableRep {
int bucket_entries_logging_threshold,
bool if_log_bucket_dist_when_flash);
virtual KeyHandle Allocate(const size_t len, char** buf) override;
KeyHandle Allocate(const size_t len, char** buf) override;
virtual void Insert(KeyHandle handle) override;
void Insert(KeyHandle handle) override;
virtual bool Contains(const char* key) const override;
bool Contains(const char* key) const override;
virtual size_t ApproximateMemoryUsage() override;
size_t ApproximateMemoryUsage() override;
virtual void Get(const LookupKey& k, void* callback_args,
bool (*callback_func)(void* arg,
const char* entry)) override;
void Get(const LookupKey& k, void* callback_args,
bool (*callback_func)(void* arg, const char* entry)) override;
virtual ~HashLinkListRep();
~HashLinkListRep() override;
virtual MemTableRep::Iterator* GetIterator(Arena* arena = nullptr) override;
MemTableRep::Iterator* GetIterator(Arena* arena = nullptr) override;
virtual MemTableRep::Iterator* GetDynamicPrefixIterator(
MemTableRep::Iterator* GetDynamicPrefixIterator(
Arena* arena = nullptr) override;
private:
@ -265,36 +264,34 @@ class HashLinkListRep : public MemTableRep {
explicit FullListIterator(MemtableSkipList* list, Allocator* allocator)
: iter_(list), full_list_(list), allocator_(allocator) {}
virtual ~FullListIterator() {
}
~FullListIterator() override {}
// Returns true iff the iterator is positioned at a valid node.
virtual bool Valid() const override { return iter_.Valid(); }
bool Valid() const override { return iter_.Valid(); }
// Returns the key at the current position.
// REQUIRES: Valid()
virtual const char* key() const override {
const char* key() const override {
assert(Valid());
return iter_.key();
}
// Advances to the next position.
// REQUIRES: Valid()
virtual void Next() override {
void Next() override {
assert(Valid());
iter_.Next();
}
// Advances to the previous position.
// REQUIRES: Valid()
virtual void Prev() override {
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) override {
void Seek(const Slice& internal_key, const char* memtable_key) override {
const char* encoded_key =
(memtable_key != nullptr) ?
memtable_key : EncodeKey(&tmp_, internal_key);
@ -302,7 +299,7 @@ class HashLinkListRep : public MemTableRep {
}
// Retreat to the last entry with a key <= target
virtual void SeekForPrev(const Slice& internal_key,
void SeekForPrev(const Slice& internal_key,
const char* memtable_key) override {
const char* encoded_key = (memtable_key != nullptr)
? memtable_key
@ -312,11 +309,12 @@ 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() override { iter_.SeekToFirst(); }
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() override { iter_.SeekToLast(); }
void SeekToLast() override { iter_.SeekToLast(); }
private:
MemtableSkipList::Iterator iter_;
// To destruct with the iterator.
@ -333,42 +331,42 @@ class HashLinkListRep : public MemTableRep {
head_(head),
node_(nullptr) {}
virtual ~LinkListIterator() {}
~LinkListIterator() override {}
// Returns true iff the iterator is positioned at a valid node.
virtual bool Valid() const override { return node_ != nullptr; }
bool Valid() const override { return node_ != nullptr; }
// Returns the key at the current position.
// REQUIRES: Valid()
virtual const char* key() const override {
const char* key() const override {
assert(Valid());
return node_->key;
}
// Advances to the next position.
// REQUIRES: Valid()
virtual void Next() override {
void Next() override {
assert(Valid());
node_ = node_->Next();
}
// Advances to the previous position.
// REQUIRES: Valid()
virtual void Prev() override {
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,
void Seek(const Slice& internal_key,
const char* /*memtable_key*/) override {
node_ = hash_link_list_rep_->FindGreaterOrEqualInBucket(head_,
internal_key);
}
// Retreat to the last entry with a key <= target
virtual void SeekForPrev(const Slice& /*internal_key*/,
void SeekForPrev(const Slice& /*internal_key*/,
const char* /*memtable_key*/) override {
// Since we do not support Prev()
// We simply do not support SeekForPrev
@ -377,7 +375,7 @@ 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() override {
void SeekToFirst() override {
// Prefix iterator does not support total order.
// We simply set the iterator to invalid state
Reset(nullptr);
@ -385,7 +383,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() override {
void SeekToLast() override {
// Prefix iterator does not support total order.
// We simply set the iterator to invalid state
Reset(nullptr);
@ -414,7 +412,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) override {
void Seek(const Slice& k, const char* memtable_key) override {
auto transformed = memtable_rep_.GetPrefix(k);
auto* bucket = memtable_rep_.GetBucket(transformed);
@ -443,21 +441,21 @@ class HashLinkListRep : public MemTableRep {
}
}
virtual bool Valid() const override {
bool Valid() const override {
if (skip_list_iter_) {
return skip_list_iter_->Valid();
}
return HashLinkListRep::LinkListIterator::Valid();
}
virtual const char* key() const override {
const char* key() const override {
if (skip_list_iter_) {
return skip_list_iter_->key();
}
return HashLinkListRep::LinkListIterator::key();
}
virtual void Next() override {
void Next() override {
if (skip_list_iter_) {
skip_list_iter_->Next();
} else {
@ -476,19 +474,19 @@ class HashLinkListRep : public MemTableRep {
// instantiating an empty bucket over which to iterate.
public:
EmptyIterator() { }
virtual bool Valid() const override { return false; }
virtual const char* key() const override {
bool Valid() const override { return false; }
const char* key() const override {
assert(false);
return nullptr;
}
virtual void Next() override {}
virtual void Prev() override {}
virtual void Seek(const Slice& /*user_key*/,
void Next() override {}
void Prev() override {}
void Seek(const Slice& /*user_key*/,
const char* /*memtable_key*/) override {}
virtual void SeekForPrev(const Slice& /*user_key*/,
void SeekForPrev(const Slice& /*user_key*/,
const char* /*memtable_key*/) override {}
virtual void SeekToFirst() override {}
virtual void SeekToLast() override {}
void SeekToFirst() override {}
void SeekToLast() override {}
private:
};

View File

@ -28,21 +28,20 @@ class HashSkipListRep : public MemTableRep {
size_t bucket_size, int32_t skiplist_height,
int32_t skiplist_branching_factor);
virtual void Insert(KeyHandle handle) override;
void Insert(KeyHandle handle) override;
virtual bool Contains(const char* key) const override;
bool Contains(const char* key) const override;
virtual size_t ApproximateMemoryUsage() override;
size_t ApproximateMemoryUsage() override;
virtual void Get(const LookupKey& k, void* callback_args,
bool (*callback_func)(void* arg,
const char* entry)) override;
void Get(const LookupKey& k, void* callback_args,
bool (*callback_func)(void* arg, const char* entry)) override;
virtual ~HashSkipListRep();
~HashSkipListRep() override;
virtual MemTableRep::Iterator* GetIterator(Arena* arena = nullptr) override;
MemTableRep::Iterator* GetIterator(Arena* arena = nullptr) override;
virtual MemTableRep::Iterator* GetDynamicPrefixIterator(
MemTableRep::Iterator* GetDynamicPrefixIterator(
Arena* arena = nullptr) override;
private:
@ -85,7 +84,7 @@ class HashSkipListRep : public MemTableRep {
Arena* arena = nullptr)
: list_(list), iter_(list), own_list_(own_list), arena_(arena) {}
virtual ~Iterator() {
~Iterator() override {
// if we own the list, we should also delete it
if (own_list_) {
assert(list_ != nullptr);
@ -94,34 +93,31 @@ class HashSkipListRep : public MemTableRep {
}
// Returns true iff the iterator is positioned at a valid node.
virtual bool Valid() const override {
return list_ != nullptr && iter_.Valid();
}
bool Valid() const override { return list_ != nullptr && iter_.Valid(); }
// Returns the key at the current position.
// REQUIRES: Valid()
virtual const char* key() const override {
const char* key() const override {
assert(Valid());
return iter_.key();
}
// Advances to the next position.
// REQUIRES: Valid()
virtual void Next() override {
void Next() override {
assert(Valid());
iter_.Next();
}
// Advances to the previous position.
// REQUIRES: Valid()
virtual void Prev() override {
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) override {
void Seek(const Slice& internal_key, const char* memtable_key) override {
if (list_ != nullptr) {
const char* encoded_key =
(memtable_key != nullptr) ?
@ -131,7 +127,7 @@ class HashSkipListRep : public MemTableRep {
}
// Retreat to the last entry with a key <= target
virtual void SeekForPrev(const Slice& /*internal_key*/,
void SeekForPrev(const Slice& /*internal_key*/,
const char* /*memtable_key*/) override {
// not supported
assert(false);
@ -139,7 +135,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() override {
void SeekToFirst() override {
if (list_ != nullptr) {
iter_.SeekToFirst();
}
@ -147,11 +143,12 @@ 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() override {
void SeekToLast() override {
if (list_ != nullptr) {
iter_.SeekToLast();
}
}
protected:
void Reset(Bucket* list) {
if (own_list_) {
@ -181,7 +178,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) override {
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);
@ -189,7 +186,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() override {
void SeekToFirst() override {
// Prefix iterator does not support total order.
// We simply set the iterator to invalid state
Reset(nullptr);
@ -197,11 +194,12 @@ 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() override {
void SeekToLast() override {
// Prefix iterator does not support total order.
// We simply set the iterator to invalid state
Reset(nullptr);
}
private:
// the underlying memtable
const HashSkipListRep& memtable_rep_;
@ -212,19 +210,19 @@ class HashSkipListRep : public MemTableRep {
// instantiating an empty bucket over which to iterate.
public:
EmptyIterator() { }
virtual bool Valid() const override { return false; }
virtual const char* key() const override {
bool Valid() const override { return false; }
const char* key() const override {
assert(false);
return nullptr;
}
virtual void Next() override {}
virtual void Prev() override {}
virtual void Seek(const Slice& /*internal_key*/,
void Next() override {}
void Prev() override {}
void Seek(const Slice& /*internal_key*/,
const char* /*memtable_key*/) override {}
virtual void SeekForPrev(const Slice& /*internal_key*/,
void SeekForPrev(const Slice& /*internal_key*/,
const char* /*memtable_key*/) override {}
virtual void SeekToFirst() override {}
virtual void SeekToLast() override {}
void SeekToFirst() override {}
void SeekToLast() override {}
private:
};

View File

@ -27,55 +27,53 @@ public:
transform_(transform),
lookahead_(lookahead) {}
virtual KeyHandle Allocate(const size_t len, char** buf) override {
KeyHandle Allocate(const size_t len, char** buf) override {
*buf = skip_list_.AllocateKey(len);
return static_cast<KeyHandle>(*buf);
}
// Insert key into the list.
// REQUIRES: nothing that compares equal to key is currently in the list.
virtual void Insert(KeyHandle handle) override {
void Insert(KeyHandle handle) override {
skip_list_.Insert(static_cast<char*>(handle));
}
virtual bool InsertKey(KeyHandle handle) override {
bool InsertKey(KeyHandle handle) override {
return skip_list_.Insert(static_cast<char*>(handle));
}
virtual void InsertWithHint(KeyHandle handle, void** hint) override {
void InsertWithHint(KeyHandle handle, void** hint) override {
skip_list_.InsertWithHint(static_cast<char*>(handle), hint);
}
virtual bool InsertKeyWithHint(KeyHandle handle, void** hint) override {
bool InsertKeyWithHint(KeyHandle handle, void** hint) override {
return skip_list_.InsertWithHint(static_cast<char*>(handle), hint);
}
virtual void InsertConcurrently(KeyHandle handle) override {
void InsertConcurrently(KeyHandle handle) override {
skip_list_.InsertConcurrently(static_cast<char*>(handle));
}
virtual bool InsertKeyConcurrently(KeyHandle handle) override {
bool InsertKeyConcurrently(KeyHandle handle) override {
return skip_list_.InsertConcurrently(static_cast<char*>(handle));
}
// Returns true iff an entry that compares equal to key is in the list.
virtual bool Contains(const char* key) const override {
bool Contains(const char* key) const override {
return skip_list_.Contains(key);
}
virtual size_t ApproximateMemoryUsage() override {
size_t ApproximateMemoryUsage() override {
// All memory is allocated through allocator; nothing to report here
return 0;
}
virtual void Get(const LookupKey& k, void* callback_args,
bool (*callback_func)(void* arg,
const char* entry)) override {
void Get(const LookupKey& k, void* callback_args,
bool (*callback_func)(void* arg, const char* entry)) override {
SkipListRep::Iterator iter(&skip_list_);
Slice dummy_slice;
for (iter.Seek(dummy_slice, k.memtable_key().data());
iter.Valid() && callback_func(callback_args, iter.key());
iter.Next()) {
iter.Valid() && callback_func(callback_args, iter.key()); iter.Next()) {
}
}
@ -88,7 +86,7 @@ public:
return (end_count >= start_count) ? (end_count - start_count) : 0;
}
virtual ~SkipListRep() override { }
~SkipListRep() override {}
// Iteration over the contents of a skip list
class Iterator : public MemTableRep::Iterator {
@ -101,34 +99,25 @@ public:
const InlineSkipList<const MemTableRep::KeyComparator&>* list)
: iter_(list) {}
virtual ~Iterator() override { }
~Iterator() override {}
// Returns true iff the iterator is positioned at a valid node.
virtual bool Valid() const override {
return iter_.Valid();
}
bool Valid() const override { return iter_.Valid(); }
// Returns the key at the current position.
// REQUIRES: Valid()
virtual const char* key() const override {
return iter_.key();
}
const char* key() const override { return iter_.key(); }
// Advances to the next position.
// REQUIRES: Valid()
virtual void Next() override {
iter_.Next();
}
void Next() override { iter_.Next(); }
// Advances to the previous position.
// REQUIRES: Valid()
virtual void Prev() override {
iter_.Prev();
}
void Prev() override { iter_.Prev(); }
// Advance to the first entry with a key >= target
virtual void Seek(const Slice& user_key, const char* memtable_key)
override {
void Seek(const Slice& user_key, const char* memtable_key) override {
if (memtable_key != nullptr) {
iter_.Seek(memtable_key);
} else {
@ -137,8 +126,7 @@ public:
}
// Retreat to the last entry with a key <= target
virtual void SeekForPrev(const Slice& user_key,
const char* memtable_key) override {
void SeekForPrev(const Slice& user_key, const char* memtable_key) override {
if (memtable_key != nullptr) {
iter_.SeekForPrev(memtable_key);
} else {
@ -148,15 +136,12 @@ public:
// Position at the first entry in list.
// Final state of iterator is Valid() iff list is not empty.
virtual void SeekToFirst() override {
iter_.SeekToFirst();
}
void SeekToFirst() override { iter_.SeekToFirst(); }
// Position at the last entry in list.
// Final state of iterator is Valid() iff list is not empty.
virtual void SeekToLast() override {
iter_.SeekToLast();
}
void SeekToLast() override { iter_.SeekToLast(); }
protected:
std::string tmp_; // For passing to EncodeKey
};
@ -170,18 +155,16 @@ public:
explicit LookaheadIterator(const SkipListRep& rep) :
rep_(rep), iter_(&rep_.skip_list_), prev_(iter_) {}
virtual ~LookaheadIterator() override {}
~LookaheadIterator() override {}
virtual bool Valid() const override {
return iter_.Valid();
}
bool Valid() const override { return iter_.Valid(); }
virtual const char *key() const override {
const char* key() const override {
assert(Valid());
return iter_.key();
}
virtual void Next() override {
void Next() override {
assert(Valid());
bool advance_prev = true;
@ -206,14 +189,13 @@ public:
iter_.Next();
}
virtual void Prev() override {
void Prev() override {
assert(Valid());
iter_.Prev();
prev_ = iter_;
}
virtual void Seek(const Slice& internal_key, const char *memtable_key)
override {
void Seek(const Slice& internal_key, const char* memtable_key) override {
const char *encoded_key =
(memtable_key != nullptr) ?
memtable_key : EncodeKey(&tmp_, internal_key);
@ -236,7 +218,7 @@ public:
prev_ = iter_;
}
virtual void SeekForPrev(const Slice& internal_key,
void SeekForPrev(const Slice& internal_key,
const char* memtable_key) override {
const char* encoded_key = (memtable_key != nullptr)
? memtable_key
@ -245,12 +227,12 @@ public:
prev_ = iter_;
}
virtual void SeekToFirst() override {
void SeekToFirst() override {
iter_.SeekToFirst();
prev_ = iter_;
}
virtual void SeekToLast() override {
void SeekToLast() override {
iter_.SeekToLast();
prev_ = iter_;
}
@ -264,7 +246,7 @@ public:
InlineSkipList<const MemTableRep::KeyComparator&>::Iterator prev_;
};
virtual MemTableRep::Iterator* GetIterator(Arena* arena = nullptr) override {
MemTableRep::Iterator* GetIterator(Arena* arena = nullptr) override {
if (lookahead_ > 0) {
void *mem =
arena ? arena->AllocateAligned(sizeof(SkipListRep::LookaheadIterator))

View File

@ -31,20 +31,19 @@ class VectorRep : public MemTableRep {
// single buffer and pass that in as the parameter to Insert)
// REQUIRES: nothing that compares equal to key is currently in the
// collection.
virtual void Insert(KeyHandle handle) override;
void Insert(KeyHandle handle) override;
// Returns true iff an entry that compares equal to key is in the collection.
virtual bool Contains(const char* key) const override;
bool Contains(const char* key) const override;
virtual void MarkReadOnly() override;
void MarkReadOnly() override;
virtual size_t ApproximateMemoryUsage() override;
size_t ApproximateMemoryUsage() override;
virtual void Get(const LookupKey& k, void* callback_args,
bool (*callback_func)(void* arg,
const char* entry)) override;
void Get(const LookupKey& k, void* callback_args,
bool (*callback_func)(void* arg, const char* entry)) override;
virtual ~VectorRep() override { }
~VectorRep() override {}
class Iterator : public MemTableRep::Iterator {
class VectorRep* vrep_;
@ -62,41 +61,40 @@ class VectorRep : public MemTableRep {
// Initialize an iterator over the specified collection.
// The returned iterator is not valid.
// explicit Iterator(const MemTableRep* collection);
virtual ~Iterator() override { };
~Iterator() override{};
// Returns true iff the iterator is positioned at a valid node.
virtual bool Valid() const override;
bool Valid() const override;
// Returns the key at the current position.
// REQUIRES: Valid()
virtual const char* key() const override;
const char* key() const override;
// Advances to the next position.
// REQUIRES: Valid()
virtual void Next() override;
void Next() override;
// Advances to the previous position.
// REQUIRES: Valid()
virtual void Prev() override;
void Prev() override;
// Advance to the first entry with a key >= target
virtual void Seek(const Slice& user_key, const char* memtable_key) override;
void Seek(const Slice& user_key, const char* memtable_key) override;
// Advance to the first entry with a key <= target
virtual void SeekForPrev(const Slice& user_key,
const char* memtable_key) override;
void SeekForPrev(const Slice& user_key, const char* memtable_key) override;
// Position at the first entry in collection.
// Final state of iterator is Valid() iff collection is not empty.
virtual void SeekToFirst() override;
void SeekToFirst() override;
// Position at the last entry in collection.
// Final state of iterator is Valid() iff collection is not empty.
virtual void SeekToLast() override;
void SeekToLast() override;
};
// Return an iterator over the keys in this representation.
virtual MemTableRep::Iterator* GetIterator(Arena* arena) override;
MemTableRep::Iterator* GetIterator(Arena* arena) override;
private:
friend class Iterator;

View File

@ -21,18 +21,16 @@ namespace rocksdb {
// For testing: emit an array with one hash value per key
class TestHashFilter : public FilterPolicy {
public:
virtual const char* Name() const override { return "TestHashFilter"; }
const char* Name() const override { return "TestHashFilter"; }
virtual void CreateFilter(const Slice* keys, int n,
std::string* dst) const override {
void CreateFilter(const Slice* keys, int n, std::string* dst) const override {
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 override {
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)) {
@ -146,7 +144,7 @@ class BlockBasedFilterBlockTest : public testing::Test {
table_options_.filter_policy.reset(NewBloomFilterPolicy(10));
}
~BlockBasedFilterBlockTest() {}
~BlockBasedFilterBlockTest() override {}
};
TEST_F(BlockBasedFilterBlockTest, BlockBasedEmptyBuilder) {

View File

@ -210,14 +210,14 @@ class BlockBasedTableBuilder::BlockBasedTablePropertiesCollector
whole_key_filtering_(whole_key_filtering),
prefix_filtering_(prefix_filtering) {}
virtual Status InternalAdd(const Slice& /*key*/, const Slice& /*value*/,
Status InternalAdd(const Slice& /*key*/, const Slice& /*value*/,
uint64_t /*file_size*/) override {
// Intentionally left blank. Have no interest in collecting stats for
// individual key/value pairs.
return Status::OK();
}
virtual Status Finish(UserCollectedProperties* properties) override {
Status Finish(UserCollectedProperties* properties) override {
std::string val;
PutFixed32(&val, static_cast<uint32_t>(index_type_));
properties->insert({BlockBasedTablePropertyNames::kIndexType, val});
@ -229,11 +229,11 @@ class BlockBasedTableBuilder::BlockBasedTablePropertiesCollector
}
// The name of the properties collector can be used for debugging purpose.
virtual const char* Name() const override {
const char* Name() const override {
return "BlockBasedTablePropertiesCollector";
}
virtual UserCollectedProperties GetReadableProperties() const override {
UserCollectedProperties GetReadableProperties() const override {
// Intentionally left blank.
return UserCollectedProperties();
}

View File

@ -259,7 +259,7 @@ class PartitionIndexReader : public IndexReader, public Cleanable {
}
// return a two-level iterator: first level is on the partition index
virtual InternalIteratorBase<BlockHandle>* NewIterator(
InternalIteratorBase<BlockHandle>* NewIterator(
IndexBlockIter* /*iter*/ = nullptr, bool /*dont_care*/ = true,
bool fill_cache = true) override {
Statistics* kNullStats = nullptr;
@ -294,7 +294,7 @@ class PartitionIndexReader : public IndexReader, public Cleanable {
// in its destructor.
}
virtual void CacheDependencies(bool pin) override {
void CacheDependencies(bool pin) override {
// Before read partitions, prefetch them to avoid lots of IOs
auto rep = table_->rep_;
IndexBlockIter biter;
@ -362,12 +362,10 @@ class PartitionIndexReader : public IndexReader, public Cleanable {
}
}
virtual size_t size() const override { return index_block_->size(); }
virtual size_t usable_size() const override {
return index_block_->usable_size();
}
size_t size() const override { return index_block_->size(); }
size_t usable_size() const override { return index_block_->usable_size(); }
virtual size_t ApproximateMemoryUsage() const override {
size_t ApproximateMemoryUsage() const override {
assert(index_block_);
size_t usage = index_block_->ApproximateMemoryUsage();
#ifdef ROCKSDB_MALLOC_USABLE_SIZE
@ -436,7 +434,7 @@ class BinarySearchIndexReader : public IndexReader {
return s;
}
virtual InternalIteratorBase<BlockHandle>* NewIterator(
InternalIteratorBase<BlockHandle>* NewIterator(
IndexBlockIter* iter = nullptr, bool /*dont_care*/ = true,
bool /*dont_care*/ = true) override {
Statistics* kNullStats = nullptr;
@ -447,12 +445,10 @@ class BinarySearchIndexReader : public IndexReader {
index_key_includes_seq_, index_value_is_full_);
}
virtual size_t size() const override { return index_block_->size(); }
virtual size_t usable_size() const override {
return index_block_->usable_size();
}
size_t size() const override { return index_block_->size(); }
size_t usable_size() const override { return index_block_->usable_size(); }
virtual size_t ApproximateMemoryUsage() const override {
size_t ApproximateMemoryUsage() const override {
assert(index_block_);
size_t usage = index_block_->ApproximateMemoryUsage();
#ifdef ROCKSDB_MALLOC_USABLE_SIZE
@ -566,7 +562,7 @@ class HashIndexReader : public IndexReader {
return Status::OK();
}
virtual InternalIteratorBase<BlockHandle>* NewIterator(
InternalIteratorBase<BlockHandle>* NewIterator(
IndexBlockIter* iter = nullptr, bool total_order_seek = true,
bool /*dont_care*/ = true) override {
Statistics* kNullStats = nullptr;
@ -578,12 +574,10 @@ class HashIndexReader : public IndexReader {
false /* block_contents_pinned */, prefix_index_.get());
}
virtual size_t size() const override { return index_block_->size(); }
virtual size_t usable_size() const override {
return index_block_->usable_size();
}
size_t size() const override { return index_block_->size(); }
size_t usable_size() const override { return index_block_->usable_size(); }
virtual size_t ApproximateMemoryUsage() const override {
size_t ApproximateMemoryUsage() const override {
assert(index_block_);
size_t usage = index_block_->ApproximateMemoryUsage();
usage += prefixes_contents_.usable_size();
@ -610,7 +604,7 @@ class HashIndexReader : public IndexReader {
assert(index_block_ != nullptr);
}
~HashIndexReader() {}
~HashIndexReader() override {}
std::unique_ptr<Block> index_block_;
std::unique_ptr<BlockPrefixIndex> prefix_index_;

View File

@ -197,7 +197,7 @@ void CuckooTableReader::Prepare(const Slice& key) {
class CuckooTableIterator : public InternalIterator {
public:
explicit CuckooTableIterator(CuckooTableReader* reader);
~CuckooTableIterator() {}
~CuckooTableIterator() override {}
bool Valid() const override;
void SeekToFirst() override;
void SeekToLast() override;

View File

@ -30,8 +30,7 @@ class FlushBlockBySizePolicy : public FlushBlockPolicy {
align_(align),
data_block_builder_(data_block_builder) {}
virtual bool Update(const Slice& key,
const Slice& value) override {
bool Update(const Slice& key, const Slice& value) override {
// it makes no sense to flush when the data block is empty
if (data_block_builder_.empty()) {
return false;

View File

@ -20,12 +20,12 @@ class TestFilterBitsBuilder : public FilterBitsBuilder {
explicit TestFilterBitsBuilder() {}
// Add Key to filter
virtual void AddKey(const Slice& key) override {
void AddKey(const Slice& key) override {
hash_entries_.push_back(Hash(key.data(), key.size(), 1));
}
// Generate the filter using the keys that are added
virtual Slice Finish(std::unique_ptr<const char[]>* buf) override {
Slice Finish(std::unique_ptr<const char[]>* buf) override {
uint32_t len = static_cast<uint32_t>(hash_entries_.size()) * 4;
char* data = new char[len];
for (size_t i = 0; i < hash_entries_.size(); i++) {
@ -45,7 +45,7 @@ class TestFilterBitsReader : public FilterBitsReader {
explicit TestFilterBitsReader(const Slice& contents)
: data_(contents.data()), len_(static_cast<uint32_t>(contents.size())) {}
virtual bool MayMatch(const Slice& entry) override {
bool MayMatch(const Slice& entry) override {
uint32_t h = Hash(entry.data(), entry.size(), 1);
for (size_t i = 0; i + 4 <= len_; i += 4) {
if (h == DecodeFixed32(data_ + i)) {
@ -63,18 +63,16 @@ class TestFilterBitsReader : public FilterBitsReader {
class TestHashFilter : public FilterPolicy {
public:
virtual const char* Name() const override { return "TestHashFilter"; }
const char* Name() const override { return "TestHashFilter"; }
virtual void CreateFilter(const Slice* keys, int n,
std::string* dst) const override {
void CreateFilter(const Slice* keys, int n, std::string* dst) const override {
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 override {
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)) {
@ -84,12 +82,11 @@ class TestHashFilter : public FilterPolicy {
return false;
}
virtual FilterBitsBuilder* GetFilterBitsBuilder() const override {
FilterBitsBuilder* GetFilterBitsBuilder() const override {
return new TestFilterBitsBuilder();
}
virtual FilterBitsReader* GetFilterBitsReader(const Slice& contents)
const override {
FilterBitsReader* GetFilterBitsReader(const Slice& contents) const override {
return new TestFilterBitsReader(contents);
}
};
@ -145,7 +142,7 @@ class FullFilterBlockTest : public testing::Test {
table_options_.filter_policy.reset(NewBloomFilterPolicy(10, false));
}
~FullFilterBlockTest() {}
~FullFilterBlockTest() override {}
};
TEST_F(FullFilterBlockTest, EmptyBuilder) {

View File

@ -110,13 +110,13 @@ namespace {
class EmptyIterator : public Iterator {
public:
explicit EmptyIterator(const Status& s) : status_(s) { }
virtual bool Valid() const override { return false; }
virtual void Seek(const Slice& /*target*/) override {}
virtual void SeekForPrev(const Slice& /*target*/) override {}
virtual void SeekToFirst() override {}
virtual void SeekToLast() override {}
virtual void Next() override { assert(false); }
virtual void Prev() override { assert(false); }
bool Valid() const override { return false; }
void Seek(const Slice& /*target*/) override {}
void SeekForPrev(const Slice& /*target*/) override {}
void SeekToFirst() override {}
void SeekToLast() override {}
void Next() override { assert(false); }
void Prev() override { assert(false); }
Slice key() const override {
assert(false);
return Slice();
@ -125,7 +125,7 @@ class EmptyIterator : public Iterator {
assert(false);
return Slice();
}
virtual Status status() const override { return status_; }
Status status() const override { return status_; }
private:
Status status_;
@ -135,13 +135,13 @@ template <class TValue = Slice>
class EmptyInternalIterator : public InternalIteratorBase<TValue> {
public:
explicit EmptyInternalIterator(const Status& s) : status_(s) {}
virtual bool Valid() const override { return false; }
virtual void Seek(const Slice& /*target*/) override {}
virtual void SeekForPrev(const Slice& /*target*/) override {}
virtual void SeekToFirst() override {}
virtual void SeekToLast() override {}
virtual void Next() override { assert(false); }
virtual void Prev() override { assert(false); }
bool Valid() const override { return false; }
void Seek(const Slice& /*target*/) override {}
void SeekForPrev(const Slice& /*target*/) override {}
void SeekToFirst() override {}
void SeekToLast() override {}
void Next() override { assert(false); }
void Prev() override { assert(false); }
Slice key() const override {
assert(false);
return Slice();
@ -150,7 +150,7 @@ class EmptyInternalIterator : public InternalIteratorBase<TValue> {
assert(false);
return TValue();
}
virtual Status status() const override { return status_; }
Status status() const override { return status_; }
private:
Status status_;

View File

@ -19,7 +19,7 @@ class MergerTest : public testing::Test {
rnd_(3),
merging_iterator_(nullptr),
single_iterator_(nullptr) {}
~MergerTest() = default;
~MergerTest() override = default;
std::vector<std::string> GenerateStrings(size_t len, int string_len) {
std::vector<std::string> ret;

View File

@ -83,19 +83,17 @@ class MergingIterator : public InternalIterator {
}
}
virtual ~MergingIterator() {
~MergingIterator() override {
for (auto& child : children_) {
child.DeleteIter(is_arena_mode_);
}
}
virtual bool Valid() const override {
return current_ != nullptr && status_.ok();
}
bool Valid() const override { return current_ != nullptr && status_.ok(); }
virtual Status status() const override { return status_; }
Status status() const override { return status_; }
virtual void SeekToFirst() override {
void SeekToFirst() override {
ClearHeaps();
status_ = Status::OK();
for (auto& child : children_) {
@ -111,7 +109,7 @@ class MergingIterator : public InternalIterator {
current_ = CurrentForward();
}
virtual void SeekToLast() override {
void SeekToLast() override {
ClearHeaps();
InitMaxHeap();
status_ = Status::OK();
@ -128,7 +126,7 @@ class MergingIterator : public InternalIterator {
current_ = CurrentReverse();
}
virtual void Seek(const Slice& target) override {
void Seek(const Slice& target) override {
ClearHeaps();
status_ = Status::OK();
for (auto& child : children_) {
@ -153,7 +151,7 @@ class MergingIterator : public InternalIterator {
}
}
virtual void SeekForPrev(const Slice& target) override {
void SeekForPrev(const Slice& target) override {
ClearHeaps();
InitMaxHeap();
status_ = Status::OK();
@ -180,7 +178,7 @@ class MergingIterator : public InternalIterator {
}
}
virtual void Next() override {
void Next() override {
assert(Valid());
// Ensure that all children are positioned after key().
@ -214,7 +212,7 @@ class MergingIterator : public InternalIterator {
current_ = CurrentForward();
}
virtual void Prev() override {
void Prev() override {
assert(Valid());
// Ensure that all children are positioned before key().
// If we are moving in the reverse direction, it is already
@ -273,31 +271,30 @@ class MergingIterator : public InternalIterator {
current_ = CurrentReverse();
}
virtual Slice key() const override {
Slice key() const override {
assert(Valid());
return current_->key();
}
virtual Slice value() const override {
Slice value() const override {
assert(Valid());
return current_->value();
}
virtual void SetPinnedItersMgr(
PinnedIteratorsManager* pinned_iters_mgr) override {
void SetPinnedItersMgr(PinnedIteratorsManager* pinned_iters_mgr) override {
pinned_iters_mgr_ = pinned_iters_mgr;
for (auto& child : children_) {
child.SetPinnedItersMgr(pinned_iters_mgr);
}
}
virtual bool IsKeyPinned() const override {
bool IsKeyPinned() const override {
assert(Valid());
return pinned_iters_mgr_ && pinned_iters_mgr_->PinningEnabled() &&
current_->IsKeyPinned();
}
virtual bool IsValuePinned() const override {
bool IsValuePinned() const override {
assert(Valid());
return pinned_iters_mgr_ && pinned_iters_mgr_->PinningEnabled() &&
current_->IsValuePinned();

View File

@ -27,7 +27,7 @@ class MockedBlockBasedTable : public BlockBasedTable {
rep->cache_key_prefix_size = 10;
}
virtual CachableEntry<FilterBlockReader> GetFilter(
CachableEntry<FilterBlockReader> GetFilter(
FilePrefetchBuffer*, const BlockHandle& filter_blk_handle,
const bool /* unused */, bool /* unused */, GetContext* /* unused */,
const SliceTransform* prefix_extractor) const override {
@ -38,7 +38,7 @@ class MockedBlockBasedTable : public BlockBasedTable {
return {obj, nullptr};
}
virtual FilterBlockReader* ReadFilter(
FilterBlockReader* ReadFilter(
FilePrefetchBuffer*, const BlockHandle& filter_blk_handle,
const bool /* unused */,
const SliceTransform* prefix_extractor) const override {
@ -67,7 +67,7 @@ class PartitionedFilterBlockTest
}
std::shared_ptr<Cache> cache_;
~PartitionedFilterBlockTest() {}
~PartitionedFilterBlockTest() override {}
const std::string keys[4] = {"afoo", "bar", "box", "hello"};
const std::string missing_keys[2] = {"missing", "other"};

View File

@ -54,7 +54,7 @@ inline uint32_t GetFixed32Element(const char* base, size_t offset) {
class PlainTableIterator : public InternalIterator {
public:
explicit PlainTableIterator(PlainTableReader* table, bool use_prefix_seek);
~PlainTableIterator();
~PlainTableIterator() override;
bool Valid() const override;

View File

@ -65,17 +65,17 @@ namespace {
// DummyPropertiesCollector used to test BlockBasedTableProperties
class DummyPropertiesCollector : public TablePropertiesCollector {
public:
const char* Name() const { return ""; }
const char* Name() const override { return ""; }
Status Finish(UserCollectedProperties* /*properties*/) {
Status Finish(UserCollectedProperties* /*properties*/) override {
return Status::OK();
}
Status Add(const Slice& /*user_key*/, const Slice& /*value*/) {
Status Add(const Slice& /*user_key*/, const Slice& /*value*/) override {
return Status::OK();
}
virtual UserCollectedProperties GetReadableProperties() const {
UserCollectedProperties GetReadableProperties() const override {
return UserCollectedProperties{};
}
};
@ -83,21 +83,21 @@ class DummyPropertiesCollector : public TablePropertiesCollector {
class DummyPropertiesCollectorFactory1
: public TablePropertiesCollectorFactory {
public:
virtual TablePropertiesCollector* CreateTablePropertiesCollector(
TablePropertiesCollectorFactory::Context /*context*/) {
TablePropertiesCollector* CreateTablePropertiesCollector(
TablePropertiesCollectorFactory::Context /*context*/) override {
return new DummyPropertiesCollector();
}
const char* Name() const { return "DummyPropertiesCollector1"; }
const char* Name() const override { return "DummyPropertiesCollector1"; }
};
class DummyPropertiesCollectorFactory2
: public TablePropertiesCollectorFactory {
public:
virtual TablePropertiesCollector* CreateTablePropertiesCollector(
TablePropertiesCollectorFactory::Context /*context*/) {
TablePropertiesCollector* CreateTablePropertiesCollector(
TablePropertiesCollectorFactory::Context /*context*/) override {
return new DummyPropertiesCollector();
}
const char* Name() const { return "DummyPropertiesCollector2"; }
const char* Name() const override { return "DummyPropertiesCollector2"; }
};
// Return reverse of "key".
@ -110,15 +110,15 @@ std::string Reverse(const Slice& key) {
class ReverseKeyComparator : public Comparator {
public:
virtual const char* Name() const override {
const char* Name() const override {
return "rocksdb.ReverseBytewiseComparator";
}
virtual int Compare(const Slice& a, const Slice& b) const override {
int Compare(const Slice& a, const Slice& b) const override {
return BytewiseComparator()->Compare(Reverse(a), Reverse(b));
}
virtual void FindShortestSeparator(std::string* start,
void FindShortestSeparator(std::string* start,
const Slice& limit) const override {
std::string s = Reverse(*start);
std::string l = Reverse(limit);
@ -126,7 +126,7 @@ class ReverseKeyComparator : public Comparator {
*start = Reverse(s);
}
virtual void FindShortSuccessor(std::string* key) const override {
void FindShortSuccessor(std::string* key) const override {
std::string s = Reverse(*key);
BytewiseComparator()->FindShortSuccessor(&s);
*key = Reverse(s);
@ -212,11 +212,9 @@ class BlockConstructor: public Constructor {
: Constructor(cmp),
comparator_(cmp),
block_(nullptr) { }
~BlockConstructor() {
delete block_;
}
virtual Status FinishImpl(
const Options& /*options*/, const ImmutableCFOptions& /*ioptions*/,
~BlockConstructor() override { delete block_; }
Status FinishImpl(const Options& /*options*/,
const ImmutableCFOptions& /*ioptions*/,
const MutableCFOptions& /*moptions*/,
const BlockBasedTableOptions& table_options,
const InternalKeyComparator& /*internal_comparator*/,
@ -235,7 +233,7 @@ class BlockConstructor: public Constructor {
block_ = new Block(std::move(contents), kDisableGlobalSequenceNumber);
return Status::OK();
}
virtual InternalIterator* NewIterator(
InternalIterator* NewIterator(
const SliceTransform* /*prefix_extractor*/) const override {
return block_->NewIterator<DataBlockIter>(comparator_, comparator_);
}
@ -254,32 +252,32 @@ class KeyConvertingIterator : public InternalIterator {
explicit KeyConvertingIterator(InternalIterator* iter,
bool arena_mode = false)
: iter_(iter), arena_mode_(arena_mode) {}
virtual ~KeyConvertingIterator() {
~KeyConvertingIterator() override {
if (arena_mode_) {
iter_->~InternalIterator();
} else {
delete iter_;
}
}
virtual bool Valid() const override { return iter_->Valid() && status_.ok(); }
virtual void Seek(const Slice& target) override {
bool Valid() const override { return iter_->Valid() && status_.ok(); }
void Seek(const Slice& target) override {
ParsedInternalKey ikey(target, kMaxSequenceNumber, kTypeValue);
std::string encoded;
AppendInternalKey(&encoded, ikey);
iter_->Seek(encoded);
}
virtual void SeekForPrev(const Slice& target) override {
void SeekForPrev(const Slice& target) override {
ParsedInternalKey ikey(target, kMaxSequenceNumber, kTypeValue);
std::string encoded;
AppendInternalKey(&encoded, ikey);
iter_->SeekForPrev(encoded);
}
virtual void SeekToFirst() override { iter_->SeekToFirst(); }
virtual void SeekToLast() override { iter_->SeekToLast(); }
virtual void Next() override { iter_->Next(); }
virtual void Prev() override { iter_->Prev(); }
void SeekToFirst() override { iter_->SeekToFirst(); }
void SeekToLast() override { iter_->SeekToLast(); }
void Next() override { iter_->Next(); }
void Prev() override { iter_->Prev(); }
virtual Slice key() const override {
Slice key() const override {
assert(Valid());
ParsedInternalKey parsed_key;
if (!ParseInternalKey(iter_->key(), &parsed_key)) {
@ -289,8 +287,8 @@ class KeyConvertingIterator : public InternalIterator {
return parsed_key.user_key;
}
virtual Slice value() const override { return iter_->value(); }
virtual Status status() const override {
Slice value() const override { return iter_->value(); }
Status status() const override {
return status_.ok() ? iter_->status() : status_;
}
@ -312,10 +310,9 @@ class TableConstructor: public Constructor {
: Constructor(cmp),
convert_to_internal_key_(convert_to_internal_key),
level_(level) {}
~TableConstructor() { Reset(); }
~TableConstructor() override { Reset(); }
virtual Status FinishImpl(const Options& options,
const ImmutableCFOptions& ioptions,
Status FinishImpl(const Options& options, const ImmutableCFOptions& ioptions,
const MutableCFOptions& moptions,
const BlockBasedTableOptions& /*table_options*/,
const InternalKeyComparator& internal_comparator,
@ -368,7 +365,7 @@ class TableConstructor: public Constructor {
&table_reader_);
}
virtual InternalIterator* NewIterator(
InternalIterator* NewIterator(
const SliceTransform* prefix_extractor) const override {
ReadOptions ro;
InternalIterator* iter = table_reader_->NewIterator(ro, prefix_extractor);
@ -401,7 +398,7 @@ class TableConstructor: public Constructor {
virtual TableReader* GetTableReader() { return table_reader_.get(); }
virtual bool AnywayDeleteIterator() const override {
bool AnywayDeleteIterator() const override {
return convert_to_internal_key_;
}
@ -449,11 +446,8 @@ class MemTableConstructor: public Constructor {
wb, kMaxSequenceNumber, 0 /* column_family_id */);
memtable_->Ref();
}
~MemTableConstructor() {
delete memtable_->Unref();
}
virtual Status FinishImpl(
const Options&, const ImmutableCFOptions& ioptions,
~MemTableConstructor() override { delete memtable_->Unref(); }
Status FinishImpl(const Options&, const ImmutableCFOptions& ioptions,
const MutableCFOptions& /*moptions*/,
const BlockBasedTableOptions& /*table_options*/,
const InternalKeyComparator& /*internal_comparator*/,
@ -471,15 +465,15 @@ class MemTableConstructor: public Constructor {
}
return Status::OK();
}
virtual InternalIterator* NewIterator(
InternalIterator* NewIterator(
const SliceTransform* /*prefix_extractor*/) const override {
return new KeyConvertingIterator(
memtable_->NewIterator(ReadOptions(), &arena_), true);
}
virtual bool AnywayDeleteIterator() const override { return true; }
bool AnywayDeleteIterator() const override { return true; }
virtual bool IsArenaMode() const override { return true; }
bool IsArenaMode() const override { return true; }
private:
mutable Arena arena_;
@ -493,18 +487,16 @@ class MemTableConstructor: public Constructor {
class InternalIteratorFromIterator : public InternalIterator {
public:
explicit InternalIteratorFromIterator(Iterator* it) : it_(it) {}
virtual bool Valid() const override { return it_->Valid(); }
virtual void Seek(const Slice& target) override { it_->Seek(target); }
virtual void SeekForPrev(const Slice& target) override {
it_->SeekForPrev(target);
}
virtual void SeekToFirst() override { it_->SeekToFirst(); }
virtual void SeekToLast() override { it_->SeekToLast(); }
virtual void Next() override { it_->Next(); }
virtual void Prev() override { it_->Prev(); }
bool Valid() const override { return it_->Valid(); }
void Seek(const Slice& target) override { it_->Seek(target); }
void SeekForPrev(const Slice& target) override { it_->SeekForPrev(target); }
void SeekToFirst() override { it_->SeekToFirst(); }
void SeekToLast() override { it_->SeekToLast(); }
void Next() override { it_->Next(); }
void Prev() override { it_->Prev(); }
Slice key() const override { return it_->key(); }
Slice value() const override { return it_->value(); }
virtual Status status() const override { return it_->status(); }
Status status() const override { return it_->status(); }
private:
std::unique_ptr<Iterator> it_;
@ -518,11 +510,9 @@ class DBConstructor: public Constructor {
db_ = nullptr;
NewDB();
}
~DBConstructor() {
delete db_;
}
virtual Status FinishImpl(
const Options& /*options*/, const ImmutableCFOptions& /*ioptions*/,
~DBConstructor() override { delete db_; }
Status FinishImpl(const Options& /*options*/,
const ImmutableCFOptions& /*ioptions*/,
const MutableCFOptions& /*moptions*/,
const BlockBasedTableOptions& /*table_options*/,
const InternalKeyComparator& /*internal_comparator*/,
@ -538,12 +528,12 @@ class DBConstructor: public Constructor {
return Status::OK();
}
virtual InternalIterator* NewIterator(
InternalIterator* NewIterator(
const SliceTransform* /*prefix_extractor*/) const override {
return new InternalIteratorFromIterator(db_->NewIterator(ReadOptions()));
}
virtual DB* db() const override { return db_; }
DB* db() const override { return db_; }
private:
void NewDB() {
@ -679,9 +669,9 @@ class FixedOrLessPrefixTransform : public SliceTransform {
prefix_len_(prefix_len) {
}
virtual const char* Name() const override { return "rocksdb.FixedPrefix"; }
const char* Name() const override { return "rocksdb.FixedPrefix"; }
virtual Slice Transform(const Slice& src) const override {
Slice Transform(const Slice& src) const override {
assert(InDomain(src));
if (src.size() < prefix_len_) {
return src;
@ -689,14 +679,12 @@ class FixedOrLessPrefixTransform : public SliceTransform {
return Slice(src.data(), prefix_len_);
}
virtual bool InDomain(const Slice& /*src*/) const override { return true; }
bool InDomain(const Slice& /*src*/) const override { return true; }
virtual bool InRange(const Slice& dst) const override {
bool InRange(const Slice& dst) const override {
return (dst.size() <= prefix_len_);
}
virtual bool FullLengthEnabled(size_t* /*len*/) const override {
return false;
}
bool FullLengthEnabled(size_t* /*len*/) const override { return false; }
};
class HarnessTest : public testing::Test {
@ -805,7 +793,7 @@ class HarnessTest : public testing::Test {
moptions_ = MutableCFOptions(options_);
}
~HarnessTest() { delete constructor_; }
~HarnessTest() override { delete constructor_; }
void Add(const std::string& key, const std::string& value) {
constructor_->Add(key, value);
@ -2287,7 +2275,7 @@ class MockCache : public LRUCache {
double high_pri_pool_ratio)
: LRUCache(capacity, num_shard_bits, strict_capacity_limit,
high_pri_pool_ratio) {}
virtual Status Insert(const Slice& key, void* value, size_t charge,
Status Insert(const Slice& key, void* value, size_t charge,
void (*deleter)(const Slice& key, void* value),
Handle** handle = nullptr,
Priority priority = Priority::LOW) override {
@ -2298,8 +2286,7 @@ class MockCache : public LRUCache {
priority);
}
// This is called by the application right after inserting a data block
virtual void TEST_mark_as_data_block(const Slice& key,
size_t charge) override {
void TEST_mark_as_data_block(const Slice& key, size_t charge) override {
marked_data_in_cache_[key.ToString()] = charge;
marked_size_ += charge;
}
@ -2487,7 +2474,7 @@ TEST_P(BlockBasedTableTest, BlockCacheLeak) {
namespace {
class CustomMemoryAllocator : public MemoryAllocator {
public:
virtual const char* Name() const override { return "CustomMemoryAllocator"; }
const char* Name() const override { return "CustomMemoryAllocator"; }
void* Allocate(size_t size) override {
++numAllocations;
@ -3165,7 +3152,7 @@ TEST_P(IndexBlockRestartIntervalTest, IndexBlockRestartInterval) {
class PrefixTest : public testing::Test {
public:
PrefixTest() : testing::Test() {}
~PrefixTest() {}
~PrefixTest() override {}
};
namespace {

View File

@ -25,29 +25,29 @@ class TwoLevelIndexIterator : public InternalIteratorBase<BlockHandle> {
TwoLevelIteratorState* state,
InternalIteratorBase<BlockHandle>* first_level_iter);
virtual ~TwoLevelIndexIterator() {
~TwoLevelIndexIterator() override {
first_level_iter_.DeleteIter(false /* is_arena_mode */);
second_level_iter_.DeleteIter(false /* is_arena_mode */);
delete state_;
}
virtual void Seek(const Slice& target) override;
virtual void SeekForPrev(const Slice& target) override;
virtual void SeekToFirst() override;
virtual void SeekToLast() override;
virtual void Next() override;
virtual void Prev() override;
void Seek(const Slice& target) override;
void SeekForPrev(const Slice& target) override;
void SeekToFirst() override;
void SeekToLast() override;
void Next() override;
void Prev() override;
virtual bool Valid() const override { return second_level_iter_.Valid(); }
virtual Slice key() const override {
bool Valid() const override { return second_level_iter_.Valid(); }
Slice key() const override {
assert(Valid());
return second_level_iter_.key();
}
virtual BlockHandle value() const override {
BlockHandle value() const override {
assert(Valid());
return second_level_iter_.value();
}
virtual Status status() const override {
Status status() const override {
if (!first_level_iter_.status().ok()) {
assert(second_level_iter_.iter() == nullptr);
return first_level_iter_.status();
@ -58,10 +58,10 @@ class TwoLevelIndexIterator : public InternalIteratorBase<BlockHandle> {
return status_;
}
}
virtual void SetPinnedItersMgr(
void SetPinnedItersMgr(
PinnedIteratorsManager* /*pinned_iters_mgr*/) override {}
virtual bool IsKeyPinned() const override { return false; }
virtual bool IsValuePinned() const override { return false; }
bool IsKeyPinned() const override { return false; }
bool IsValuePinned() const override { return false; }
private:
void SaveError(const Status& s) {

View File

@ -1205,7 +1205,7 @@ class ReportFileOpEnv : public EnvWrapper {
ReportFileOpCounters* counters)
: target_(std::move(target)), counters_(counters) {}
virtual Status Read(size_t n, Slice* result, char* scratch) override {
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(),
@ -1213,7 +1213,7 @@ class ReportFileOpEnv : public EnvWrapper {
return rv;
}
virtual Status Skip(uint64_t n) override { return target_->Skip(n); }
Status Skip(uint64_t n) override { return target_->Skip(n); }
};
Status s = target()->NewSequentialFile(f, r, soptions);
@ -1236,7 +1236,7 @@ class ReportFileOpEnv : public EnvWrapper {
CountingFile(unique_ptr<RandomAccessFile>&& target,
ReportFileOpCounters* counters)
: target_(std::move(target)), counters_(counters) {}
virtual Status Read(uint64_t offset, size_t n, Slice* result,
Status Read(uint64_t offset, size_t n, Slice* result,
char* scratch) const override {
counters_->read_counter_.fetch_add(1, std::memory_order_relaxed);
Status rv = target_->Read(offset, n, result, scratch);
@ -2050,16 +2050,17 @@ class Benchmark {
no_auto_recovery_(false),
recovery_complete_(false) {}
~ErrorHandlerListener() {}
~ErrorHandlerListener() override {}
void OnErrorRecoveryBegin(BackgroundErrorReason /*reason*/,
Status /*bg_error*/, bool* auto_recovery) {
Status /*bg_error*/,
bool* auto_recovery) override {
if (*auto_recovery && no_auto_recovery_) {
*auto_recovery = false;
}
}
void OnErrorRecoveryCompleted(Status /*old_bg_error*/) {
void OnErrorRecoveryCompleted(Status /*old_bg_error*/) override {
InstrumentedMutexLock l(&mutex_);
recovery_complete_ = true;
cv_.SignalAll();
@ -2310,13 +2311,13 @@ class Benchmark {
class KeepFilter : public CompactionFilter {
public:
virtual bool Filter(int /*level*/, const Slice& /*key*/,
const Slice& /*value*/, std::string* /*new_value*/,
bool Filter(int /*level*/, const Slice& /*key*/, const Slice& /*value*/,
std::string* /*new_value*/,
bool* /*value_changed*/) const override {
return false;
}
virtual const char* Name() const override { return "KeepFilter"; }
const char* Name() const override { return "KeepFilter"; }
};
std::shared_ptr<Cache> NewCache(int64_t capacity) {

View File

@ -1869,7 +1869,7 @@ void ChangeCompactionStyleCommand::DoCommand() {
namespace {
struct StdErrReporter : public log::Reader::Reporter {
virtual void Corruption(size_t /*bytes*/, const Status& s) override {
void Corruption(size_t /*bytes*/, const Status& s) override {
std::cerr << "Corruption detected in log file " << s.ToString() << "\n";
}
};
@ -1894,39 +1894,36 @@ class InMemoryHandler : public WriteBatch::Handler {
}
}
virtual Status PutCF(uint32_t cf, const Slice& key,
const Slice& value) override {
Status PutCF(uint32_t cf, const Slice& key, const Slice& value) override {
row_ << "PUT(" << cf << ") : ";
commonPutMerge(key, value);
return Status::OK();
}
virtual Status MergeCF(uint32_t cf, const Slice& key,
const Slice& value) override {
Status MergeCF(uint32_t cf, const Slice& key, const Slice& value) override {
row_ << "MERGE(" << cf << ") : ";
commonPutMerge(key, value);
return Status::OK();
}
virtual Status MarkNoop(bool)
override {
Status MarkNoop(bool) override {
row_ << "NOOP ";
return Status::OK();
}
virtual Status DeleteCF(uint32_t cf, const Slice& key) override {
Status DeleteCF(uint32_t cf, const Slice& key) override {
row_ << "DELETE(" << cf << ") : ";
row_ << LDBCommand::StringToHex(key.ToString()) << " ";
return Status::OK();
}
virtual Status SingleDeleteCF(uint32_t cf, const Slice& key) override {
Status SingleDeleteCF(uint32_t cf, const Slice& key) override {
row_ << "SINGLE_DELETE(" << cf << ") : ";
row_ << LDBCommand::StringToHex(key.ToString()) << " ";
return Status::OK();
}
virtual Status DeleteRangeCF(uint32_t cf, const Slice& begin_key,
Status DeleteRangeCF(uint32_t cf, const Slice& begin_key,
const Slice& end_key) override {
row_ << "DELETE_RANGE(" << cf << ") : ";
row_ << LDBCommand::StringToHex(begin_key.ToString()) << " ";
@ -1934,34 +1931,34 @@ class InMemoryHandler : public WriteBatch::Handler {
return Status::OK();
}
virtual Status MarkBeginPrepare(bool unprepare) override {
Status MarkBeginPrepare(bool unprepare) override {
row_ << "BEGIN_PREPARE(";
row_ << (unprepare ? "true" : "false") << ") ";
return Status::OK();
}
virtual Status MarkEndPrepare(const Slice& xid) override {
Status MarkEndPrepare(const Slice& xid) override {
row_ << "END_PREPARE(";
row_ << LDBCommand::StringToHex(xid.ToString()) << ") ";
return Status::OK();
}
virtual Status MarkRollback(const Slice& xid) override {
Status MarkRollback(const Slice& xid) override {
row_ << "ROLLBACK(";
row_ << LDBCommand::StringToHex(xid.ToString()) << ") ";
return Status::OK();
}
virtual Status MarkCommit(const Slice& xid) override {
Status MarkCommit(const Slice& xid) override {
row_ << "COMMIT(";
row_ << LDBCommand::StringToHex(xid.ToString()) << ") ";
return Status::OK();
}
virtual ~InMemoryHandler() {}
~InMemoryHandler() override {}
protected:
virtual bool WriteAfterCommit() const override { return write_after_commit_; }
bool WriteAfterCommit() const override { return write_after_commit_; }
private:
std::stringstream& row_;

View File

@ -89,7 +89,7 @@ class SSTDumpToolTest : public testing::Test {
public:
SSTDumpToolTest() { testDir_ = test::TmpDir(); }
~SSTDumpToolTest() {}
~SSTDumpToolTest() override {}
std::string MakeFilePath(const std::string& file_name) const {
std::string path(testDir_);

View File

@ -50,7 +50,7 @@ class TraceAnalyzerTest : public testing::Test {
dbname_ = test_path_ + "/db";
}
~TraceAnalyzerTest() {}
~TraceAnalyzerTest() override {}
void GenerateTrace(std::string trace_path) {
Options options;

View File

@ -28,13 +28,13 @@ namespace {
class NoSleepEnv : public EnvWrapper {
public:
NoSleepEnv(Env* base) : EnvWrapper(base) {}
virtual void SleepForMicroseconds(int micros) override {
void SleepForMicroseconds(int micros) override {
fake_time_ += static_cast<uint64_t>(micros);
}
virtual uint64_t NowNanos() override { return fake_time_ * 1000; }
uint64_t NowNanos() override { return fake_time_ * 1000; }
virtual uint64_t NowMicros() override { return fake_time_; }
uint64_t NowMicros() override { return fake_time_; }
private:
uint64_t fake_time_ = 6666666666;

View File

@ -172,9 +172,9 @@ class FullFilterBitsReader : public FilterBitsReader {
}
}
~FullFilterBitsReader() {}
~FullFilterBitsReader() override {}
virtual bool MayMatch(const Slice& entry) override {
bool MayMatch(const Slice& entry) override {
if (data_len_ <= 5) { // remain same with original filter
return false;
}
@ -274,15 +274,11 @@ class BloomFilterPolicy : public FilterPolicy {
initialize();
}
~BloomFilterPolicy() {
}
~BloomFilterPolicy() override {}
virtual const char* Name() const override {
return "rocksdb.BuiltinBloomFilter";
}
const char* Name() const override { return "rocksdb.BuiltinBloomFilter"; }
virtual void CreateFilter(const Slice* keys, int n,
std::string* dst) const override {
void CreateFilter(const Slice* keys, int n, std::string* dst) const override {
// Compute bloom filter size (in both bits and bytes)
size_t bits = n * bits_per_key_;
@ -310,8 +306,7 @@ class BloomFilterPolicy : public FilterPolicy {
}
}
virtual bool KeyMayMatch(const Slice& key,
const Slice& bloom_filter) const override {
bool KeyMayMatch(const Slice& key, const Slice& bloom_filter) const override {
const size_t len = bloom_filter.size();
if (len < 2) return false;
@ -337,7 +332,7 @@ class BloomFilterPolicy : public FilterPolicy {
return true;
}
virtual FilterBitsBuilder* GetFilterBitsBuilder() const override {
FilterBitsBuilder* GetFilterBitsBuilder() const override {
if (use_block_based_builder_) {
return nullptr;
}
@ -345,8 +340,7 @@ class BloomFilterPolicy : public FilterPolicy {
return new FullFilterBitsBuilder(bits_per_key_, num_probes_);
}
virtual FilterBitsReader* GetFilterBitsReader(const Slice& contents)
const override {
FilterBitsReader* GetFilterBitsReader(const Slice& contents) const override {
return new FullFilterBitsReader(contents);
}

View File

@ -63,9 +63,7 @@ class BloomTest : public testing::Test {
BloomTest() : policy_(
NewBloomFilterPolicy(FLAGS_bits_per_key)) {}
~BloomTest() {
delete policy_;
}
~BloomTest() override { delete policy_; }
void Reset() {
keys_.clear();
@ -192,9 +190,7 @@ class FullBloomTest : public testing::Test {
Reset();
}
~FullBloomTest() {
delete policy_;
}
~FullBloomTest() override { delete policy_; }
FullFilterBitsBuilder* GetFullFilterBitsBuilder() {
return dynamic_cast<FullFilterBitsBuilder*>(bits_builder_.get());

View File

@ -22,19 +22,15 @@ class BytewiseComparatorImpl : public Comparator {
public:
BytewiseComparatorImpl() { }
virtual const char* Name() const override {
return "leveldb.BytewiseComparator";
}
const char* Name() const override { return "leveldb.BytewiseComparator"; }
virtual int Compare(const Slice& a, const Slice& b) const override {
int Compare(const Slice& a, const Slice& b) const override {
return a.compare(b);
}
virtual bool Equal(const Slice& a, const Slice& b) const override {
return a == b;
}
bool Equal(const Slice& a, const Slice& b) const override { return a == b; }
virtual void FindShortestSeparator(std::string* start,
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());
@ -85,7 +81,7 @@ class BytewiseComparatorImpl : public Comparator {
}
}
virtual void FindShortSuccessor(std::string* key) const override {
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++) {
@ -99,7 +95,7 @@ class BytewiseComparatorImpl : public Comparator {
// *key is a run of 0xffs. Leave it alone.
}
virtual bool IsSameLengthImmediateSuccessor(const Slice& s,
bool IsSameLengthImmediateSuccessor(const Slice& s,
const Slice& t) const override {
if (s.size() != t.size() || s.size() == 0) {
return false;
@ -125,7 +121,7 @@ class BytewiseComparatorImpl : public Comparator {
}
}
virtual bool CanKeysWithDifferentByteContentsBeEqual() const override {
bool CanKeysWithDifferentByteContentsBeEqual() const override {
return false;
}
};
@ -134,11 +130,11 @@ class ReverseBytewiseComparatorImpl : public BytewiseComparatorImpl {
public:
ReverseBytewiseComparatorImpl() { }
virtual const char* Name() const override {
const char* Name() const override {
return "rocksdb.ReverseBytewiseComparator";
}
virtual int Compare(const Slice& a, const Slice& b) const override {
int Compare(const Slice& a, const Slice& b) const override {
return -a.compare(b);
}
@ -193,7 +189,7 @@ class ReverseBytewiseComparatorImpl : public BytewiseComparatorImpl {
// Don't do anything for simplicity.
}
virtual bool CanKeysWithDifferentByteContentsBeEqual() const override {
bool CanKeysWithDifferentByteContentsBeEqual() const override {
return false;
}
};

View File

@ -38,7 +38,7 @@ class DeleteSchedulerTest : public testing::Test {
}
}
~DeleteSchedulerTest() {
~DeleteSchedulerTest() override {
rocksdb::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->LoadDependency({});
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks();

View File

@ -15,7 +15,7 @@ class EventLoggerTest : public testing::Test {};
class StringLogger : public Logger {
public:
using Logger::Logv;
virtual void Logv(const char* format, va_list ap) override {
void Logv(const char* format, va_list ap) override {
vsnprintf(buffer_, sizeof(buffer_), format, ap);
}
char* buffer() { return buffer_; }

View File

@ -595,9 +595,8 @@ class ReadaheadRandomAccessFile : public RandomAccessFile {
ReadaheadRandomAccessFile& operator=(const ReadaheadRandomAccessFile&) = delete;
virtual Status Read(uint64_t offset, size_t n, Slice* result,
Status Read(uint64_t offset, size_t n, Slice* result,
char* scratch) const override {
if (n + alignment_ >= readahead_size_) {
return file_->Read(offset, n, result, scratch);
}
@ -643,7 +642,7 @@ class ReadaheadRandomAccessFile : public RandomAccessFile {
return s;
}
virtual Status Prefetch(uint64_t offset, size_t n) override {
Status Prefetch(uint64_t offset, size_t n) override {
if (n < readahead_size_) {
// Don't allow smaller prefetches than the configured `readahead_size_`.
// `Read()` assumes a smaller prefetch buffer indicates EOF was reached.
@ -658,21 +657,19 @@ class ReadaheadRandomAccessFile : public RandomAccessFile {
Roundup(offset_ + n, alignment_) - prefetch_offset);
}
virtual size_t GetUniqueId(char* id, size_t max_size) const override {
size_t GetUniqueId(char* id, size_t max_size) const override {
return file_->GetUniqueId(id, max_size);
}
virtual void Hint(AccessPattern pattern) override { file_->Hint(pattern); }
void Hint(AccessPattern pattern) override { file_->Hint(pattern); }
virtual Status InvalidateCache(size_t offset, size_t length) override {
Status InvalidateCache(size_t offset, size_t length) override {
return file_->InvalidateCache(offset, length);
}
virtual bool use_direct_io() const override {
return file_->use_direct_io();
}
bool use_direct_io() const override { return file_->use_direct_io(); }
private:
private:
bool TryReadFromCache(uint64_t offset, size_t n, size_t* cached_len,
char* scratch) const {
if (offset < buffer_offset_ ||

View File

@ -20,13 +20,13 @@ TEST_F(WritableFileWriterTest, RangeSync) {
class FakeWF : public WritableFile {
public:
explicit FakeWF() : size_(0), last_synced_(0) {}
~FakeWF() {}
~FakeWF() override {}
Status Append(const Slice& data) override {
size_ += data.size();
return Status::OK();
}
virtual Status Truncate(uint64_t /*size*/) override { return Status::OK(); }
Status Truncate(uint64_t /*size*/) override { return Status::OK(); }
Status Close() override {
EXPECT_GE(size_, last_synced_ + kMb);
EXPECT_LT(size_, last_synced_ + 2 * kMb);
@ -97,7 +97,7 @@ TEST_F(WritableFileWriterTest, IncrementalBuffer) {
: file_data_(_file_data),
use_direct_io_(_use_direct_io),
no_flush_(_no_flush) {}
~FakeWF() {}
~FakeWF() override {}
Status Append(const Slice& data) override {
file_data_->append(data.data(), data.size());
@ -113,7 +113,7 @@ TEST_F(WritableFileWriterTest, IncrementalBuffer) {
return Status::OK();
}
virtual Status Truncate(uint64_t size) override {
Status Truncate(uint64_t size) override {
file_data_->resize(size);
return Status::OK();
}
@ -183,7 +183,7 @@ TEST_F(WritableFileWriterTest, AppendStatusReturn) {
public:
explicit FakeWF() : use_direct_io_(false), io_error_(false) {}
virtual bool use_direct_io() const override { return use_direct_io_; }
bool use_direct_io() const override { return use_direct_io_; }
Status Append(const Slice& /*data*/) override {
if (io_error_) {
return Status::IOError("Fake IO error");
@ -226,7 +226,7 @@ class ReadaheadRandomAccessFileTest
static std::vector<size_t> GetReadaheadSizeList() {
return {1lu << 12, 1lu << 16};
}
virtual void SetUp() override {
void SetUp() override {
readahead_size_ = GetParam();
scratch_.reset(new char[2 * readahead_size_]);
ResetSourceStr();

View File

@ -25,8 +25,7 @@ class LockTest : public testing::Test {
current_ = this;
}
~LockTest() {
}
~LockTest() override {}
Status LockFile(FileLock** db_lock) {
return env_->LockFile(file_, db_lock);

View File

@ -32,27 +32,27 @@ class FixedPrefixTransform : public SliceTransform {
// the class implementation itself.
name_("rocksdb.FixedPrefix." + ToString(prefix_len_)) {}
virtual const char* Name() const override { return name_.c_str(); }
const char* Name() const override { return name_.c_str(); }
virtual Slice Transform(const Slice& src) const override {
Slice Transform(const Slice& src) const override {
assert(InDomain(src));
return Slice(src.data(), prefix_len_);
}
virtual bool InDomain(const Slice& src) const override {
bool InDomain(const Slice& src) const override {
return (src.size() >= prefix_len_);
}
virtual bool InRange(const Slice& dst) const override {
bool InRange(const Slice& dst) const override {
return (dst.size() == prefix_len_);
}
virtual bool FullLengthEnabled(size_t* len) const override {
bool FullLengthEnabled(size_t* len) const override {
*len = prefix_len_;
return true;
}
virtual bool SameResultWhenAppended(const Slice& prefix) const override {
bool SameResultWhenAppended(const Slice& prefix) const override {
return InDomain(prefix);
}
};
@ -72,25 +72,25 @@ class CappedPrefixTransform : public SliceTransform {
// the class implementation itself.
name_("rocksdb.CappedPrefix." + ToString(cap_len_)) {}
virtual const char* Name() const override { return name_.c_str(); }
const char* Name() const override { return name_.c_str(); }
virtual Slice Transform(const Slice& src) const override {
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 override { return true; }
bool InDomain(const Slice& /*src*/) const override { return true; }
virtual bool InRange(const Slice& dst) const override {
bool InRange(const Slice& dst) const override {
return (dst.size() <= cap_len_);
}
virtual bool FullLengthEnabled(size_t* len) const override {
bool FullLengthEnabled(size_t* len) const override {
*len = cap_len_;
return true;
}
virtual bool SameResultWhenAppended(const Slice& prefix) const override {
bool SameResultWhenAppended(const Slice& prefix) const override {
return prefix.size() >= cap_len_;
}
};
@ -99,15 +99,15 @@ class NoopTransform : public SliceTransform {
public:
explicit NoopTransform() { }
virtual const char* Name() const override { return "rocksdb.Noop"; }
const char* Name() const override { return "rocksdb.Noop"; }
virtual Slice Transform(const Slice& src) const override { return src; }
Slice Transform(const Slice& src) const override { return src; }
virtual bool InDomain(const Slice& /*src*/) const override { return true; }
bool InDomain(const Slice& /*src*/) const override { return true; }
virtual bool InRange(const Slice& /*dst*/) const override { return true; }
bool InRange(const Slice& /*dst*/) const override { return true; }
virtual bool SameResultWhenAppended(const Slice& /*prefix*/) const override {
bool SameResultWhenAppended(const Slice& /*prefix*/) const override {
return false;
}
};

View File

@ -57,7 +57,7 @@ class SliceTransformDBTest : public testing::Test {
EXPECT_OK(DestroyDB(dbname_, last_options_));
}
~SliceTransformDBTest() {
~SliceTransformDBTest() override {
delete db_;
EXPECT_OK(DestroyDB(dbname_, last_options_));
}

View File

@ -87,11 +87,9 @@ class Uint64ComparatorImpl : public Comparator {
public:
Uint64ComparatorImpl() {}
virtual const char* Name() const override {
return "rocksdb.Uint64Comparator";
}
const char* Name() const override { return "rocksdb.Uint64Comparator"; }
virtual int Compare(const Slice& a, const Slice& b) const override {
int Compare(const Slice& a, const Slice& b) const override {
assert(a.size() == sizeof(uint64_t) && b.size() == sizeof(uint64_t));
const uint64_t* left = reinterpret_cast<const uint64_t*>(a.data());
const uint64_t* right = reinterpret_cast<const uint64_t*>(b.data());
@ -108,14 +106,12 @@ class Uint64ComparatorImpl : public Comparator {
}
}
virtual void FindShortestSeparator(std::string* /*start*/,
void FindShortestSeparator(std::string* /*start*/,
const Slice& /*limit*/) const override {
return;
}
virtual void FindShortSuccessor(std::string* /*key*/) const override {
return;
}
void FindShortSuccessor(std::string* /*key*/) const override { return; }
};
} // namespace

View File

@ -92,7 +92,7 @@ class BackupEngineImpl : public BackupEngine {
public:
BackupEngineImpl(Env* db_env, const BackupableDBOptions& options,
bool read_only = false);
~BackupEngineImpl();
~BackupEngineImpl() override;
Status CreateNewBackupWithMetadata(DB* db, const std::string& app_metadata,
bool flush_before_backup = false,
std::function<void()> progress_callback =
@ -118,7 +118,7 @@ class BackupEngineImpl : public BackupEngine {
restore_options);
}
virtual Status VerifyBackup(BackupID backup_id) override;
Status VerifyBackup(BackupID backup_id) override;
Status Initialize();
@ -1853,34 +1853,33 @@ class BackupEngineReadOnlyImpl : public BackupEngineReadOnly {
BackupEngineReadOnlyImpl(Env* db_env, const BackupableDBOptions& options)
: backup_engine_(new BackupEngineImpl(db_env, options, true)) {}
virtual ~BackupEngineReadOnlyImpl() {}
~BackupEngineReadOnlyImpl() override {}
// The returned BackupInfos are in chronological order, which means the
// latest backup comes last.
virtual void GetBackupInfo(std::vector<BackupInfo>* backup_info) override {
void GetBackupInfo(std::vector<BackupInfo>* backup_info) override {
backup_engine_->GetBackupInfo(backup_info);
}
virtual void GetCorruptedBackups(
std::vector<BackupID>* corrupt_backup_ids) override {
void GetCorruptedBackups(std::vector<BackupID>* corrupt_backup_ids) override {
backup_engine_->GetCorruptedBackups(corrupt_backup_ids);
}
virtual Status RestoreDBFromBackup(
Status RestoreDBFromBackup(
BackupID backup_id, const std::string& db_dir, const std::string& wal_dir,
const RestoreOptions& restore_options = RestoreOptions()) override {
return backup_engine_->RestoreDBFromBackup(backup_id, db_dir, wal_dir,
restore_options);
}
virtual Status RestoreDBFromLatestBackup(
Status RestoreDBFromLatestBackup(
const std::string& db_dir, const std::string& wal_dir,
const RestoreOptions& restore_options = RestoreOptions()) override {
return backup_engine_->RestoreDBFromLatestBackup(db_dir, wal_dir,
restore_options);
}
virtual Status VerifyBackup(BackupID backup_id) override {
Status VerifyBackup(BackupID backup_id) override {
return backup_engine_->VerifyBackup(backup_id);
}

View File

@ -44,41 +44,34 @@ class DummyDB : public StackableDB {
: StackableDB(nullptr), options_(options), dbname_(dbname),
deletions_enabled_(true), sequence_number_(0) {}
virtual SequenceNumber GetLatestSequenceNumber() const override {
SequenceNumber GetLatestSequenceNumber() const override {
return ++sequence_number_;
}
virtual const std::string& GetName() const override {
return dbname_;
}
const std::string& GetName() const override { return dbname_; }
virtual Env* GetEnv() const override {
return options_.env;
}
Env* GetEnv() const override { return options_.env; }
using DB::GetOptions;
virtual Options GetOptions(
ColumnFamilyHandle* /*column_family*/) const override {
Options GetOptions(ColumnFamilyHandle* /*column_family*/) const override {
return options_;
}
virtual DBOptions GetDBOptions() const override {
return DBOptions(options_);
}
DBOptions GetDBOptions() const override { return DBOptions(options_); }
virtual Status EnableFileDeletions(bool /*force*/) override {
Status EnableFileDeletions(bool /*force*/) override {
EXPECT_TRUE(!deletions_enabled_);
deletions_enabled_ = true;
return Status::OK();
}
virtual Status DisableFileDeletions() override {
Status DisableFileDeletions() override {
EXPECT_TRUE(deletions_enabled_);
deletions_enabled_ = false;
return Status::OK();
}
virtual Status GetLiveFiles(std::vector<std::string>& vec, uint64_t* mfs,
Status GetLiveFiles(std::vector<std::string>& vec, uint64_t* mfs,
bool /*flush_memtable*/ = true) override {
EXPECT_TRUE(!deletions_enabled_);
vec = live_files_;
@ -86,9 +79,7 @@ class DummyDB : public StackableDB {
return Status::OK();
}
virtual ColumnFamilyHandle* DefaultColumnFamily() const override {
return nullptr;
}
ColumnFamilyHandle* DefaultColumnFamily() const override { return nullptr; }
class DummyLogFile : public LogFile {
public:
@ -96,36 +87,32 @@ class DummyDB : public StackableDB {
DummyLogFile(const std::string& path, bool alive = true)
: path_(path), alive_(alive) {}
virtual std::string PathName() const override {
return path_;
}
std::string PathName() const override { return path_; }
virtual uint64_t LogNumber() const override {
uint64_t LogNumber() const override {
// what business do you have calling this method?
ADD_FAILURE();
return 0;
}
virtual WalFileType Type() const override {
WalFileType Type() const override {
return alive_ ? kAliveLogFile : kArchivedLogFile;
}
virtual SequenceNumber StartSequence() const override {
SequenceNumber StartSequence() const override {
// this seqnum guarantees the dummy file will be included in the backup
// as long as it is alive.
return kMaxSequenceNumber;
}
virtual uint64_t SizeFileBytes() const override {
return 0;
}
uint64_t SizeFileBytes() const override { return 0; }
private:
std::string path_;
bool alive_;
}; // DummyLogFile
virtual Status GetSortedWalFiles(VectorLogPtr& files) override {
Status GetSortedWalFiles(VectorLogPtr& files) override {
EXPECT_TRUE(!deletions_enabled_);
files.resize(wal_files_.size());
for (size_t i = 0; i < files.size(); ++i) {
@ -136,7 +123,7 @@ class DummyDB : public StackableDB {
}
// To avoid FlushWAL called on stacked db which is nullptr
virtual Status FlushWAL(bool /*sync*/) override { return Status::OK(); }
Status FlushWAL(bool /*sync*/) override { return Status::OK(); }
std::vector<std::string> live_files_;
// pair<filename, alive?>
@ -156,7 +143,7 @@ class TestEnv : public EnvWrapper {
public:
explicit DummySequentialFile(bool fail_reads)
: SequentialFile(), rnd_(5), fail_reads_(fail_reads) {}
virtual Status Read(size_t n, Slice* result, char* scratch) override {
Status Read(size_t n, Slice* result, char* scratch) override {
if (fail_reads_) {
return Status::IOError();
}
@ -169,10 +156,11 @@ class TestEnv : public EnvWrapper {
return Status::OK();
}
virtual Status Skip(uint64_t n) override {
Status Skip(uint64_t n) override {
size_left = (n > size_left) ? size_left - n : 0;
return Status::OK();
}
private:
size_t size_left = 200;
Random rnd_;
@ -217,7 +205,7 @@ class TestEnv : public EnvWrapper {
return s;
}
virtual Status NewRandomAccessFile(const std::string& fname,
Status NewRandomAccessFile(const std::string& fname,
unique_ptr<RandomAccessFile>* result,
const EnvOptions& options) override {
MutexLock l(&mutex_);
@ -231,7 +219,7 @@ class TestEnv : public EnvWrapper {
return s;
}
virtual Status DeleteFile(const std::string& fname) override {
Status DeleteFile(const std::string& fname) override {
MutexLock l(&mutex_);
if (fail_delete_files_) {
return Status::IOError();
@ -241,7 +229,7 @@ class TestEnv : public EnvWrapper {
return EnvWrapper::DeleteFile(fname);
}
virtual Status DeleteDir(const std::string& dirname) override {
Status DeleteDir(const std::string& dirname) override {
MutexLock l(&mutex_);
if (fail_delete_files_) {
return Status::IOError();
@ -336,7 +324,7 @@ class TestEnv : public EnvWrapper {
}
void SetNewDirectoryFailure(bool fail) { new_directory_failure_ = fail; }
virtual Status NewDirectory(const std::string& name,
Status NewDirectory(const std::string& name,
std::unique_ptr<Directory>* result) override {
if (new_directory_failure_) {
return Status::IOError("SimulatedFailure");

View File

@ -22,23 +22,20 @@ class BlobIndexCompactionFilter : public CompactionFilter {
current_time_(current_time),
statistics_(statistics) {}
virtual ~BlobIndexCompactionFilter() {
~BlobIndexCompactionFilter() override {
RecordTick(statistics_, BLOB_DB_BLOB_INDEX_EXPIRED_COUNT, expired_count_);
RecordTick(statistics_, BLOB_DB_BLOB_INDEX_EXPIRED_SIZE, expired_size_);
RecordTick(statistics_, BLOB_DB_BLOB_INDEX_EVICTED_COUNT, evicted_count_);
RecordTick(statistics_, BLOB_DB_BLOB_INDEX_EVICTED_SIZE, evicted_size_);
}
virtual const char* Name() const override {
return "BlobIndexCompactionFilter";
}
const char* Name() const override { return "BlobIndexCompactionFilter"; }
// Filter expired blob indexes regardless of snapshots.
virtual bool IgnoreSnapshots() const override { return true; }
bool IgnoreSnapshots() const override { return true; }
virtual Decision FilterV2(int /*level*/, const Slice& key,
ValueType value_type, const Slice& value,
std::string* /*new_value*/,
Decision FilterV2(int /*level*/, const Slice& key, ValueType value_type,
const Slice& value, std::string* /*new_value*/,
std::string* /*skip_until*/) const override {
if (value_type != kBlobIndex) {
return Decision::kKeep;

View File

@ -568,7 +568,7 @@ class BlobDBImpl::BlobInserter : public WriteBatch::Handler {
WriteBatch* batch() { return &batch_; }
virtual Status PutCF(uint32_t column_family_id, const Slice& key,
Status PutCF(uint32_t column_family_id, const Slice& key,
const Slice& value) override {
if (column_family_id != default_cf_id_) {
return Status::NotSupported(
@ -579,8 +579,7 @@ class BlobDBImpl::BlobInserter : public WriteBatch::Handler {
return s;
}
virtual Status DeleteCF(uint32_t column_family_id,
const Slice& key) override {
Status DeleteCF(uint32_t column_family_id, const Slice& key) override {
if (column_family_id != default_cf_id_) {
return Status::NotSupported(
"Blob DB doesn't support non-default column family.");
@ -600,17 +599,17 @@ class BlobDBImpl::BlobInserter : public WriteBatch::Handler {
return s;
}
virtual Status SingleDeleteCF(uint32_t /*column_family_id*/,
Status SingleDeleteCF(uint32_t /*column_family_id*/,
const Slice& /*key*/) override {
return Status::NotSupported("Not supported operation in blob db.");
}
virtual Status MergeCF(uint32_t /*column_family_id*/, const Slice& /*key*/,
Status MergeCF(uint32_t /*column_family_id*/, const Slice& /*key*/,
const Slice& /*value*/) override {
return Status::NotSupported("Not supported operation in blob db.");
}
virtual void LogData(const Slice& blob) override { batch_.PutLogData(blob); }
void LogData(const Slice& blob) override { batch_.PutLogData(blob); }
};
Status BlobDBImpl::Write(const WriteOptions& options, WriteBatch* updates) {
@ -1405,7 +1404,7 @@ class BlobDBImpl::GarbageCollectionWriteCallback : public WriteCallback {
SequenceNumber upper_bound)
: cfd_(cfd), key_(key), upper_bound_(upper_bound) {}
virtual Status Callback(DB* db) override {
Status Callback(DB* db) override {
auto* db_impl = reinterpret_cast<DBImpl*>(db);
auto* sv = db_impl->GetAndRefSuperVersion(cfd_);
SequenceNumber latest_seq = 0;
@ -1432,7 +1431,7 @@ class BlobDBImpl::GarbageCollectionWriteCallback : public WriteCallback {
return s;
}
virtual bool AllowWriteBatching() override { return false; }
bool AllowWriteBatching() override { return false; }
private:
ColumnFamilyData* cfd_;

View File

@ -48,7 +48,7 @@ class BlobDBTest : public testing::Test {
assert(s.ok());
}
~BlobDBTest() {
~BlobDBTest() override {
SyncPoint::GetInstance()->ClearAllCallBacks();
Destroy();
}
@ -1234,12 +1234,12 @@ TEST_F(BlobDBTest, InlineSmallValues) {
TEST_F(BlobDBTest, CompactionFilterNotSupported) {
class TestCompactionFilter : public CompactionFilter {
virtual const char *Name() const { return "TestCompactionFilter"; }
const char *Name() const override { return "TestCompactionFilter"; }
};
class TestCompactionFilterFactory : public CompactionFilterFactory {
virtual const char *Name() const { return "TestCompactionFilterFactory"; }
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context & /*context*/) {
const char *Name() const override { return "TestCompactionFilterFactory"; }
std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context & /*context*/) override {
return std::unique_ptr<CompactionFilter>(new TestCompactionFilter());
}
};

View File

@ -99,15 +99,13 @@ public:
: purge_ttl_on_expiration_(purge_ttl_on_expiration),
gc_grace_period_in_seconds_(gc_grace_period_in_seconds) {}
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& /*context*/) override {
return std::unique_ptr<CompactionFilter>(new CassandraCompactionFilter(
purge_ttl_on_expiration_, gc_grace_period_in_seconds_));
}
virtual const char* Name() const override {
return "TestCompactionFilterFactory";
}
const char* Name() const override { return "TestCompactionFilterFactory"; }
private:
bool purge_ttl_on_expiration_;

View File

@ -66,7 +66,7 @@ class CheckpointTest : public testing::Test {
Reopen(options);
}
~CheckpointTest() {
~CheckpointTest() override {
rocksdb::SyncPoint::GetInstance()->DisableProcessing();
rocksdb::SyncPoint::GetInstance()->LoadDependency({});
rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks();

View File

@ -17,28 +17,28 @@ class TimedEnv : public EnvWrapper {
public:
explicit TimedEnv(Env* base_env) : EnvWrapper(base_env) {}
virtual Status NewSequentialFile(const std::string& fname,
Status NewSequentialFile(const std::string& fname,
std::unique_ptr<SequentialFile>* result,
const EnvOptions& options) override {
PERF_TIMER_GUARD(env_new_sequential_file_nanos);
return EnvWrapper::NewSequentialFile(fname, result, options);
}
virtual Status NewRandomAccessFile(const std::string& fname,
Status NewRandomAccessFile(const std::string& fname,
std::unique_ptr<RandomAccessFile>* result,
const EnvOptions& options) override {
PERF_TIMER_GUARD(env_new_random_access_file_nanos);
return EnvWrapper::NewRandomAccessFile(fname, result, options);
}
virtual Status NewWritableFile(const std::string& fname,
Status NewWritableFile(const std::string& fname,
std::unique_ptr<WritableFile>* result,
const EnvOptions& options) override {
PERF_TIMER_GUARD(env_new_writable_file_nanos);
return EnvWrapper::NewWritableFile(fname, result, options);
}
virtual Status ReuseWritableFile(const std::string& fname,
Status ReuseWritableFile(const std::string& fname,
const std::string& old_fname,
std::unique_ptr<WritableFile>* result,
const EnvOptions& options) override {
@ -46,91 +46,88 @@ class TimedEnv : public EnvWrapper {
return EnvWrapper::ReuseWritableFile(fname, old_fname, result, options);
}
virtual Status NewRandomRWFile(const std::string& fname,
Status NewRandomRWFile(const std::string& fname,
std::unique_ptr<RandomRWFile>* result,
const EnvOptions& options) override {
PERF_TIMER_GUARD(env_new_random_rw_file_nanos);
return EnvWrapper::NewRandomRWFile(fname, result, options);
}
virtual Status NewDirectory(const std::string& name,
Status NewDirectory(const std::string& name,
std::unique_ptr<Directory>* result) override {
PERF_TIMER_GUARD(env_new_directory_nanos);
return EnvWrapper::NewDirectory(name, result);
}
virtual Status FileExists(const std::string& fname) override {
Status FileExists(const std::string& fname) override {
PERF_TIMER_GUARD(env_file_exists_nanos);
return EnvWrapper::FileExists(fname);
}
virtual Status GetChildren(const std::string& dir,
Status GetChildren(const std::string& dir,
std::vector<std::string>* result) override {
PERF_TIMER_GUARD(env_get_children_nanos);
return EnvWrapper::GetChildren(dir, result);
}
virtual Status GetChildrenFileAttributes(
Status GetChildrenFileAttributes(
const std::string& dir, std::vector<FileAttributes>* result) override {
PERF_TIMER_GUARD(env_get_children_file_attributes_nanos);
return EnvWrapper::GetChildrenFileAttributes(dir, result);
}
virtual Status DeleteFile(const std::string& fname) override {
Status DeleteFile(const std::string& fname) override {
PERF_TIMER_GUARD(env_delete_file_nanos);
return EnvWrapper::DeleteFile(fname);
}
virtual Status CreateDir(const std::string& dirname) override {
Status CreateDir(const std::string& dirname) override {
PERF_TIMER_GUARD(env_create_dir_nanos);
return EnvWrapper::CreateDir(dirname);
}
virtual Status CreateDirIfMissing(const std::string& dirname) override {
Status CreateDirIfMissing(const std::string& dirname) override {
PERF_TIMER_GUARD(env_create_dir_if_missing_nanos);
return EnvWrapper::CreateDirIfMissing(dirname);
}
virtual Status DeleteDir(const std::string& dirname) override {
Status DeleteDir(const std::string& dirname) override {
PERF_TIMER_GUARD(env_delete_dir_nanos);
return EnvWrapper::DeleteDir(dirname);
}
virtual Status GetFileSize(const std::string& fname,
uint64_t* file_size) override {
Status GetFileSize(const std::string& fname, uint64_t* file_size) override {
PERF_TIMER_GUARD(env_get_file_size_nanos);
return EnvWrapper::GetFileSize(fname, file_size);
}
virtual Status GetFileModificationTime(const std::string& fname,
Status GetFileModificationTime(const std::string& fname,
uint64_t* file_mtime) override {
PERF_TIMER_GUARD(env_get_file_modification_time_nanos);
return EnvWrapper::GetFileModificationTime(fname, file_mtime);
}
virtual Status RenameFile(const std::string& src,
const std::string& dst) override {
Status RenameFile(const std::string& src, const std::string& dst) override {
PERF_TIMER_GUARD(env_rename_file_nanos);
return EnvWrapper::RenameFile(src, dst);
}
virtual Status LinkFile(const std::string& src,
const std::string& dst) override {
Status LinkFile(const std::string& src, const std::string& dst) override {
PERF_TIMER_GUARD(env_link_file_nanos);
return EnvWrapper::LinkFile(src, dst);
}
virtual Status LockFile(const std::string& fname, FileLock** lock) override {
Status LockFile(const std::string& fname, FileLock** lock) override {
PERF_TIMER_GUARD(env_lock_file_nanos);
return EnvWrapper::LockFile(fname, lock);
}
virtual Status UnlockFile(FileLock* lock) override {
Status UnlockFile(FileLock* lock) override {
PERF_TIMER_GUARD(env_unlock_file_nanos);
return EnvWrapper::UnlockFile(lock);
}
virtual Status NewLogger(const std::string& fname,
Status NewLogger(const std::string& fname,
std::shared_ptr<Logger>* result) override {
PERF_TIMER_GUARD(env_new_logger_nanos);
return EnvWrapper::NewLogger(fname, result);

View File

@ -19,7 +19,7 @@ namespace { // anonymous namespace
// Slice::compare
class MaxOperator : public MergeOperator {
public:
virtual bool FullMergeV2(const MergeOperationInput& merge_in,
bool FullMergeV2(const MergeOperationInput& merge_in,
MergeOperationOutput* merge_out) const override {
Slice& max = merge_out->existing_operand;
if (merge_in.existing_value) {
@ -38,7 +38,7 @@ class MaxOperator : public MergeOperator {
return true;
}
virtual bool PartialMerge(const Slice& /*key*/, const Slice& left_operand,
bool PartialMerge(const Slice& /*key*/, const Slice& left_operand,
const Slice& right_operand, std::string* new_value,
Logger* /*logger*/) const override {
if (left_operand.compare(right_operand) >= 0) {
@ -49,7 +49,7 @@ class MaxOperator : public MergeOperator {
return true;
}
virtual bool PartialMergeMulti(const Slice& /*key*/,
bool PartialMergeMulti(const Slice& /*key*/,
const std::deque<Slice>& operand_list,
std::string* new_value,
Logger* /*logger*/) const override {
@ -64,7 +64,7 @@ class MaxOperator : public MergeOperator {
return true;
}
virtual const char* Name() const override { return "MaxOperator"; }
const char* Name() const override { return "MaxOperator"; }
};
} // end of anonymous namespace

View File

@ -22,10 +22,9 @@ namespace { // anonymous namespace
// From the client-perspective, semantics are the same.
class PutOperator : public MergeOperator {
public:
virtual bool FullMerge(const Slice& /*key*/, const Slice* /*existing_value*/,
bool FullMerge(const Slice& /*key*/, const Slice* /*existing_value*/,
const std::deque<std::string>& operand_sequence,
std::string* new_value,
Logger* /*logger*/) const override {
std::string* new_value, Logger* /*logger*/) const override {
// Put basically only looks at the current/latest value
assert(!operand_sequence.empty());
assert(new_value != nullptr);
@ -33,7 +32,7 @@ class PutOperator : public MergeOperator {
return true;
}
virtual bool PartialMerge(const Slice& /*key*/, const Slice& /*left_operand*/,
bool PartialMerge(const Slice& /*key*/, const Slice& /*left_operand*/,
const Slice& right_operand, std::string* new_value,
Logger* /*logger*/) const override {
new_value->assign(right_operand.data(), right_operand.size());
@ -41,7 +40,7 @@ class PutOperator : public MergeOperator {
}
using MergeOperator::PartialMergeMulti;
virtual bool PartialMergeMulti(const Slice& /*key*/,
bool PartialMergeMulti(const Slice& /*key*/,
const std::deque<Slice>& operand_list,
std::string* new_value,
Logger* /*logger*/) const override {
@ -49,13 +48,11 @@ class PutOperator : public MergeOperator {
return true;
}
virtual const char* Name() const override {
return "PutOperator";
}
const char* Name() const override { return "PutOperator"; }
};
class PutOperatorV2 : public PutOperator {
virtual bool FullMerge(const Slice& /*key*/, const Slice* /*existing_value*/,
bool FullMerge(const Slice& /*key*/, const Slice* /*existing_value*/,
const std::deque<std::string>& /*operand_sequence*/,
std::string* /*new_value*/,
Logger* /*logger*/) const override {
@ -63,7 +60,7 @@ class PutOperatorV2 : public PutOperator {
return false;
}
virtual bool FullMergeV2(const MergeOperationInput& merge_in,
bool FullMergeV2(const MergeOperationInput& merge_in,
MergeOperationOutput* merge_out) const override {
// Put basically only looks at the current/latest value
assert(!merge_in.operand_list.empty());

View File

@ -20,7 +20,7 @@ namespace { // anonymous namespace
// Implemented as an AssociativeMergeOperator for simplicity and example.
class UInt64AddOperator : public AssociativeMergeOperator {
public:
virtual bool Merge(const Slice& /*key*/, const Slice* existing_value,
bool Merge(const Slice& /*key*/, const Slice* existing_value,
const Slice& value, std::string* new_value,
Logger* logger) const override {
uint64_t orig_value = 0;
@ -36,9 +36,7 @@ class UInt64AddOperator : public AssociativeMergeOperator {
return true; // Return true always since corruption will be treated as 0
}
virtual const char* Name() const override {
return "UInt64AddOperator";
}
const char* Name() const override { return "UInt64AddOperator"; }
private:
// Takes the string and decodes it into a uint64_t

View File

@ -98,11 +98,11 @@ namespace {
class DummyTableFactory : public TableFactory {
public:
DummyTableFactory() {}
virtual ~DummyTableFactory() {}
~DummyTableFactory() override {}
virtual const char* Name() const override { return "DummyTableFactory"; }
const char* Name() const override { return "DummyTableFactory"; }
virtual Status NewTableReader(
Status NewTableReader(
const TableReaderOptions& /*table_reader_options*/,
std::unique_ptr<RandomAccessFileReader>&& /*file*/,
uint64_t /*file_size*/, std::unique_ptr<TableReader>* /*table_reader*/,
@ -110,20 +110,20 @@ class DummyTableFactory : public TableFactory {
return Status::NotSupported();
}
virtual TableBuilder* NewTableBuilder(
TableBuilder* NewTableBuilder(
const TableBuilderOptions& /*table_builder_options*/,
uint32_t /*column_family_id*/,
WritableFileWriter* /*file*/) const override {
return nullptr;
}
virtual Status SanitizeOptions(
Status SanitizeOptions(
const DBOptions& /*db_opts*/,
const ColumnFamilyOptions& /*cf_opts*/) const override {
return Status::NotSupported();
}
virtual std::string GetPrintableTableOptions() const override { return ""; }
std::string GetPrintableTableOptions() const override { return ""; }
Status GetOptionString(std::string* /*opt_string*/,
const std::string& /*delimiter*/) const override {
@ -134,39 +134,39 @@ class DummyTableFactory : public TableFactory {
class DummyMergeOperator : public MergeOperator {
public:
DummyMergeOperator() {}
virtual ~DummyMergeOperator() {}
~DummyMergeOperator() override {}
virtual bool FullMergeV2(const MergeOperationInput& /*merge_in*/,
bool FullMergeV2(const MergeOperationInput& /*merge_in*/,
MergeOperationOutput* /*merge_out*/) const override {
return false;
}
virtual bool PartialMergeMulti(const Slice& /*key*/,
bool PartialMergeMulti(const Slice& /*key*/,
const std::deque<Slice>& /*operand_list*/,
std::string* /*new_value*/,
Logger* /*logger*/) const override {
return false;
}
virtual const char* Name() const override { return "DummyMergeOperator"; }
const char* Name() const override { return "DummyMergeOperator"; }
};
class DummySliceTransform : public SliceTransform {
public:
DummySliceTransform() {}
virtual ~DummySliceTransform() {}
~DummySliceTransform() override {}
// Return the name of this transformation.
virtual const char* Name() const { return "DummySliceTransform"; }
const char* Name() const override { return "DummySliceTransform"; }
// transform a src in domain to a dst in the range
virtual Slice Transform(const Slice& src) const { return src; }
Slice Transform(const Slice& src) const override { return src; }
// determine whether this is a valid src upon the function applies
virtual bool InDomain(const Slice& /*src*/) const { return false; }
bool InDomain(const Slice& /*src*/) const override { return false; }
// determine whether dst=Transform(src) for some src
virtual bool InRange(const Slice& /*dst*/) const { return false; }
bool InRange(const Slice& /*dst*/) const override { return false; }
};
} // namespace

View File

@ -20,7 +20,7 @@
namespace rocksdb {
struct HashTableTest : public testing::Test {
~HashTableTest() { map_.Clear(&HashTableTest::ClearNode); }
~HashTableTest() override { map_.Clear(&HashTableTest::ClearNode); }
struct Node {
Node() {}
@ -49,7 +49,9 @@ struct HashTableTest : public testing::Test {
};
struct EvictableHashTableTest : public testing::Test {
~EvictableHashTableTest() { map_.Clear(&EvictableHashTableTest::ClearNode); }
~EvictableHashTableTest() override {
map_.Clear(&EvictableHashTableTest::ClearNode);
}
struct Node : LRUElement<Node> {
Node() {}

View File

@ -160,18 +160,16 @@ class SimCacheImpl : public SimCache {
hit_times_(0),
stats_(nullptr) {}
virtual ~SimCacheImpl() {}
virtual void SetCapacity(size_t capacity) override {
cache_->SetCapacity(capacity);
}
~SimCacheImpl() override {}
void SetCapacity(size_t capacity) override { cache_->SetCapacity(capacity); }
virtual void SetStrictCapacityLimit(bool strict_capacity_limit) override {
void SetStrictCapacityLimit(bool strict_capacity_limit) override {
cache_->SetStrictCapacityLimit(strict_capacity_limit);
}
virtual Status Insert(const Slice& key, void* value, size_t charge,
void (*deleter)(const Slice& key, void* value),
Handle** handle, Priority priority) override {
Status Insert(const Slice& key, void* value, size_t charge,
void (*deleter)(const Slice& key, void* value), Handle** handle,
Priority priority) override {
// The handle and value passed in are for real cache, so we pass nullptr
// to key_only_cache_ for both instead. Also, the deleter function pointer
// will be called by user to perform some external operation which should
@ -191,7 +189,7 @@ class SimCacheImpl : public SimCache {
return cache_->Insert(key, value, charge, deleter, handle, priority);
}
virtual Handle* Lookup(const Slice& key, Statistics* stats) override {
Handle* Lookup(const Slice& key, Statistics* stats) override {
Handle* h = key_only_cache_->Lookup(key);
if (h != nullptr) {
key_only_cache_->Release(h);
@ -207,79 +205,75 @@ class SimCacheImpl : public SimCache {
return cache_->Lookup(key, stats);
}
virtual bool Ref(Handle* handle) override { return cache_->Ref(handle); }
bool Ref(Handle* handle) override { return cache_->Ref(handle); }
virtual bool Release(Handle* handle, bool force_erase = false) override {
bool Release(Handle* handle, bool force_erase = false) override {
return cache_->Release(handle, force_erase);
}
virtual void Erase(const Slice& key) override {
void Erase(const Slice& key) override {
cache_->Erase(key);
key_only_cache_->Erase(key);
}
virtual void* Value(Handle* handle) override { return cache_->Value(handle); }
void* Value(Handle* handle) override { return cache_->Value(handle); }
virtual uint64_t NewId() override { return cache_->NewId(); }
uint64_t NewId() override { return cache_->NewId(); }
virtual size_t GetCapacity() const override { return cache_->GetCapacity(); }
size_t GetCapacity() const override { return cache_->GetCapacity(); }
virtual bool HasStrictCapacityLimit() const override {
bool HasStrictCapacityLimit() const override {
return cache_->HasStrictCapacityLimit();
}
virtual size_t GetUsage() const override { return cache_->GetUsage(); }
size_t GetUsage() const override { return cache_->GetUsage(); }
virtual size_t GetUsage(Handle* handle) const override {
size_t GetUsage(Handle* handle) const override {
return cache_->GetUsage(handle);
}
virtual size_t GetPinnedUsage() const override {
return cache_->GetPinnedUsage();
}
size_t GetPinnedUsage() const override { return cache_->GetPinnedUsage(); }
virtual void DisownData() override {
void DisownData() override {
cache_->DisownData();
key_only_cache_->DisownData();
}
virtual void ApplyToAllCacheEntries(void (*callback)(void*, size_t),
void ApplyToAllCacheEntries(void (*callback)(void*, size_t),
bool thread_safe) override {
// only apply to _cache since key_only_cache doesn't hold value
cache_->ApplyToAllCacheEntries(callback, thread_safe);
}
virtual void EraseUnRefEntries() override {
void EraseUnRefEntries() override {
cache_->EraseUnRefEntries();
key_only_cache_->EraseUnRefEntries();
}
virtual size_t GetSimCapacity() const override {
size_t GetSimCapacity() const override {
return key_only_cache_->GetCapacity();
}
virtual size_t GetSimUsage() const override {
return key_only_cache_->GetUsage();
}
virtual void SetSimCapacity(size_t capacity) override {
size_t GetSimUsage() const override { return key_only_cache_->GetUsage(); }
void SetSimCapacity(size_t capacity) override {
key_only_cache_->SetCapacity(capacity);
}
virtual uint64_t get_miss_counter() const override {
uint64_t get_miss_counter() const override {
return miss_times_.load(std::memory_order_relaxed);
}
virtual uint64_t get_hit_counter() const override {
uint64_t get_hit_counter() const override {
return hit_times_.load(std::memory_order_relaxed);
}
virtual void reset_counter() override {
void reset_counter() override {
miss_times_.store(0, std::memory_order_relaxed);
hit_times_.store(0, std::memory_order_relaxed);
SetTickerCount(stats_, SIM_BLOCK_CACHE_HIT, 0);
SetTickerCount(stats_, SIM_BLOCK_CACHE_MISS, 0);
}
virtual std::string ToString() const override {
std::string ToString() const override {
std::string res;
res.append("SimCache MISSes: " + std::to_string(get_miss_counter()) + "\n");
res.append("SimCache HITs: " + std::to_string(get_hit_counter()) + "\n");
@ -291,7 +285,7 @@ class SimCacheImpl : public SimCache {
return res;
}
virtual std::string GetPrintableOptions() const override {
std::string GetPrintableOptions() const override {
std::string ret;
ret.reserve(20000);
ret.append(" cache_options:\n");
@ -301,18 +295,15 @@ class SimCacheImpl : public SimCache {
return ret;
}
virtual Status StartActivityLogging(const std::string& activity_log_file,
Env* env,
Status StartActivityLogging(const std::string& activity_log_file, Env* env,
uint64_t max_logging_size = 0) override {
return cache_activity_logger_.StartLogging(activity_log_file, env,
max_logging_size);
}
virtual void StopActivityLogging() override {
cache_activity_logger_.StopLogging();
}
void StopActivityLogging() override { cache_activity_logger_.StopLogging(); }
virtual Status GetActivityLoggingStatus() override {
Status GetActivityLoggingStatus() override {
return cache_activity_logger_.bg_status();
}

View File

@ -37,7 +37,7 @@ class OptimisticTransactionTest : public testing::Test {
DestroyDB(dbname, options);
Open();
}
~OptimisticTransactionTest() {
~OptimisticTransactionTest() override {
delete txn_db;
DestroyDB(dbname, options);
}

View File

@ -459,18 +459,17 @@ Status PessimisticTransaction::LockBatch(WriteBatch* batch,
}
}
virtual Status PutCF(uint32_t column_family_id, const Slice& key,
Status PutCF(uint32_t column_family_id, const Slice& key,
const Slice& /* unused */) override {
RecordKey(column_family_id, key);
return Status::OK();
}
virtual Status MergeCF(uint32_t column_family_id, const Slice& key,
Status MergeCF(uint32_t column_family_id, const Slice& key,
const Slice& /* unused */) override {
RecordKey(column_family_id, key);
return Status::OK();
}
virtual Status DeleteCF(uint32_t column_family_id,
const Slice& key) override {
Status DeleteCF(uint32_t column_family_id, const Slice& key) override {
RecordKey(column_family_id, key);
return Status::OK();
}

View File

@ -19,7 +19,7 @@ namespace rocksdb {
class TransactionDBMutexImpl : public TransactionDBMutex {
public:
TransactionDBMutexImpl() {}
~TransactionDBMutexImpl() {}
~TransactionDBMutexImpl() override {}
Status Lock() override;
@ -36,7 +36,7 @@ class TransactionDBMutexImpl : public TransactionDBMutex {
class TransactionDBCondVarImpl : public TransactionDBCondVar {
public:
TransactionDBCondVarImpl() {}
~TransactionDBCondVarImpl() {}
~TransactionDBCondVarImpl() override {}
Status Wait(std::shared_ptr<TransactionDBMutex> mutex) override;

View File

@ -4791,7 +4791,7 @@ TEST_P(TransactionTest, SetSnapshotOnNextOperationWithNotification) {
explicit Notifier(const Snapshot** snapshot_ptr)
: snapshot_ptr_(snapshot_ptr) {}
void SnapshotCreated(const Snapshot* newSnapshot) {
void SnapshotCreated(const Snapshot* newSnapshot) override {
*snapshot_ptr_ = newSnapshot;
}
};
@ -5266,15 +5266,13 @@ TEST_P(TransactionTest, Optimizations) {
class ThreeBytewiseComparator : public Comparator {
public:
ThreeBytewiseComparator() {}
virtual const char* Name() const override {
return "test.ThreeBytewiseComparator";
}
virtual int Compare(const Slice& a, const Slice& b) const override {
const char* Name() const override { return "test.ThreeBytewiseComparator"; }
int Compare(const Slice& a, const Slice& b) const override {
Slice na = Slice(a.data(), a.size() < 3 ? a.size() : 3);
Slice nb = Slice(b.data(), b.size() < 3 ? b.size() : 3);
return na.compare(nb);
}
virtual bool Equal(const Slice& a, const Slice& b) const override {
bool Equal(const Slice& a, const Slice& b) const override {
Slice na = Slice(a.data(), a.size() < 3 ? a.size() : 3);
Slice nb = Slice(b.data(), b.size() < 3 ? b.size() : 3);
return na == nb;

View File

@ -330,7 +330,7 @@ class WritePreparedTxnDBMock : public WritePreparedTxnDB {
void TakeSnapshot(SequenceNumber seq) { snapshots_.push_back(seq); }
protected:
virtual const std::vector<SequenceNumber> GetSnapshotListFromDB(
const std::vector<SequenceNumber> GetSnapshotListFromDB(
SequenceNumber /* unused */) override {
return snapshots_;
}

View File

@ -185,7 +185,7 @@ Status WritePreparedTxn::CommitInternal() {
public:
explicit PublishSeqPreReleaseCallback(DBImpl* db_impl)
: db_impl_(db_impl) {}
virtual Status Callback(SequenceNumber seq, bool is_mem_disabled) override {
Status Callback(SequenceNumber seq, bool is_mem_disabled) override {
#ifdef NDEBUG
(void)is_mem_disabled;
#endif
@ -311,7 +311,7 @@ Status WritePreparedTxn::RollbackInternal() {
}
protected:
virtual bool WriteAfterCommit() const override { return false; }
bool WriteAfterCommit() const override { return false; }
} rollback_handler(db_impl_, wpt_db_, read_at_seq, &rollback_batch,
*cf_comp_map_shared_ptr.get(), *cf_map_shared_ptr.get(),
wpt_db_->txn_db_options_.rollback_merge_operands);

View File

@ -64,8 +64,7 @@ Status WritePreparedTxnDB::Initialize(
public:
explicit CommitSubBatchPreReleaseCallback(WritePreparedTxnDB* db)
: db_(db) {}
virtual Status Callback(SequenceNumber commit_seq,
bool is_mem_disabled) override {
Status Callback(SequenceNumber commit_seq, bool is_mem_disabled) override {
#ifdef NDEBUG
(void)is_mem_disabled;
#endif

Some files were not shown because too many files have changed in this diff Show More