Relational NT
A relational database kernel shaped around NT-style object management.
Loading...
Searching...
No Matches
nt::Merkle< Key > Class Template Reference

Classes

struct  Entry
 One (key, payload) pair returned by Page(). More...

Static Public Member Functions

static std::string Insert (IStorageBackend &store, const std::string &root_hex, const Key &key, const Hash32 &payload)
 Insert or overwrite a (key, payload) mapping.
static std::string Remove (IStorageBackend &store, const std::string &root_hex, const Key &key)
 Remove a key from the tree.
static std::optional< Hash32 > Get (IStorageBackend &store, const std::string &root_hex, const Key &key)
 Look up the payload for a key.
static std::vector< Entry > Page (IStorageBackend &store, const std::string &root_hex, size_t offset, size_t limit)
 Page through entries in key-sorted order.

Static Public Attributes

static constexpr size_t B = 64

Member Function Documentation

◆ Get()

template<typename Key>
std::optional< Hash32 > nt::Merkle< Key >::Get ( IStorageBackend & store,
const std::string & root_hex,
const Key & key )
static

Look up the payload for a key.

Returns
The payload when present, std::nullopt when absent.

◆ Insert()

template<typename Key>
std::string nt::Merkle< Key >::Insert ( IStorageBackend & store,
const std::string & root_hex,
const Key & key,
const Hash32 & payload )
static

Insert or overwrite a (key, payload) mapping.

Parameters
storeKV backend for node serialisation.
root_hexCurrent root hash (empty string = empty tree).
keyRouting/identity key.
payloadHash this key maps to (child root one level down, or the key itself at the relation level).
Returns
New root hash. Equal to root_hex when an insertion of an identical (key, payload) pair would be a no-op.

◆ Page()

template<typename Key>
std::vector< typename Merkle< Key >::Entry > nt::Merkle< Key >::Page ( IStorageBackend & store,
const std::string & root_hex,
size_t offset,
size_t limit )
static

Page through entries in key-sorted order.

Descends to the leaf at logical position offset using cumulative leaf_counts stored in internal nodes, then walks forward collecting at most limit entries. Only the nodes on the active path are loaded; sibling subtrees are never touched.

◆ Remove()

template<typename Key>
std::string nt::Merkle< Key >::Remove ( IStorageBackend & store,
const std::string & root_hex,
const Key & key )
static

Remove a key from the tree.

Returns
New root hash. Empty string when the tree becomes empty. Equal to root_hex when the key is absent.

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