6 #ifndef KAGOME_ROCKSDB_HPP 7 #define KAGOME_ROCKSDB_HPP 11 #include <rocksdb/db.h> 12 #include <boost/filesystem/path.hpp> 30 static outcome::result<std::unique_ptr<RocksDB>>
create(
31 const boost::filesystem::path &path,
32 rocksdb::Options options = rocksdb::Options(),
33 bool prevent_destruction =
false);
35 std::unique_ptr<BufferBatch>
batch()
override;
37 size_t size()
const override;
39 std::unique_ptr<Cursor>
cursor()
override;
41 outcome::result<bool>
contains(
const Key &key)
const override;
43 bool empty()
const override;
45 outcome::result<kagome::storage::Buffer>
load(
46 const Key &key)
const override;
48 outcome::result<std::optional<Buffer>>
tryLoad(
49 const Key &key)
const override;
52 const Buffer &value)
override;
56 outcome::result<void>
remove(
const BufferView &key)
override;
61 RocksDB(
bool prevent_destruction);
65 std::unique_ptr<rocksdb::DB>
db_;
66 rocksdb::ReadOptions
ro_;
67 rocksdb::WriteOptions
wo_;
72 #endif // KAGOME_ROCKSDB_HPP void compact(const Buffer &first, const Buffer &last)
Class represents arbitrary (including empty) byte buffer.
rocksdb::WriteOptions wo_
outcome::result< kagome::storage::Buffer > load(const Key &key) const override
Load value by key.
outcome::result< bool > contains(const Key &key) const override
Checks if given key-value binding exists in the storage.
std::unique_ptr< Cursor > cursor() override
Returns new key-value iterator.
outcome::result< std::optional< Buffer > > tryLoad(const Key &key) const override
Load value by key.
outcome::result< void > put(const BufferView &key, const Buffer &value) override
size_t size() const override
std::unique_ptr< rocksdb::DB > db_
std::shared_ptr< soralog::Logger > Logger
bool prevent_destruction_
std::unique_ptr< BufferBatch > batch() override
Creates new Write Batch - an object, which can be used to efficiently write bulk data.
bool empty() const override
Returns true if the storage is empty.
RocksDB(bool prevent_destruction)
static outcome::result< std::unique_ptr< RocksDB > > create(const boost::filesystem::path &path, rocksdb::Options options=rocksdb::Options(), bool prevent_destruction=false)
Factory method to create an instance of RocksDB class.