2013-08-06 00:55:44 +00:00
|
|
|
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
|
|
|
|
2013-10-05 05:32:05 +00:00
|
|
|
#pragma once
|
2013-08-23 15:38:13 +00:00
|
|
|
#include "rocksdb/db.h"
|
2013-08-06 00:55:44 +00:00
|
|
|
|
2013-10-04 04:49:15 +00:00
|
|
|
namespace rocksdb {
|
2013-08-06 00:55:44 +00:00
|
|
|
|
|
|
|
// This class contains APIs to stack rocksdb wrappers.Eg. Stack TTL over base d
|
|
|
|
class StackableDB : public DB {
|
|
|
|
public:
|
2013-11-25 20:39:23 +00:00
|
|
|
// StackableDB is the owner of db now!
|
|
|
|
explicit StackableDB(DB* db) : db_(db) {}
|
2013-08-06 00:55:44 +00:00
|
|
|
|
2013-11-25 20:39:23 +00:00
|
|
|
~StackableDB() {
|
|
|
|
delete db_;
|
2013-08-06 00:55:44 +00:00
|
|
|
}
|
|
|
|
|
2013-11-25 20:39:23 +00:00
|
|
|
virtual DB* GetBaseDB() {
|
|
|
|
return db_;
|
2013-08-06 00:55:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual Status Put(const WriteOptions& options,
|
|
|
|
const Slice& key,
|
|
|
|
const Slice& val) override {
|
2013-11-25 20:39:23 +00:00
|
|
|
return db_->Put(options, key, val);
|
2013-08-06 00:55:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual Status Get(const ReadOptions& options,
|
|
|
|
const Slice& key,
|
|
|
|
std::string* value) override {
|
2013-11-25 20:39:23 +00:00
|
|
|
return db_->Get(options, key, value);
|
2013-08-06 00:55:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual std::vector<Status> MultiGet(const ReadOptions& options,
|
|
|
|
const std::vector<Slice>& keys,
|
|
|
|
std::vector<std::string>* values)
|
|
|
|
override {
|
2013-11-25 20:39:23 +00:00
|
|
|
return db_->MultiGet(options, keys, values);
|
2013-08-06 00:55:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool KeyMayExist(const ReadOptions& options,
|
|
|
|
const Slice& key,
|
|
|
|
std::string* value,
|
|
|
|
bool* value_found = nullptr) override {
|
2013-11-25 20:39:23 +00:00
|
|
|
return db_->KeyMayExist(options, key, value, value_found);
|
2013-08-06 00:55:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual Status Delete(const WriteOptions& wopts, const Slice& key) override {
|
2013-11-25 20:39:23 +00:00
|
|
|
return db_->Delete(wopts, key);
|
2013-08-06 00:55:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual Status Merge(const WriteOptions& options,
|
|
|
|
const Slice& key,
|
|
|
|
const Slice& value) override {
|
2013-11-25 20:39:23 +00:00
|
|
|
return db_->Merge(options, key, value);
|
2013-08-06 00:55:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virtual Status Write(const WriteOptions& opts, WriteBatch* updates)
|
|
|
|
override {
|
2013-11-25 20:39:23 +00:00
|
|
|
return db_->Write(opts, updates);
|
2013-08-06 00:55:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual Iterator* NewIterator(const ReadOptions& opts) override {
|
2013-11-25 20:39:23 +00:00
|
|
|
return db_->NewIterator(opts);
|
2013-08-06 00:55:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual const Snapshot* GetSnapshot() override {
|
2013-11-25 20:39:23 +00:00
|
|
|
return db_->GetSnapshot();
|
2013-08-06 00:55:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void ReleaseSnapshot(const Snapshot* snapshot) override {
|
2013-11-25 20:39:23 +00:00
|
|
|
return db_->ReleaseSnapshot(snapshot);
|
2013-08-06 00:55:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool GetProperty(const Slice& property, std::string* value)
|
|
|
|
override {
|
2013-11-25 20:39:23 +00:00
|
|
|
return db_->GetProperty(property, value);
|
2013-08-06 00:55:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void GetApproximateSizes(const Range* r, int n, uint64_t* sizes)
|
|
|
|
override {
|
2013-11-25 20:39:23 +00:00
|
|
|
return db_->GetApproximateSizes(r, n, sizes);
|
2013-08-06 00:55:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void CompactRange(const Slice* begin, const Slice* end,
|
2013-09-04 20:13:08 +00:00
|
|
|
bool reduce_level = false,
|
|
|
|
int target_level = -1) override {
|
2013-11-25 20:39:23 +00:00
|
|
|
return db_->CompactRange(begin, end, reduce_level, target_level);
|
2013-08-06 00:55:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual int NumberLevels() override {
|
2013-11-25 20:39:23 +00:00
|
|
|
return db_->NumberLevels();
|
2013-08-06 00:55:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual int MaxMemCompactionLevel() override {
|
2013-11-25 20:39:23 +00:00
|
|
|
return db_->MaxMemCompactionLevel();
|
2013-08-06 00:55:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual int Level0StopWriteTrigger() override {
|
2013-11-25 20:39:23 +00:00
|
|
|
return db_->Level0StopWriteTrigger();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual Env* GetEnv() const override {
|
|
|
|
return db_->GetEnv();
|
2013-08-06 00:55:44 +00:00
|
|
|
}
|
|
|
|
|
2013-11-25 23:51:50 +00:00
|
|
|
virtual const Options& GetOptions() const override {
|
|
|
|
return db_->GetOptions();
|
|
|
|
}
|
|
|
|
|
2013-08-06 00:55:44 +00:00
|
|
|
virtual Status Flush(const FlushOptions& fopts) override {
|
2013-11-25 20:39:23 +00:00
|
|
|
return db_->Flush(fopts);
|
2013-08-06 00:55:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual Status DisableFileDeletions() override {
|
2013-11-25 20:39:23 +00:00
|
|
|
return db_->DisableFileDeletions();
|
2013-08-06 00:55:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual Status EnableFileDeletions() override {
|
2013-11-25 20:39:23 +00:00
|
|
|
return db_->EnableFileDeletions();
|
2013-08-06 00:55:44 +00:00
|
|
|
}
|
|
|
|
|
2013-10-03 21:38:32 +00:00
|
|
|
virtual Status GetLiveFiles(std::vector<std::string>& vec, uint64_t* mfs,
|
|
|
|
bool flush_memtable = true) override {
|
2013-11-25 20:39:23 +00:00
|
|
|
return db_->GetLiveFiles(vec, mfs, flush_memtable);
|
2013-08-06 00:55:44 +00:00
|
|
|
}
|
|
|
|
|
2013-10-25 02:09:02 +00:00
|
|
|
virtual SequenceNumber GetLatestSequenceNumber() const override {
|
2013-11-25 20:39:23 +00:00
|
|
|
return db_->GetLatestSequenceNumber();
|
2013-08-06 00:55:44 +00:00
|
|
|
}
|
|
|
|
|
2013-08-06 19:54:37 +00:00
|
|
|
virtual Status GetSortedWalFiles(VectorLogPtr& files) override {
|
2013-11-25 20:39:23 +00:00
|
|
|
return db_->GetSortedWalFiles(files);
|
2013-08-06 19:54:37 +00:00
|
|
|
}
|
|
|
|
|
2013-10-24 06:39:23 +00:00
|
|
|
virtual Status DeleteFile(std::string name) override {
|
2013-11-25 20:39:23 +00:00
|
|
|
return db_->DeleteFile(name);
|
2013-08-06 19:54:37 +00:00
|
|
|
}
|
|
|
|
|
2013-12-05 18:16:39 +00:00
|
|
|
virtual Status GetDbIdentity(std::string& identity) {
|
|
|
|
return db_->GetDbIdentity(identity);
|
|
|
|
}
|
|
|
|
|
2013-08-06 00:55:44 +00:00
|
|
|
virtual Status GetUpdatesSince(SequenceNumber seq_number,
|
|
|
|
unique_ptr<TransactionLogIterator>* iter)
|
|
|
|
override {
|
2013-11-25 20:39:23 +00:00
|
|
|
return db_->GetUpdatesSince(seq_number, iter);
|
2013-08-06 00:55:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2013-11-25 20:39:23 +00:00
|
|
|
DB* db_;
|
2013-08-06 00:55:44 +00:00
|
|
|
};
|
|
|
|
|
2013-10-04 04:49:15 +00:00
|
|
|
} // namespace rocksdb
|