Declare all DB methods virtual so that StackableDB can override them

main
Igor Canadi 11 years ago
parent d69dc64be7
commit db1854d78c
  1. 45
      include/rocksdb/db.h

@ -164,8 +164,8 @@ class DB {
virtual Status Put(const WriteOptions& options, virtual Status Put(const WriteOptions& options,
ColumnFamilyHandle* column_family, const Slice& key, ColumnFamilyHandle* column_family, const Slice& key,
const Slice& value) = 0; const Slice& value) = 0;
Status Put(const WriteOptions& options, const Slice& key, virtual Status Put(const WriteOptions& options, const Slice& key,
const Slice& value) { const Slice& value) {
return Put(options, DefaultColumnFamily(), key, value); return Put(options, DefaultColumnFamily(), key, value);
} }
@ -176,7 +176,7 @@ class DB {
virtual Status Delete(const WriteOptions& options, virtual Status Delete(const WriteOptions& options,
ColumnFamilyHandle* column_family, ColumnFamilyHandle* column_family,
const Slice& key) = 0; const Slice& key) = 0;
Status Delete(const WriteOptions& options, const Slice& key) { virtual Status Delete(const WriteOptions& options, const Slice& key) {
return Delete(options, DefaultColumnFamily(), key); return Delete(options, DefaultColumnFamily(), key);
} }
@ -187,8 +187,8 @@ class DB {
virtual Status Merge(const WriteOptions& options, virtual Status Merge(const WriteOptions& options,
ColumnFamilyHandle* column_family, const Slice& key, ColumnFamilyHandle* column_family, const Slice& key,
const Slice& value) = 0; const Slice& value) = 0;
Status Merge(const WriteOptions& options, const Slice& key, virtual Status Merge(const WriteOptions& options, const Slice& key,
const Slice& value) { const Slice& value) {
return Merge(options, DefaultColumnFamily(), key, value); return Merge(options, DefaultColumnFamily(), key, value);
} }
@ -207,7 +207,7 @@ class DB {
virtual Status Get(const ReadOptions& options, virtual Status Get(const ReadOptions& options,
ColumnFamilyHandle* column_family, const Slice& key, ColumnFamilyHandle* column_family, const Slice& key,
std::string* value) = 0; std::string* value) = 0;
Status Get(const ReadOptions& options, const Slice& key, std::string* value) { virtual Status Get(const ReadOptions& options, const Slice& key, std::string* value) {
return Get(options, DefaultColumnFamily(), key, value); return Get(options, DefaultColumnFamily(), key, value);
} }
@ -225,9 +225,9 @@ class DB {
const ReadOptions& options, const ReadOptions& options,
const std::vector<ColumnFamilyHandle*>& column_family, const std::vector<ColumnFamilyHandle*>& column_family,
const std::vector<Slice>& keys, std::vector<std::string>* values) = 0; const std::vector<Slice>& keys, std::vector<std::string>* values) = 0;
std::vector<Status> MultiGet(const ReadOptions& options, virtual std::vector<Status> MultiGet(const ReadOptions& options,
const std::vector<Slice>& keys, const std::vector<Slice>& keys,
std::vector<std::string>* values) { std::vector<std::string>* values) {
return MultiGet(options, std::vector<ColumnFamilyHandle*>( return MultiGet(options, std::vector<ColumnFamilyHandle*>(
keys.size(), DefaultColumnFamily()), keys.size(), DefaultColumnFamily()),
keys, values); keys, values);
@ -248,8 +248,8 @@ class DB {
} }
return true; return true;
} }
bool KeyMayExist(const ReadOptions& options, const Slice& key, virtual bool KeyMayExist(const ReadOptions& options, const Slice& key,
std::string* value, bool* value_found = nullptr) { std::string* value, bool* value_found = nullptr) {
return KeyMayExist(options, DefaultColumnFamily(), key, value, value_found); return KeyMayExist(options, DefaultColumnFamily(), key, value, value_found);
} }
@ -261,7 +261,7 @@ class DB {
// The returned iterator should be deleted before this db is deleted. // The returned iterator should be deleted before this db is deleted.
virtual Iterator* NewIterator(const ReadOptions& options, virtual Iterator* NewIterator(const ReadOptions& options,
ColumnFamilyHandle* column_family) = 0; ColumnFamilyHandle* column_family) = 0;
Iterator* NewIterator(const ReadOptions& options) { virtual Iterator* NewIterator(const ReadOptions& options) {
return NewIterator(options, DefaultColumnFamily()); return NewIterator(options, DefaultColumnFamily());
} }
// Returns iterators from a consistent database state across multiple // Returns iterators from a consistent database state across multiple
@ -301,7 +301,7 @@ class DB {
// of the sstables that make up the db contents. // of the sstables that make up the db contents.
virtual bool GetProperty(ColumnFamilyHandle* column_family, virtual bool GetProperty(ColumnFamilyHandle* column_family,
const Slice& property, std::string* value) = 0; const Slice& property, std::string* value) = 0;
bool GetProperty(const Slice& property, std::string* value) { virtual bool GetProperty(const Slice& property, std::string* value) {
return GetProperty(DefaultColumnFamily(), property, value); return GetProperty(DefaultColumnFamily(), property, value);
} }
@ -316,7 +316,7 @@ class DB {
virtual void GetApproximateSizes(ColumnFamilyHandle* column_family, virtual void GetApproximateSizes(ColumnFamilyHandle* column_family,
const Range* range, int n, const Range* range, int n,
uint64_t* sizes) = 0; uint64_t* sizes) = 0;
void GetApproximateSizes(const Range* range, int n, uint64_t* sizes) { virtual void GetApproximateSizes(const Range* range, int n, uint64_t* sizes) {
GetApproximateSizes(DefaultColumnFamily(), range, n, sizes); GetApproximateSizes(DefaultColumnFamily(), range, n, sizes);
} }
@ -341,26 +341,27 @@ class DB {
const Slice* begin, const Slice* end, const Slice* begin, const Slice* end,
bool reduce_level = false, bool reduce_level = false,
int target_level = -1) = 0; int target_level = -1) = 0;
Status CompactRange(const Slice* begin, const Slice* end, virtual Status CompactRange(const Slice* begin, const Slice* end,
bool reduce_level = false, int target_level = -1) { bool reduce_level = false,
int target_level = -1) {
return CompactRange(DefaultColumnFamily(), begin, end, reduce_level, return CompactRange(DefaultColumnFamily(), begin, end, reduce_level,
target_level); target_level);
} }
// Number of levels used for this DB. // Number of levels used for this DB.
virtual int NumberLevels(ColumnFamilyHandle* column_family) = 0; virtual int NumberLevels(ColumnFamilyHandle* column_family) = 0;
int NumberLevels() { return NumberLevels(DefaultColumnFamily()); } virtual int NumberLevels() { return NumberLevels(DefaultColumnFamily()); }
// Maximum level to which a new compacted memtable is pushed if it // Maximum level to which a new compacted memtable is pushed if it
// does not create overlap. // does not create overlap.
virtual int MaxMemCompactionLevel(ColumnFamilyHandle* column_family) = 0; virtual int MaxMemCompactionLevel(ColumnFamilyHandle* column_family) = 0;
int MaxMemCompactionLevel() { virtual int MaxMemCompactionLevel() {
return MaxMemCompactionLevel(DefaultColumnFamily()); return MaxMemCompactionLevel(DefaultColumnFamily());
} }
// Number of files in level-0 that would stop writes. // Number of files in level-0 that would stop writes.
virtual int Level0StopWriteTrigger(ColumnFamilyHandle* column_family) = 0; virtual int Level0StopWriteTrigger(ColumnFamilyHandle* column_family) = 0;
int Level0StopWriteTrigger() { virtual int Level0StopWriteTrigger() {
return Level0StopWriteTrigger(DefaultColumnFamily()); return Level0StopWriteTrigger(DefaultColumnFamily());
} }
@ -374,14 +375,14 @@ class DB {
// Get DB Options that we use // Get DB Options that we use
virtual const Options& GetOptions(ColumnFamilyHandle* column_family) virtual const Options& GetOptions(ColumnFamilyHandle* column_family)
const = 0; const = 0;
const Options& GetOptions() const { virtual const Options& GetOptions() const {
return GetOptions(DefaultColumnFamily()); return GetOptions(DefaultColumnFamily());
} }
// Flush all mem-table data. // Flush all mem-table data.
virtual Status Flush(const FlushOptions& options, virtual Status Flush(const FlushOptions& options,
ColumnFamilyHandle* column_family) = 0; ColumnFamilyHandle* column_family) = 0;
Status Flush(const FlushOptions& options) { virtual Status Flush(const FlushOptions& options) {
return Flush(options, DefaultColumnFamily()); return Flush(options, DefaultColumnFamily());
} }
@ -466,7 +467,7 @@ class DB {
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
virtual Status GetPropertiesOfAllTables(ColumnFamilyHandle* column_family, virtual Status GetPropertiesOfAllTables(ColumnFamilyHandle* column_family,
TablePropertiesCollection* props) = 0; TablePropertiesCollection* props) = 0;
Status GetPropertiesOfAllTables(TablePropertiesCollection* props) { virtual Status GetPropertiesOfAllTables(TablePropertiesCollection* props) {
return GetPropertiesOfAllTables(DefaultColumnFamily(), props); return GetPropertiesOfAllTables(DefaultColumnFamily(), props);
} }
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE

Loading…
Cancel
Save