sgns::storage::rocksdb¶
An implementation of PersistentBufferMap interface, which uses rocksdb as underlying storage.
#include <rocksdb.hpp>
Inherits from sgns::storage::face::GenericStorage< Buffer, Buffer >, sgns::storage::face::ReadOnlyMap< K, V >, sgns::storage::face::BatchWriteMap< K, V >, IComponent, sgns::storage::face::Iterable< K, V >, sgns::storage::face::Readable< K, V >, sgns::storage::face::Writeable< K, V >, sgns::storage::face::Batchable< K, V >
Public Classes¶
| Name | |
|---|---|
| class | Batch Class that is used to implement efficient bulk (batch) modifications of the Map. |
| class | Cursor Instance of cursor can be used as bidirectional iterator over key-value bindings of the Map. |
Public Types¶
| Name | |
|---|---|
| using ::ROCKSDB_NAMESPACE::Iterator | Iterator |
| using ::ROCKSDB_NAMESPACE::Options | Options |
| using ::ROCKSDB_NAMESPACE::ReadOptions | ReadOptions |
| using ::ROCKSDB_NAMESPACE::WriteOptions | WriteOptions |
| using ::ROCKSDB_NAMESPACE::DB | DB |
| using ::ROCKSDB_NAMESPACE::Status | Status |
| using ::ROCKSDB_NAMESPACE::Slice | Slice |
| using std::map< Buffer, Buffer > | QueryResult |
| using std::pair< Buffer, Buffer > | KeyValuePair |
Public Functions¶
| Name | |
|---|---|
| ~rocksdb() override | |
| void | setReadOptions(ReadOptions ro) Set read options, which are used in. |
| void | setWriteOptions(WriteOptions wo) Set write options, which are used in. |
| virtual std::unique_ptr< BufferMapCursor > | cursor() override Returns new key-value iterator. |
| virtual std::unique_ptr< BufferBatch > | batch() override Creates new Write Batch - an object, which can be used to efficiently write bulk data. |
| virtual outcome::result< Buffer > | get(const Buffer & key) const override Get value by key. |
| outcome::result< QueryResult > | query(const Buffer & keyPrefix) const |
| outcome::result< QueryResult > | query(const std::string & prefix_base, const std::string & middle_part, const std::string & remainder_prefix) const Queries with a middle part that can be a wildcard, negated string or normal string. |
| virtual bool | contains(const Buffer & key) const override Returns true if given key-value binding exists in the storage. |
| virtual bool | empty() const override Returns true if the storage is empty. |
| virtual outcome::result< void > | put(const Buffer & key, const Buffer & value) override Store value by key. |
| outcome::result< void > | put(const Buffer & key, Buffer && value) override |
| virtual outcome::result< void > | remove(const Buffer & key) override Remove value by key. |
| virtual std::string | GetName() override |
| std::shared_ptr< DB > | getDB() const |
| std::vector< KeyValuePair > | GetAll() const Gets all key value pairs on rocksdb. |
| outcome::result< std::shared_ptr< rocksdb > > | create(std::string_view path, const Options & options =Options()) Factory method to create an instance of rocksdb class. |
| outcome::result< std::shared_ptr< rocksdb > > | create(const std::shared_ptr< DB > & db) Factory method to create an instance of rocksdb class. |
Additional inherited members¶
Public Functions inherited from IComponent
| Name | |
|---|---|
| virtual | ~IComponent() =default |
Public Functions inherited from sgns::storage::face::Iterable< K, V >
| Name | |
|---|---|
| virtual | ~Iterable() =default |
Public Functions inherited from sgns::storage::face::Readable< K, V >
| Name | |
|---|---|
| virtual | ~Readable() =default |
Public Functions inherited from sgns::storage::face::Writeable< K, V >
| Name | |
|---|---|
| virtual | ~Writeable() =default |
Public Functions inherited from sgns::storage::face::Batchable< K, V >
| Name | |
|---|---|
| virtual | ~Batchable() =default |
Public Types Documentation¶
using Iterator¶
using Options¶
using ReadOptions¶
using WriteOptions¶
using DB¶
using Status¶
using Slice¶
using QueryResult¶
using KeyValuePair¶
Public Functions Documentation¶
function ~rocksdb¶
function setReadOptions¶
Set read options, which are used in.
Parameters:
- ro options
See: rocksdb::get
function setWriteOptions¶
Set write options, which are used in.
Parameters:
- wo options
See: rocksdb::put
function cursor¶
Returns new key-value iterator.
Return: kv iterator
Reimplements: sgns::storage::face::Iterable::cursor
function batch¶
Creates new Write Batch - an object, which can be used to efficiently write bulk data.
Reimplements: sgns::storage::face::Batchable::batch
function get¶
Get value by key.
Parameters:
- key K
Return: V
Reimplements: sgns::storage::face::Readable::get
function query¶
function query¶
outcome::result< QueryResult > query(
const std::string & prefix_base,
const std::string & middle_part,
const std::string & remainder_prefix
) const
Queries with a middle part that can be a wildcard, negated string or normal string.
Parameters:
- prefix_base The base prefix to query
- middle_part Either a string (normal query), '*' or !string
- remainder_prefix The remainder part of the query prefix
Return: List of query results
function contains¶
Returns true if given key-value binding exists in the storage.
Parameters:
- key K
Return: true if key has value, false otherwise.
Reimplements: sgns::storage::face::Readable::contains
function empty¶
Returns true if the storage is empty.
Reimplements: sgns::storage::face::Readable::empty
function put¶
Store value by key.
Parameters:
- key key
- value value
Return: result containing void if put successful, error otherwise
Reimplements: sgns::storage::face::Writeable::put
function put¶
function remove¶
Remove value by key.
Parameters:
- key K
Return: error code if error happened
Reimplements: sgns::storage::face::Writeable::remove
function GetName¶
Reimplements: IComponent::GetName
function getDB¶
function GetAll¶
Gets all key value pairs on rocksdb.
function create¶
static outcome::result< std::shared_ptr< rocksdb > > create(
std::string_view path,
const Options & options =Options()
)
Factory method to create an instance of rocksdb class.
Parameters:
- path filesystem path where database is going to be
- options rocksdb options, such as caching, logging, etc.
Return: instance of rocksdb
function create¶
Factory method to create an instance of rocksdb class.
Parameters:
- db pointer to rocksdb database instance
Updated on 2026-03-04 at 13:10:44 -0800