Kagome
Polkadot Runtime Engine in C++17
kagome::storage::RocksDB Class Reference

#include <rocksdb.hpp>

Inheritance diagram for kagome::storage::RocksDB:
Collaboration diagram for kagome::storage::RocksDB:

Classes

class  Batch
 

Public Member Functions

 ~RocksDB () override
 
std::unique_ptr< BufferBatchbatch () override
 Creates new Write Batch - an object, which can be used to efficiently write bulk data. More...
 
size_t size () const override
 
std::unique_ptr< Cursorcursor () override
 Returns new key-value iterator. More...
 
outcome::result< bool > contains (const Key &key) const override
 Checks if given key-value binding exists in the storage. More...
 
bool empty () const override
 Returns true if the storage is empty. More...
 
outcome::result< kagome::storage::Bufferload (const Key &key) const override
 Load value by key. More...
 
outcome::result< std::optional< Buffer > > tryLoad (const Key &key) const override
 Load value by key. More...
 
outcome::result< void > put (const BufferView &key, const Buffer &value) override
 
outcome::result< void > put (const BufferView &key, Buffer &&value) override
 
outcome::result< void > remove (const BufferView &key) override
 
void compact (const Buffer &first, const Buffer &last)
 
- Public Member Functions inherited from kagome::storage::face::Iterable< K, V, KView >
virtual ~Iterable ()=default
 
- Public Member Functions inherited from kagome::storage::face::ReadableStorage< KView, V >
virtual ~ReadableStorage ()=default
 
- Public Member Functions inherited from kagome::storage::face::ReadableBase< KView >
virtual ~ReadableBase ()=default
 
- Public Member Functions inherited from kagome::storage::face::Writeable< KView, V >
virtual ~Writeable ()=default
 
virtual outcome::result< void > put (const KView &key, const V &value)=0
 Store value by key. More...
 
virtual outcome::result< void > put (const KView &key, V &&value)=0
 
virtual outcome::result< void > remove (const KView &key)=0
 Remove value by key. More...
 
- Public Member Functions inherited from kagome::storage::face::BatchWriteable< KView, V >
virtual ~BatchWriteable ()=default
 

Static Public Member Functions

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. More...
 

Private Member Functions

 RocksDB (bool prevent_destruction)
 

Private Attributes

bool prevent_destruction_ = false
 
std::unique_ptr< rocksdb::DB > db_
 
rocksdb::ReadOptions ro_
 
rocksdb::WriteOptions wo_
 
log::Logger logger_
 

Additional Inherited Members

- Public Types inherited from kagome::storage::face::Iterable< K, V, KView >
using Cursor = MapCursor< K, V, KView >
 
- Public Types inherited from kagome::storage::face::ReadableStorage< KView, V >
using Key = KView
 
using Value = V
 
- Public Types inherited from kagome::storage::face::ReadableBase< KView >
using Key = KView
 

Detailed Description

Definition at line 17 of file rocksdb.hpp.

Constructor & Destructor Documentation

kagome::storage::RocksDB::~RocksDB ( )
override

Definition at line 24 of file rocksdb.cpp.

kagome::storage::RocksDB::RocksDB ( bool  prevent_destruction)
private

Definition at line 19 of file rocksdb.cpp.

Member Function Documentation

std::unique_ptr< BufferBatch > kagome::storage::RocksDB::batch ( )
overridevirtual

Creates new Write Batch - an object, which can be used to efficiently write bulk data.

Implements kagome::storage::face::BatchWriteable< KView, V >.

Definition at line 79 of file rocksdb.cpp.

void kagome::storage::RocksDB::compact ( const Buffer first,
const Buffer last 
)

Definition at line 179 of file rocksdb.cpp.

outcome::result< bool > kagome::storage::RocksDB::contains ( const Key key) const
overridevirtual

Checks if given key-value binding exists in the storage.

Parameters
keyK
Returns
true if key has value, false if does not, or error at .

Implements kagome::storage::face::ReadableBase< KView >.

Definition at line 106 of file rocksdb.cpp.

outcome::result< std::unique_ptr< RocksDB > > kagome::storage::RocksDB::create ( const boost::filesystem::path &  path,
rocksdb::Options  options = rocksdb::Options(),
bool  prevent_destruction = false 
)
static

Factory method to create an instance of RocksDB class.

Parameters
pathfilesystem path where database is going to be
optionsrocksdb options, such as caching, logging, etc.
prevent_destruction- avoid destruction of underlying db if true
Returns
instance of RocksDB

Definition at line 37 of file rocksdb.cpp.

std::unique_ptr< RocksDB::Cursor > kagome::storage::RocksDB::cursor ( )
overridevirtual

Returns new key-value iterator.

Returns
kv iterator

Implements kagome::storage::face::Iterable< K, V, KView >.

Definition at line 101 of file rocksdb.cpp.

bool kagome::storage::RocksDB::empty ( ) const
overridevirtual

Returns true if the storage is empty.

Implements kagome::storage::face::ReadableBase< KView >.

Definition at line 120 of file rocksdb.cpp.

outcome::result< Buffer > kagome::storage::RocksDB::load ( const Key key) const
overridevirtual

Load value by key.

Parameters
keyK
Returns
V

Implements kagome::storage::face::ReadableStorage< KView, V >.

Definition at line 126 of file rocksdb.cpp.

outcome::result< void > kagome::storage::RocksDB::put ( const BufferView key,
const Buffer value 
)
override

Definition at line 155 of file rocksdb.cpp.

outcome::result< void > kagome::storage::RocksDB::put ( const BufferView key,
Buffer &&  value 
)
override

Definition at line 165 of file rocksdb.cpp.

outcome::result< void > kagome::storage::RocksDB::remove ( const BufferView key)
override

Definition at line 170 of file rocksdb.cpp.

size_t kagome::storage::RocksDB::size ( ) const
overridevirtual

Reports RAM state size

Returns
size in bytes

Implements kagome::storage::face::GenericStorage< K, V, KView >.

Definition at line 83 of file rocksdb.cpp.

outcome::result< std::optional< Buffer > > kagome::storage::RocksDB::tryLoad ( const Key key) const
overridevirtual

Load value by key.

Parameters
keyK
Returns
V if contains(K) or std::nullopt

Implements kagome::storage::face::ReadableStorage< KView, V >.

Definition at line 138 of file rocksdb.cpp.

Member Data Documentation

std::unique_ptr<rocksdb::DB> kagome::storage::RocksDB::db_
private

Definition at line 65 of file rocksdb.hpp.

log::Logger kagome::storage::RocksDB::logger_
private

Definition at line 68 of file rocksdb.hpp.

bool kagome::storage::RocksDB::prevent_destruction_ = false
private

Definition at line 63 of file rocksdb.hpp.

rocksdb::ReadOptions kagome::storage::RocksDB::ro_
private

Definition at line 66 of file rocksdb.hpp.

rocksdb::WriteOptions kagome::storage::RocksDB::wo_
private

Definition at line 67 of file rocksdb.hpp.


The documentation for this class was generated from the following files: