sgns::storage::trie::SuperGeniusTrieImpl¶
#include <supergenius_trie_impl.hpp>
Inherits from sgns::storage::trie::SuperGeniusTrie, sgns::storage::face::GenericMap< base::Buffer, base::Buffer >, sgns::storage::face::ReadOnlyMap< K, V >, sgns::storage::face::Writeable< K, V >, sgns::storage::face::Iterable< K, V >, sgns::storage::face::Readable< K, V >
Public Types¶
| Name | |
|---|---|
| enum class | Error |
| using std::function< outcome::result< NodePtr >(BranchPtr, uint8_t)> | ChildRetrieveFunctor |
Public Functions¶
| Name | |
|---|---|
| SuperGeniusTrieImpl(ChildRetrieveFunctor f =defaultChildRetrieveFunctor) =default | |
| SuperGeniusTrieImpl(NodePtr root, ChildRetrieveFunctor f =defaultChildRetrieveFunctor) =default | |
| virtual NodePtr | getRoot() const override |
| virtual outcome::result< NodePtr > | getNode(NodePtr parent, const KeyNibbles & key_nibbles) const override |
| virtual outcome::result< std::list< std::pair< BranchPtr, uint8_t > > > | getPath(NodePtr parent, const KeyNibbles & key_nibbles) const override |
| virtual outcome::result< void > | clearPrefix(const base::Buffer & prefix) override |
| virtual outcome::result< void > | put(const base::Buffer & key, const base::Buffer & value) override Store value by key. |
| outcome::result< void > | put(const base::Buffer & key, base::Buffer && value) override |
| virtual outcome::result< void > | remove(const base::Buffer & key) override Remove value by key. |
| virtual outcome::result< base::Buffer > | get(const base::Buffer & key) const override Get value by key. |
| virtual std::unique_ptr< BufferMapCursor > | cursor() override Returns new key-value iterator. |
| virtual bool | contains(const base::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. |
Additional inherited members¶
Public Types inherited from sgns::storage::trie::SuperGeniusTrie
| Name | |
|---|---|
| using std::shared_ptr< SuperGeniusNode > | NodePtr |
| using std::shared_ptr< BranchNode > | BranchPtr |
Public Functions inherited from sgns::storage::face::Writeable< K, V >
| Name | |
|---|---|
| virtual | ~Writeable() =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 Types Documentation¶
enum Error¶
| Enumerator | Value | Description |
|---|---|---|
| INVALID_NODE_TYPE | 1 |
using ChildRetrieveFunctor¶
using sgns::storage::trie::SuperGeniusTrieImpl::ChildRetrieveFunctor =
std::function<outcome::result<NodePtr>(BranchPtr, uint8_t)>;
Public Functions Documentation¶
function SuperGeniusTrieImpl¶
Parameters:
- f a functor that will be used to obtain a child of a branch node by its index. Most useful if Trie grows too big to occupy main memory and is stored on an external storage
Creates an empty Trie
function SuperGeniusTrieImpl¶
explicit SuperGeniusTrieImpl(
NodePtr root,
ChildRetrieveFunctor f =defaultChildRetrieveFunctor
) =default
function getRoot¶
Return: the root node of the trie
Reimplements: sgns::storage::trie::SuperGeniusTrie::getRoot
function getNode¶
virtual outcome::result< NodePtr > getNode(
NodePtr parent,
const KeyNibbles & key_nibbles
) const override
Return: a node which is a descendant of
- parent found by following
- key_nibbles
Reimplements: sgns::storage::trie::SuperGeniusTrie::getNode
function getPath¶
virtual outcome::result< std::list< std::pair< BranchPtr, uint8_t > > > getPath(
NodePtr parent,
const KeyNibbles & key_nibbles
) const override
Return: a sequence of nodes in between
- parent and the node found by following
- key_nibbles. The parent is included, the end node isn't.
Reimplements: sgns::storage::trie::SuperGeniusTrie::getPath
function clearPrefix¶
Reimplements: sgns::storage::trie::SuperGeniusTrie::clearPrefix
Remove all entries, which key starts with the prefix
function put¶
virtual outcome::result< void > put(
const base::Buffer & key,
const base::Buffer & value
) override
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 get¶
Get value by key.
Parameters:
- key K
Return: V
Reimplements: sgns::storage::face::Readable::get
function cursor¶
Returns new key-value iterator.
Return: kv iterator
Reimplements: sgns::storage::face::Iterable::cursor
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
Updated on 2026-04-15 at 11:00:39 -0700