Switch to using C++ 11 override specifier.
PiperOrigin-RevId: 247491163
This commit is contained in:
parent
85cd40d108
commit
28e6d238be
22
db/c.cc
22
db/c.cc
@ -84,17 +84,17 @@ struct leveldb_filelock_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct leveldb_comparator_t : public Comparator {
|
struct leveldb_comparator_t : public Comparator {
|
||||||
virtual ~leveldb_comparator_t() { (*destructor_)(state_); }
|
~leveldb_comparator_t() override { (*destructor_)(state_); }
|
||||||
|
|
||||||
virtual int Compare(const Slice& a, const Slice& b) const {
|
int Compare(const Slice& a, const Slice& b) const override {
|
||||||
return (*compare_)(state_, a.data(), a.size(), b.data(), b.size());
|
return (*compare_)(state_, a.data(), a.size(), b.data(), b.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const char* Name() const { return (*name_)(state_); }
|
const char* Name() const override { return (*name_)(state_); }
|
||||||
|
|
||||||
// No-ops since the C binding does not support key shortening methods.
|
// No-ops since the C binding does not support key shortening methods.
|
||||||
virtual void FindShortestSeparator(std::string*, const Slice&) const {}
|
void FindShortestSeparator(std::string*, const Slice&) const override {}
|
||||||
virtual void FindShortSuccessor(std::string* key) const {}
|
void FindShortSuccessor(std::string* key) const override {}
|
||||||
|
|
||||||
void* state_;
|
void* state_;
|
||||||
void (*destructor_)(void*);
|
void (*destructor_)(void*);
|
||||||
@ -104,11 +104,11 @@ struct leveldb_comparator_t : public Comparator {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct leveldb_filterpolicy_t : public FilterPolicy {
|
struct leveldb_filterpolicy_t : public FilterPolicy {
|
||||||
virtual ~leveldb_filterpolicy_t() { (*destructor_)(state_); }
|
~leveldb_filterpolicy_t() override { (*destructor_)(state_); }
|
||||||
|
|
||||||
virtual const char* Name() const { return (*name_)(state_); }
|
const char* Name() const override { return (*name_)(state_); }
|
||||||
|
|
||||||
virtual void CreateFilter(const Slice* keys, int n, std::string* dst) const {
|
void CreateFilter(const Slice* keys, int n, std::string* dst) const override {
|
||||||
std::vector<const char*> key_pointers(n);
|
std::vector<const char*> key_pointers(n);
|
||||||
std::vector<size_t> key_sizes(n);
|
std::vector<size_t> key_sizes(n);
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
@ -121,7 +121,7 @@ struct leveldb_filterpolicy_t : public FilterPolicy {
|
|||||||
free(filter);
|
free(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool KeyMayMatch(const Slice& key, const Slice& filter) const {
|
bool KeyMayMatch(const Slice& key, const Slice& filter) const override {
|
||||||
return (*key_match_)(state_, key.data(), key.size(), filter.data(),
|
return (*key_match_)(state_, key.data(), key.size(), filter.data(),
|
||||||
filter.size());
|
filter.size());
|
||||||
}
|
}
|
||||||
@ -345,10 +345,10 @@ void leveldb_writebatch_iterate(const leveldb_writebatch_t* b, void* state,
|
|||||||
void* state_;
|
void* state_;
|
||||||
void (*put_)(void*, const char* k, size_t klen, const char* v, size_t vlen);
|
void (*put_)(void*, const char* k, size_t klen, const char* v, size_t vlen);
|
||||||
void (*deleted_)(void*, const char* k, size_t klen);
|
void (*deleted_)(void*, const char* k, size_t klen);
|
||||||
virtual void Put(const Slice& key, const Slice& value) {
|
void Put(const Slice& key, const Slice& value) override {
|
||||||
(*put_)(state_, key.data(), key.size(), value.data(), value.size());
|
(*put_)(state_, key.data(), key.size(), value.data(), value.size());
|
||||||
}
|
}
|
||||||
virtual void Delete(const Slice& key) {
|
void Delete(const Slice& key) override {
|
||||||
(*deleted_)(state_, key.data(), key.size());
|
(*deleted_)(state_, key.data(), key.size());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -376,7 +376,7 @@ Status DBImpl::RecoverLogFile(uint64_t log_number, bool last_log,
|
|||||||
Logger* info_log;
|
Logger* info_log;
|
||||||
const char* fname;
|
const char* fname;
|
||||||
Status* status; // null if options_.paranoid_checks==false
|
Status* status; // null if options_.paranoid_checks==false
|
||||||
virtual void Corruption(size_t bytes, const Status& s) {
|
void Corruption(size_t bytes, const Status& s) override {
|
||||||
Log(info_log, "%s%s: dropping %d bytes; %s",
|
Log(info_log, "%s%s: dropping %d bytes; %s",
|
||||||
(this->status == nullptr ? "(ignoring error) " : ""), fname,
|
(this->status == nullptr ? "(ignoring error) " : ""), fname,
|
||||||
static_cast<int>(bytes), s.ToString().c_str());
|
static_cast<int>(bytes), s.ToString().c_str());
|
||||||
|
25
db/db_impl.h
25
db/db_impl.h
@ -33,20 +33,21 @@ class DBImpl : public DB {
|
|||||||
DBImpl(const DBImpl&) = delete;
|
DBImpl(const DBImpl&) = delete;
|
||||||
DBImpl& operator=(const DBImpl&) = delete;
|
DBImpl& operator=(const DBImpl&) = delete;
|
||||||
|
|
||||||
virtual ~DBImpl();
|
~DBImpl() override;
|
||||||
|
|
||||||
// Implementations of the DB interface
|
// Implementations of the DB interface
|
||||||
virtual Status Put(const WriteOptions&, const Slice& key, const Slice& value);
|
Status Put(const WriteOptions&, const Slice& key,
|
||||||
virtual Status Delete(const WriteOptions&, const Slice& key);
|
const Slice& value) override;
|
||||||
virtual Status Write(const WriteOptions& options, WriteBatch* updates);
|
Status Delete(const WriteOptions&, const Slice& key) override;
|
||||||
virtual Status Get(const ReadOptions& options, const Slice& key,
|
Status Write(const WriteOptions& options, WriteBatch* updates) override;
|
||||||
std::string* value);
|
Status Get(const ReadOptions& options, const Slice& key,
|
||||||
virtual Iterator* NewIterator(const ReadOptions&);
|
std::string* value) override;
|
||||||
virtual const Snapshot* GetSnapshot();
|
Iterator* NewIterator(const ReadOptions&) override;
|
||||||
virtual void ReleaseSnapshot(const Snapshot* snapshot);
|
const Snapshot* GetSnapshot() override;
|
||||||
virtual bool GetProperty(const Slice& property, std::string* value);
|
void ReleaseSnapshot(const Snapshot* snapshot) override;
|
||||||
virtual void GetApproximateSizes(const Range* range, int n, uint64_t* sizes);
|
bool GetProperty(const Slice& property, std::string* value) override;
|
||||||
virtual void CompactRange(const Slice* begin, const Slice* end);
|
void GetApproximateSizes(const Range* range, int n, uint64_t* sizes) override;
|
||||||
|
void CompactRange(const Slice* begin, const Slice* end) override;
|
||||||
|
|
||||||
// Extra methods (for testing) that are not in the public DB interface
|
// Extra methods (for testing) that are not in the public DB interface
|
||||||
|
|
||||||
|
@ -59,17 +59,17 @@ class DBIter : public Iterator {
|
|||||||
DBIter(const DBIter&) = delete;
|
DBIter(const DBIter&) = delete;
|
||||||
DBIter& operator=(const DBIter&) = delete;
|
DBIter& operator=(const DBIter&) = delete;
|
||||||
|
|
||||||
virtual ~DBIter() { delete iter_; }
|
~DBIter() override { delete iter_; }
|
||||||
virtual bool Valid() const { return valid_; }
|
bool Valid() const override { return valid_; }
|
||||||
virtual Slice key() const {
|
Slice key() const override {
|
||||||
assert(valid_);
|
assert(valid_);
|
||||||
return (direction_ == kForward) ? ExtractUserKey(iter_->key()) : saved_key_;
|
return (direction_ == kForward) ? ExtractUserKey(iter_->key()) : saved_key_;
|
||||||
}
|
}
|
||||||
virtual Slice value() const {
|
Slice value() const override {
|
||||||
assert(valid_);
|
assert(valid_);
|
||||||
return (direction_ == kForward) ? iter_->value() : saved_value_;
|
return (direction_ == kForward) ? iter_->value() : saved_value_;
|
||||||
}
|
}
|
||||||
virtual Status status() const {
|
Status status() const override {
|
||||||
if (status_.ok()) {
|
if (status_.ok()) {
|
||||||
return iter_->status();
|
return iter_->status();
|
||||||
} else {
|
} else {
|
||||||
@ -77,11 +77,11 @@ class DBIter : public Iterator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Next();
|
void Next() override;
|
||||||
virtual void Prev();
|
void Prev() override;
|
||||||
virtual void Seek(const Slice& target);
|
void Seek(const Slice& target) override;
|
||||||
virtual void SeekToFirst();
|
void SeekToFirst() override;
|
||||||
virtual void SeekToLast();
|
void SeekToLast() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void FindNextUserEntry(bool skipping, std::string* skip);
|
void FindNextUserEntry(bool skipping, std::string* skip);
|
||||||
|
@ -210,9 +210,9 @@ class SpecialEnv : public EnvWrapper {
|
|||||||
public:
|
public:
|
||||||
CountingFile(RandomAccessFile* target, AtomicCounter* counter)
|
CountingFile(RandomAccessFile* target, AtomicCounter* counter)
|
||||||
: target_(target), counter_(counter) {}
|
: target_(target), counter_(counter) {}
|
||||||
virtual ~CountingFile() { delete target_; }
|
~CountingFile() override { delete target_; }
|
||||||
virtual Status Read(uint64_t offset, size_t n, Slice* result,
|
Status Read(uint64_t offset, size_t n, Slice* result,
|
||||||
char* scratch) const {
|
char* scratch) const override {
|
||||||
counter_->Increment();
|
counter_->Increment();
|
||||||
return target_->Read(offset, n, result, scratch);
|
return target_->Read(offset, n, result, scratch);
|
||||||
}
|
}
|
||||||
@ -1504,14 +1504,14 @@ TEST(DBTest, Fflush_Issue474) {
|
|||||||
TEST(DBTest, ComparatorCheck) {
|
TEST(DBTest, ComparatorCheck) {
|
||||||
class NewComparator : public Comparator {
|
class NewComparator : public Comparator {
|
||||||
public:
|
public:
|
||||||
virtual const char* Name() const { return "leveldb.NewComparator"; }
|
const char* Name() const override { return "leveldb.NewComparator"; }
|
||||||
virtual int Compare(const Slice& a, const Slice& b) const {
|
int Compare(const Slice& a, const Slice& b) const override {
|
||||||
return BytewiseComparator()->Compare(a, b);
|
return BytewiseComparator()->Compare(a, b);
|
||||||
}
|
}
|
||||||
virtual void FindShortestSeparator(std::string* s, const Slice& l) const {
|
void FindShortestSeparator(std::string* s, const Slice& l) const override {
|
||||||
BytewiseComparator()->FindShortestSeparator(s, l);
|
BytewiseComparator()->FindShortestSeparator(s, l);
|
||||||
}
|
}
|
||||||
virtual void FindShortSuccessor(std::string* key) const {
|
void FindShortSuccessor(std::string* key) const override {
|
||||||
BytewiseComparator()->FindShortSuccessor(key);
|
BytewiseComparator()->FindShortSuccessor(key);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1527,15 +1527,15 @@ TEST(DBTest, ComparatorCheck) {
|
|||||||
TEST(DBTest, CustomComparator) {
|
TEST(DBTest, CustomComparator) {
|
||||||
class NumberComparator : public Comparator {
|
class NumberComparator : public Comparator {
|
||||||
public:
|
public:
|
||||||
virtual const char* Name() const { return "test.NumberComparator"; }
|
const char* Name() const override { return "test.NumberComparator"; }
|
||||||
virtual int Compare(const Slice& a, const Slice& b) const {
|
int Compare(const Slice& a, const Slice& b) const override {
|
||||||
return ToNumber(a) - ToNumber(b);
|
return ToNumber(a) - ToNumber(b);
|
||||||
}
|
}
|
||||||
virtual void FindShortestSeparator(std::string* s, const Slice& l) const {
|
void FindShortestSeparator(std::string* s, const Slice& l) const override {
|
||||||
ToNumber(*s); // Check format
|
ToNumber(*s); // Check format
|
||||||
ToNumber(l); // Check format
|
ToNumber(l); // Check format
|
||||||
}
|
}
|
||||||
virtual void FindShortSuccessor(std::string* key) const {
|
void FindShortSuccessor(std::string* key) const override {
|
||||||
ToNumber(*key); // Check format
|
ToNumber(*key); // Check format
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2060,10 +2060,10 @@ class ModelDB : public DB {
|
|||||||
class Handler : public WriteBatch::Handler {
|
class Handler : public WriteBatch::Handler {
|
||||||
public:
|
public:
|
||||||
KVMap* map_;
|
KVMap* map_;
|
||||||
virtual void Put(const Slice& key, const Slice& value) {
|
void Put(const Slice& key, const Slice& value) override {
|
||||||
(*map_)[key.ToString()] = value.ToString();
|
(*map_)[key.ToString()] = value.ToString();
|
||||||
}
|
}
|
||||||
virtual void Delete(const Slice& key) { map_->erase(key.ToString()); }
|
void Delete(const Slice& key) override { map_->erase(key.ToString()); }
|
||||||
};
|
};
|
||||||
Handler handler;
|
Handler handler;
|
||||||
handler.map_ = &map_;
|
handler.map_ = &map_;
|
||||||
@ -2085,26 +2085,26 @@ class ModelDB : public DB {
|
|||||||
public:
|
public:
|
||||||
ModelIter(const KVMap* map, bool owned)
|
ModelIter(const KVMap* map, bool owned)
|
||||||
: map_(map), owned_(owned), iter_(map_->end()) {}
|
: map_(map), owned_(owned), iter_(map_->end()) {}
|
||||||
~ModelIter() {
|
~ModelIter() override {
|
||||||
if (owned_) delete map_;
|
if (owned_) delete map_;
|
||||||
}
|
}
|
||||||
virtual bool Valid() const { return iter_ != map_->end(); }
|
bool Valid() const override { return iter_ != map_->end(); }
|
||||||
virtual void SeekToFirst() { iter_ = map_->begin(); }
|
void SeekToFirst() override { iter_ = map_->begin(); }
|
||||||
virtual void SeekToLast() {
|
void SeekToLast() override {
|
||||||
if (map_->empty()) {
|
if (map_->empty()) {
|
||||||
iter_ = map_->end();
|
iter_ = map_->end();
|
||||||
} else {
|
} else {
|
||||||
iter_ = map_->find(map_->rbegin()->first);
|
iter_ = map_->find(map_->rbegin()->first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual void Seek(const Slice& k) {
|
void Seek(const Slice& k) override {
|
||||||
iter_ = map_->lower_bound(k.ToString());
|
iter_ = map_->lower_bound(k.ToString());
|
||||||
}
|
}
|
||||||
virtual void Next() { ++iter_; }
|
void Next() override { ++iter_; }
|
||||||
virtual void Prev() { --iter_; }
|
void Prev() override { --iter_; }
|
||||||
virtual Slice key() const { return iter_->first; }
|
Slice key() const override { return iter_->first; }
|
||||||
virtual Slice value() const { return iter_->second; }
|
Slice value() const override { return iter_->second; }
|
||||||
virtual Status status() const { return Status::OK(); }
|
Status status() const override { return Status::OK(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const KVMap* const map_;
|
const KVMap* const map_;
|
||||||
|
@ -103,11 +103,11 @@ class InternalKeyComparator : public Comparator {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit InternalKeyComparator(const Comparator* c) : user_comparator_(c) {}
|
explicit InternalKeyComparator(const Comparator* c) : user_comparator_(c) {}
|
||||||
virtual const char* Name() const;
|
const char* Name() const override;
|
||||||
virtual int Compare(const Slice& a, const Slice& b) const;
|
int Compare(const Slice& a, const Slice& b) const override;
|
||||||
virtual void FindShortestSeparator(std::string* start,
|
void FindShortestSeparator(std::string* start,
|
||||||
const Slice& limit) const;
|
const Slice& limit) const override;
|
||||||
virtual void FindShortSuccessor(std::string* key) const;
|
void FindShortSuccessor(std::string* key) const override;
|
||||||
|
|
||||||
const Comparator* user_comparator() const { return user_comparator_; }
|
const Comparator* user_comparator() const { return user_comparator_; }
|
||||||
|
|
||||||
@ -121,9 +121,9 @@ class InternalFilterPolicy : public FilterPolicy {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit InternalFilterPolicy(const FilterPolicy* p) : user_policy_(p) {}
|
explicit InternalFilterPolicy(const FilterPolicy* p) : user_policy_(p) {}
|
||||||
virtual const char* Name() const;
|
const char* Name() const override;
|
||||||
virtual void CreateFilter(const Slice* keys, int n, std::string* dst) const;
|
void CreateFilter(const Slice* keys, int n, std::string* dst) const override;
|
||||||
virtual bool KeyMayMatch(const Slice& key, const Slice& filter) const;
|
bool KeyMayMatch(const Slice& key, const Slice& filter) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Modules in this directory should keep internal keys wrapped inside
|
// Modules in this directory should keep internal keys wrapped inside
|
||||||
|
@ -38,7 +38,7 @@ bool GuessType(const std::string& fname, FileType* type) {
|
|||||||
// Notified when log reader encounters corruption.
|
// Notified when log reader encounters corruption.
|
||||||
class CorruptionReporter : public log::Reader::Reporter {
|
class CorruptionReporter : public log::Reader::Reporter {
|
||||||
public:
|
public:
|
||||||
virtual void Corruption(size_t bytes, const Status& status) {
|
void Corruption(size_t bytes, const Status& status) override {
|
||||||
std::string r = "corruption: ";
|
std::string r = "corruption: ";
|
||||||
AppendNumberTo(&r, bytes);
|
AppendNumberTo(&r, bytes);
|
||||||
r += " bytes; ";
|
r += " bytes; ";
|
||||||
@ -74,7 +74,7 @@ Status PrintLogContents(Env* env, const std::string& fname,
|
|||||||
// Called on every item found in a WriteBatch.
|
// Called on every item found in a WriteBatch.
|
||||||
class WriteBatchItemPrinter : public WriteBatch::Handler {
|
class WriteBatchItemPrinter : public WriteBatch::Handler {
|
||||||
public:
|
public:
|
||||||
virtual void Put(const Slice& key, const Slice& value) {
|
void Put(const Slice& key, const Slice& value) override {
|
||||||
std::string r = " put '";
|
std::string r = " put '";
|
||||||
AppendEscapedStringTo(&r, key);
|
AppendEscapedStringTo(&r, key);
|
||||||
r += "' '";
|
r += "' '";
|
||||||
@ -82,7 +82,7 @@ class WriteBatchItemPrinter : public WriteBatch::Handler {
|
|||||||
r += "'\n";
|
r += "'\n";
|
||||||
dst_->Append(r);
|
dst_->Append(r);
|
||||||
}
|
}
|
||||||
virtual void Delete(const Slice& key) {
|
void Delete(const Slice& key) override {
|
||||||
std::string r = " del '";
|
std::string r = " del '";
|
||||||
AppendEscapedStringTo(&r, key);
|
AppendEscapedStringTo(&r, key);
|
||||||
r += "'\n";
|
r += "'\n";
|
||||||
|
@ -13,13 +13,13 @@ namespace {
|
|||||||
|
|
||||||
class StdoutPrinter : public WritableFile {
|
class StdoutPrinter : public WritableFile {
|
||||||
public:
|
public:
|
||||||
virtual Status Append(const Slice& data) {
|
Status Append(const Slice& data) override {
|
||||||
fwrite(data.data(), 1, data.size(), stdout);
|
fwrite(data.data(), 1, data.size(), stdout);
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
virtual Status Close() { return Status::OK(); }
|
Status Close() override { return Status::OK(); }
|
||||||
virtual Status Flush() { return Status::OK(); }
|
Status Flush() override { return Status::OK(); }
|
||||||
virtual Status Sync() { return Status::OK(); }
|
Status Sync() override { return Status::OK(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
bool HandleDumpCommand(Env* env, char** files, int num) {
|
bool HandleDumpCommand(Env* env, char** files, int num) {
|
||||||
|
@ -161,10 +161,10 @@ class LogTest {
|
|||||||
private:
|
private:
|
||||||
class StringDest : public WritableFile {
|
class StringDest : public WritableFile {
|
||||||
public:
|
public:
|
||||||
virtual Status Close() { return Status::OK(); }
|
Status Close() override { return Status::OK(); }
|
||||||
virtual Status Flush() { return Status::OK(); }
|
Status Flush() override { return Status::OK(); }
|
||||||
virtual Status Sync() { return Status::OK(); }
|
Status Sync() override { return Status::OK(); }
|
||||||
virtual Status Append(const Slice& slice) {
|
Status Append(const Slice& slice) override {
|
||||||
contents_.append(slice.data(), slice.size());
|
contents_.append(slice.data(), slice.size());
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
@ -176,7 +176,7 @@ class LogTest {
|
|||||||
public:
|
public:
|
||||||
StringSource() : force_error_(false), returned_partial_(false) {}
|
StringSource() : force_error_(false), returned_partial_(false) {}
|
||||||
|
|
||||||
virtual Status Read(size_t n, Slice* result, char* scratch) {
|
Status Read(size_t n, Slice* result, char* scratch) override {
|
||||||
ASSERT_TRUE(!returned_partial_) << "must not Read() after eof/error";
|
ASSERT_TRUE(!returned_partial_) << "must not Read() after eof/error";
|
||||||
|
|
||||||
if (force_error_) {
|
if (force_error_) {
|
||||||
@ -194,7 +194,7 @@ class LogTest {
|
|||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Status Skip(uint64_t n) {
|
Status Skip(uint64_t n) override {
|
||||||
if (n > contents_.size()) {
|
if (n > contents_.size()) {
|
||||||
contents_.clear();
|
contents_.clear();
|
||||||
return Status::NotFound("in-memory file skipped past end");
|
return Status::NotFound("in-memory file skipped past end");
|
||||||
@ -213,7 +213,7 @@ class LogTest {
|
|||||||
class ReportCollector : public Reader::Reporter {
|
class ReportCollector : public Reader::Reporter {
|
||||||
public:
|
public:
|
||||||
ReportCollector() : dropped_bytes_(0) {}
|
ReportCollector() : dropped_bytes_(0) {}
|
||||||
virtual void Corruption(size_t bytes, const Status& status) {
|
void Corruption(size_t bytes, const Status& status) override {
|
||||||
dropped_bytes_ += bytes;
|
dropped_bytes_ += bytes;
|
||||||
message_.append(status.ToString());
|
message_.append(status.ToString());
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ class Repairer {
|
|||||||
Env* env;
|
Env* env;
|
||||||
Logger* info_log;
|
Logger* info_log;
|
||||||
uint64_t lognum;
|
uint64_t lognum;
|
||||||
virtual void Corruption(size_t bytes, const Status& s) {
|
void Corruption(size_t bytes, const Status& s) override {
|
||||||
// We print error messages for corruption, but continue repairing.
|
// We print error messages for corruption, but continue repairing.
|
||||||
Log(info_log, "Log #%llu: dropping %d bytes; %s",
|
Log(info_log, "Log #%llu: dropping %d bytes; %s",
|
||||||
(unsigned long long)lognum, static_cast<int>(bytes),
|
(unsigned long long)lognum, static_cast<int>(bytes),
|
||||||
|
@ -167,19 +167,19 @@ class Version::LevelFileNumIterator : public Iterator {
|
|||||||
const std::vector<FileMetaData*>* flist)
|
const std::vector<FileMetaData*>* flist)
|
||||||
: icmp_(icmp), flist_(flist), index_(flist->size()) { // Marks as invalid
|
: icmp_(icmp), flist_(flist), index_(flist->size()) { // Marks as invalid
|
||||||
}
|
}
|
||||||
virtual bool Valid() const { return index_ < flist_->size(); }
|
bool Valid() const override { return index_ < flist_->size(); }
|
||||||
virtual void Seek(const Slice& target) {
|
void Seek(const Slice& target) override {
|
||||||
index_ = FindFile(icmp_, *flist_, target);
|
index_ = FindFile(icmp_, *flist_, target);
|
||||||
}
|
}
|
||||||
virtual void SeekToFirst() { index_ = 0; }
|
void SeekToFirst() override { index_ = 0; }
|
||||||
virtual void SeekToLast() {
|
void SeekToLast() override {
|
||||||
index_ = flist_->empty() ? 0 : flist_->size() - 1;
|
index_ = flist_->empty() ? 0 : flist_->size() - 1;
|
||||||
}
|
}
|
||||||
virtual void Next() {
|
void Next() override {
|
||||||
assert(Valid());
|
assert(Valid());
|
||||||
index_++;
|
index_++;
|
||||||
}
|
}
|
||||||
virtual void Prev() {
|
void Prev() override {
|
||||||
assert(Valid());
|
assert(Valid());
|
||||||
if (index_ == 0) {
|
if (index_ == 0) {
|
||||||
index_ = flist_->size(); // Marks as invalid
|
index_ = flist_->size(); // Marks as invalid
|
||||||
@ -187,17 +187,17 @@ class Version::LevelFileNumIterator : public Iterator {
|
|||||||
index_--;
|
index_--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Slice key() const {
|
Slice key() const override {
|
||||||
assert(Valid());
|
assert(Valid());
|
||||||
return (*flist_)[index_]->largest.Encode();
|
return (*flist_)[index_]->largest.Encode();
|
||||||
}
|
}
|
||||||
Slice value() const {
|
Slice value() const override {
|
||||||
assert(Valid());
|
assert(Valid());
|
||||||
EncodeFixed64(value_buf_, (*flist_)[index_]->number);
|
EncodeFixed64(value_buf_, (*flist_)[index_]->number);
|
||||||
EncodeFixed64(value_buf_ + 8, (*flist_)[index_]->file_size);
|
EncodeFixed64(value_buf_ + 8, (*flist_)[index_]->file_size);
|
||||||
return Slice(value_buf_, sizeof(value_buf_));
|
return Slice(value_buf_, sizeof(value_buf_));
|
||||||
}
|
}
|
||||||
virtual Status status() const { return Status::OK(); }
|
Status status() const override { return Status::OK(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const InternalKeyComparator icmp_;
|
const InternalKeyComparator icmp_;
|
||||||
@ -883,7 +883,7 @@ Status VersionSet::LogAndApply(VersionEdit* edit, port::Mutex* mu) {
|
|||||||
Status VersionSet::Recover(bool* save_manifest) {
|
Status VersionSet::Recover(bool* save_manifest) {
|
||||||
struct LogReporter : public log::Reader::Reporter {
|
struct LogReporter : public log::Reader::Reporter {
|
||||||
Status* status;
|
Status* status;
|
||||||
virtual void Corruption(size_t bytes, const Status& s) {
|
void Corruption(size_t bytes, const Status& s) override {
|
||||||
if (this->status->ok()) *this->status = s;
|
if (this->status->ok()) *this->status = s;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -156,9 +156,9 @@ class SequentialFileImpl : public SequentialFile {
|
|||||||
file_->Ref();
|
file_->Ref();
|
||||||
}
|
}
|
||||||
|
|
||||||
~SequentialFileImpl() { file_->Unref(); }
|
~SequentialFileImpl() override { file_->Unref(); }
|
||||||
|
|
||||||
virtual Status Read(size_t n, Slice* result, char* scratch) {
|
Status Read(size_t n, Slice* result, char* scratch) override {
|
||||||
Status s = file_->Read(pos_, n, result, scratch);
|
Status s = file_->Read(pos_, n, result, scratch);
|
||||||
if (s.ok()) {
|
if (s.ok()) {
|
||||||
pos_ += result->size();
|
pos_ += result->size();
|
||||||
@ -166,7 +166,7 @@ class SequentialFileImpl : public SequentialFile {
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Status Skip(uint64_t n) {
|
Status Skip(uint64_t n) override {
|
||||||
if (pos_ > file_->Size()) {
|
if (pos_ > file_->Size()) {
|
||||||
return Status::IOError("pos_ > file_->Size()");
|
return Status::IOError("pos_ > file_->Size()");
|
||||||
}
|
}
|
||||||
@ -187,10 +187,10 @@ class RandomAccessFileImpl : public RandomAccessFile {
|
|||||||
public:
|
public:
|
||||||
explicit RandomAccessFileImpl(FileState* file) : file_(file) { file_->Ref(); }
|
explicit RandomAccessFileImpl(FileState* file) : file_(file) { file_->Ref(); }
|
||||||
|
|
||||||
~RandomAccessFileImpl() { file_->Unref(); }
|
~RandomAccessFileImpl() override { file_->Unref(); }
|
||||||
|
|
||||||
virtual Status Read(uint64_t offset, size_t n, Slice* result,
|
Status Read(uint64_t offset, size_t n, Slice* result,
|
||||||
char* scratch) const {
|
char* scratch) const override {
|
||||||
return file_->Read(offset, n, result, scratch);
|
return file_->Read(offset, n, result, scratch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,13 +202,13 @@ class WritableFileImpl : public WritableFile {
|
|||||||
public:
|
public:
|
||||||
WritableFileImpl(FileState* file) : file_(file) { file_->Ref(); }
|
WritableFileImpl(FileState* file) : file_(file) { file_->Ref(); }
|
||||||
|
|
||||||
~WritableFileImpl() { file_->Unref(); }
|
~WritableFileImpl() override { file_->Unref(); }
|
||||||
|
|
||||||
virtual Status Append(const Slice& data) { return file_->Append(data); }
|
Status Append(const Slice& data) override { return file_->Append(data); }
|
||||||
|
|
||||||
virtual Status Close() { return Status::OK(); }
|
Status Close() override { return Status::OK(); }
|
||||||
virtual Status Flush() { return Status::OK(); }
|
Status Flush() override { return Status::OK(); }
|
||||||
virtual Status Sync() { return Status::OK(); }
|
Status Sync() override { return Status::OK(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FileState* file_;
|
FileState* file_;
|
||||||
@ -216,7 +216,7 @@ class WritableFileImpl : public WritableFile {
|
|||||||
|
|
||||||
class NoOpLogger : public Logger {
|
class NoOpLogger : public Logger {
|
||||||
public:
|
public:
|
||||||
virtual void Logv(const char* format, va_list ap) {}
|
void Logv(const char* format, va_list ap) override {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class InMemoryEnv : public EnvWrapper {
|
class InMemoryEnv : public EnvWrapper {
|
||||||
|
@ -123,23 +123,23 @@ class Block::Iter : public Iterator {
|
|||||||
assert(num_restarts_ > 0);
|
assert(num_restarts_ > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool Valid() const { return current_ < restarts_; }
|
bool Valid() const override { return current_ < restarts_; }
|
||||||
virtual Status status() const { return status_; }
|
Status status() const override { return status_; }
|
||||||
virtual Slice key() const {
|
Slice key() const override {
|
||||||
assert(Valid());
|
assert(Valid());
|
||||||
return key_;
|
return key_;
|
||||||
}
|
}
|
||||||
virtual Slice value() const {
|
Slice value() const override {
|
||||||
assert(Valid());
|
assert(Valid());
|
||||||
return value_;
|
return value_;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Next() {
|
void Next() override {
|
||||||
assert(Valid());
|
assert(Valid());
|
||||||
ParseNextKey();
|
ParseNextKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Prev() {
|
void Prev() override {
|
||||||
assert(Valid());
|
assert(Valid());
|
||||||
|
|
||||||
// Scan backwards to a restart point before current_
|
// Scan backwards to a restart point before current_
|
||||||
@ -160,7 +160,7 @@ class Block::Iter : public Iterator {
|
|||||||
} while (ParseNextKey() && NextEntryOffset() < original);
|
} while (ParseNextKey() && NextEntryOffset() < original);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Seek(const Slice& target) {
|
void Seek(const Slice& target) override {
|
||||||
// Binary search in restart array to find the last restart point
|
// Binary search in restart array to find the last restart point
|
||||||
// with a key < target
|
// with a key < target
|
||||||
uint32_t left = 0;
|
uint32_t left = 0;
|
||||||
@ -200,12 +200,12 @@ class Block::Iter : public Iterator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void SeekToFirst() {
|
void SeekToFirst() override {
|
||||||
SeekToRestartPoint(0);
|
SeekToRestartPoint(0);
|
||||||
ParseNextKey();
|
ParseNextKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void SeekToLast() {
|
void SeekToLast() override {
|
||||||
SeekToRestartPoint(num_restarts_ - 1);
|
SeekToRestartPoint(num_restarts_ - 1);
|
||||||
while (ParseNextKey() && NextEntryOffset() < restarts_) {
|
while (ParseNextKey() && NextEntryOffset() < restarts_) {
|
||||||
// Keep skipping
|
// Keep skipping
|
||||||
|
@ -16,16 +16,16 @@ namespace leveldb {
|
|||||||
// For testing: emit an array with one hash value per key
|
// For testing: emit an array with one hash value per key
|
||||||
class TestHashFilter : public FilterPolicy {
|
class TestHashFilter : public FilterPolicy {
|
||||||
public:
|
public:
|
||||||
virtual const char* Name() const { return "TestHashFilter"; }
|
const char* Name() const override { return "TestHashFilter"; }
|
||||||
|
|
||||||
virtual void CreateFilter(const Slice* keys, int n, std::string* dst) const {
|
void CreateFilter(const Slice* keys, int n, std::string* dst) const override {
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
uint32_t h = Hash(keys[i].data(), keys[i].size(), 1);
|
uint32_t h = Hash(keys[i].data(), keys[i].size(), 1);
|
||||||
PutFixed32(dst, h);
|
PutFixed32(dst, h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool KeyMayMatch(const Slice& key, const Slice& filter) const {
|
bool KeyMayMatch(const Slice& key, const Slice& filter) const override {
|
||||||
uint32_t h = Hash(key.data(), key.size(), 1);
|
uint32_t h = Hash(key.data(), key.size(), 1);
|
||||||
for (size_t i = 0; i + 4 <= filter.size(); i += 4) {
|
for (size_t i = 0; i + 4 <= filter.size(); i += 4) {
|
||||||
if (h == DecodeFixed32(filter.data() + i)) {
|
if (h == DecodeFixed32(filter.data() + i)) {
|
||||||
|
@ -24,11 +24,11 @@ class MergingIterator : public Iterator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~MergingIterator() { delete[] children_; }
|
~MergingIterator() override { delete[] children_; }
|
||||||
|
|
||||||
virtual bool Valid() const { return (current_ != nullptr); }
|
bool Valid() const override { return (current_ != nullptr); }
|
||||||
|
|
||||||
virtual void SeekToFirst() {
|
void SeekToFirst() override {
|
||||||
for (int i = 0; i < n_; i++) {
|
for (int i = 0; i < n_; i++) {
|
||||||
children_[i].SeekToFirst();
|
children_[i].SeekToFirst();
|
||||||
}
|
}
|
||||||
@ -36,7 +36,7 @@ class MergingIterator : public Iterator {
|
|||||||
direction_ = kForward;
|
direction_ = kForward;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void SeekToLast() {
|
void SeekToLast() override {
|
||||||
for (int i = 0; i < n_; i++) {
|
for (int i = 0; i < n_; i++) {
|
||||||
children_[i].SeekToLast();
|
children_[i].SeekToLast();
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ class MergingIterator : public Iterator {
|
|||||||
direction_ = kReverse;
|
direction_ = kReverse;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Seek(const Slice& target) {
|
void Seek(const Slice& target) override {
|
||||||
for (int i = 0; i < n_; i++) {
|
for (int i = 0; i < n_; i++) {
|
||||||
children_[i].Seek(target);
|
children_[i].Seek(target);
|
||||||
}
|
}
|
||||||
@ -52,7 +52,7 @@ class MergingIterator : public Iterator {
|
|||||||
direction_ = kForward;
|
direction_ = kForward;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Next() {
|
void Next() override {
|
||||||
assert(Valid());
|
assert(Valid());
|
||||||
|
|
||||||
// Ensure that all children are positioned after key().
|
// Ensure that all children are positioned after key().
|
||||||
@ -78,7 +78,7 @@ class MergingIterator : public Iterator {
|
|||||||
FindSmallest();
|
FindSmallest();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Prev() {
|
void Prev() override {
|
||||||
assert(Valid());
|
assert(Valid());
|
||||||
|
|
||||||
// Ensure that all children are positioned before key().
|
// Ensure that all children are positioned before key().
|
||||||
@ -107,17 +107,17 @@ class MergingIterator : public Iterator {
|
|||||||
FindLargest();
|
FindLargest();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Slice key() const {
|
Slice key() const override {
|
||||||
assert(Valid());
|
assert(Valid());
|
||||||
return current_->key();
|
return current_->key();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Slice value() const {
|
Slice value() const override {
|
||||||
assert(Valid());
|
assert(Valid());
|
||||||
return current_->value();
|
return current_->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Status status() const {
|
Status status() const override {
|
||||||
Status status;
|
Status status;
|
||||||
for (int i = 0; i < n_; i++) {
|
for (int i = 0; i < n_; i++) {
|
||||||
status = children_[i].status();
|
status = children_[i].status();
|
||||||
|
@ -38,23 +38,23 @@ static std::string Reverse(const Slice& key) {
|
|||||||
namespace {
|
namespace {
|
||||||
class ReverseKeyComparator : public Comparator {
|
class ReverseKeyComparator : public Comparator {
|
||||||
public:
|
public:
|
||||||
virtual const char* Name() const {
|
const char* Name() const override {
|
||||||
return "leveldb.ReverseBytewiseComparator";
|
return "leveldb.ReverseBytewiseComparator";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int Compare(const Slice& a, const Slice& b) const {
|
int Compare(const Slice& a, const Slice& b) const override {
|
||||||
return BytewiseComparator()->Compare(Reverse(a), Reverse(b));
|
return BytewiseComparator()->Compare(Reverse(a), Reverse(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void FindShortestSeparator(std::string* start,
|
void FindShortestSeparator(std::string* start,
|
||||||
const Slice& limit) const {
|
const Slice& limit) const override {
|
||||||
std::string s = Reverse(*start);
|
std::string s = Reverse(*start);
|
||||||
std::string l = Reverse(limit);
|
std::string l = Reverse(limit);
|
||||||
BytewiseComparator()->FindShortestSeparator(&s, l);
|
BytewiseComparator()->FindShortestSeparator(&s, l);
|
||||||
*start = Reverse(s);
|
*start = Reverse(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void FindShortSuccessor(std::string* key) const {
|
void FindShortSuccessor(std::string* key) const override {
|
||||||
std::string s = Reverse(*key);
|
std::string s = Reverse(*key);
|
||||||
BytewiseComparator()->FindShortSuccessor(&s);
|
BytewiseComparator()->FindShortSuccessor(&s);
|
||||||
*key = Reverse(s);
|
*key = Reverse(s);
|
||||||
@ -89,15 +89,15 @@ struct STLLessThan {
|
|||||||
|
|
||||||
class StringSink : public WritableFile {
|
class StringSink : public WritableFile {
|
||||||
public:
|
public:
|
||||||
~StringSink() = default;
|
~StringSink() override = default;
|
||||||
|
|
||||||
const std::string& contents() const { return contents_; }
|
const std::string& contents() const { return contents_; }
|
||||||
|
|
||||||
virtual Status Close() { return Status::OK(); }
|
Status Close() override { return Status::OK(); }
|
||||||
virtual Status Flush() { return Status::OK(); }
|
Status Flush() override { return Status::OK(); }
|
||||||
virtual Status Sync() { return Status::OK(); }
|
Status Sync() override { return Status::OK(); }
|
||||||
|
|
||||||
virtual Status Append(const Slice& data) {
|
Status Append(const Slice& data) override {
|
||||||
contents_.append(data.data(), data.size());
|
contents_.append(data.data(), data.size());
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
@ -111,12 +111,12 @@ class StringSource : public RandomAccessFile {
|
|||||||
StringSource(const Slice& contents)
|
StringSource(const Slice& contents)
|
||||||
: contents_(contents.data(), contents.size()) {}
|
: contents_(contents.data(), contents.size()) {}
|
||||||
|
|
||||||
virtual ~StringSource() = default;
|
~StringSource() override = default;
|
||||||
|
|
||||||
uint64_t Size() const { return contents_.size(); }
|
uint64_t Size() const { return contents_.size(); }
|
||||||
|
|
||||||
virtual Status Read(uint64_t offset, size_t n, Slice* result,
|
Status Read(uint64_t offset, size_t n, Slice* result,
|
||||||
char* scratch) const {
|
char* scratch) const override {
|
||||||
if (offset >= contents_.size()) {
|
if (offset >= contents_.size()) {
|
||||||
return Status::InvalidArgument("invalid Read offset");
|
return Status::InvalidArgument("invalid Read offset");
|
||||||
}
|
}
|
||||||
|
@ -20,24 +20,24 @@ class TwoLevelIterator : public Iterator {
|
|||||||
TwoLevelIterator(Iterator* index_iter, BlockFunction block_function,
|
TwoLevelIterator(Iterator* index_iter, BlockFunction block_function,
|
||||||
void* arg, const ReadOptions& options);
|
void* arg, const ReadOptions& options);
|
||||||
|
|
||||||
virtual ~TwoLevelIterator();
|
~TwoLevelIterator() override;
|
||||||
|
|
||||||
virtual void Seek(const Slice& target);
|
void Seek(const Slice& target) override;
|
||||||
virtual void SeekToFirst();
|
void SeekToFirst() override;
|
||||||
virtual void SeekToLast();
|
void SeekToLast() override;
|
||||||
virtual void Next();
|
void Next() override;
|
||||||
virtual void Prev();
|
void Prev() override;
|
||||||
|
|
||||||
virtual bool Valid() const { return data_iter_.Valid(); }
|
bool Valid() const override { return data_iter_.Valid(); }
|
||||||
virtual Slice key() const {
|
Slice key() const override {
|
||||||
assert(Valid());
|
assert(Valid());
|
||||||
return data_iter_.key();
|
return data_iter_.key();
|
||||||
}
|
}
|
||||||
virtual Slice value() const {
|
Slice value() const override {
|
||||||
assert(Valid());
|
assert(Valid());
|
||||||
return data_iter_.value();
|
return data_iter_.value();
|
||||||
}
|
}
|
||||||
virtual Status status() const {
|
Status status() const override {
|
||||||
// It'd be nice if status() returned a const Status& instead of a Status
|
// It'd be nice if status() returned a const Status& instead of a Status
|
||||||
if (!index_iter_.status().ok()) {
|
if (!index_iter_.status().ok()) {
|
||||||
return index_iter_.status();
|
return index_iter_.status();
|
||||||
|
@ -23,9 +23,9 @@ class BloomFilterPolicy : public FilterPolicy {
|
|||||||
if (k_ > 30) k_ = 30;
|
if (k_ > 30) k_ = 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const char* Name() const { return "leveldb.BuiltinBloomFilter2"; }
|
const char* Name() const override { return "leveldb.BuiltinBloomFilter2"; }
|
||||||
|
|
||||||
virtual void CreateFilter(const Slice* keys, int n, std::string* dst) const {
|
void CreateFilter(const Slice* keys, int n, std::string* dst) const override {
|
||||||
// Compute bloom filter size (in both bits and bytes)
|
// Compute bloom filter size (in both bits and bytes)
|
||||||
size_t bits = n * bits_per_key_;
|
size_t bits = n * bits_per_key_;
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ class BloomFilterPolicy : public FilterPolicy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool KeyMayMatch(const Slice& key, const Slice& bloom_filter) const {
|
bool KeyMayMatch(const Slice& key, const Slice& bloom_filter) const override {
|
||||||
const size_t len = bloom_filter.size();
|
const size_t len = bloom_filter.size();
|
||||||
if (len < 2) return false;
|
if (len < 2) return false;
|
||||||
|
|
||||||
|
@ -354,37 +354,37 @@ class ShardedLRUCache : public Cache {
|
|||||||
shard_[s].SetCapacity(per_shard);
|
shard_[s].SetCapacity(per_shard);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual ~ShardedLRUCache() {}
|
~ShardedLRUCache() override {}
|
||||||
virtual Handle* Insert(const Slice& key, void* value, size_t charge,
|
Handle* Insert(const Slice& key, void* value, size_t charge,
|
||||||
void (*deleter)(const Slice& key, void* value)) {
|
void (*deleter)(const Slice& key, void* value)) override {
|
||||||
const uint32_t hash = HashSlice(key);
|
const uint32_t hash = HashSlice(key);
|
||||||
return shard_[Shard(hash)].Insert(key, hash, value, charge, deleter);
|
return shard_[Shard(hash)].Insert(key, hash, value, charge, deleter);
|
||||||
}
|
}
|
||||||
virtual Handle* Lookup(const Slice& key) {
|
Handle* Lookup(const Slice& key) override {
|
||||||
const uint32_t hash = HashSlice(key);
|
const uint32_t hash = HashSlice(key);
|
||||||
return shard_[Shard(hash)].Lookup(key, hash);
|
return shard_[Shard(hash)].Lookup(key, hash);
|
||||||
}
|
}
|
||||||
virtual void Release(Handle* handle) {
|
void Release(Handle* handle) override {
|
||||||
LRUHandle* h = reinterpret_cast<LRUHandle*>(handle);
|
LRUHandle* h = reinterpret_cast<LRUHandle*>(handle);
|
||||||
shard_[Shard(h->hash)].Release(handle);
|
shard_[Shard(h->hash)].Release(handle);
|
||||||
}
|
}
|
||||||
virtual void Erase(const Slice& key) {
|
void Erase(const Slice& key) override {
|
||||||
const uint32_t hash = HashSlice(key);
|
const uint32_t hash = HashSlice(key);
|
||||||
shard_[Shard(hash)].Erase(key, hash);
|
shard_[Shard(hash)].Erase(key, hash);
|
||||||
}
|
}
|
||||||
virtual void* Value(Handle* handle) {
|
void* Value(Handle* handle) override {
|
||||||
return reinterpret_cast<LRUHandle*>(handle)->value;
|
return reinterpret_cast<LRUHandle*>(handle)->value;
|
||||||
}
|
}
|
||||||
virtual uint64_t NewId() {
|
uint64_t NewId() override {
|
||||||
MutexLock l(&id_mutex_);
|
MutexLock l(&id_mutex_);
|
||||||
return ++(last_id_);
|
return ++(last_id_);
|
||||||
}
|
}
|
||||||
virtual void Prune() {
|
void Prune() override {
|
||||||
for (int s = 0; s < kNumShards; s++) {
|
for (int s = 0; s < kNumShards; s++) {
|
||||||
shard_[s].Prune();
|
shard_[s].Prune();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual size_t TotalCharge() const {
|
size_t TotalCharge() const override {
|
||||||
size_t total = 0;
|
size_t total = 0;
|
||||||
for (int s = 0; s < kNumShards; s++) {
|
for (int s = 0; s < kNumShards; s++) {
|
||||||
total += shard_[s].TotalCharge();
|
total += shard_[s].TotalCharge();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user