diff options
| author | Marcos Magueta <maguetamarcos@gmail.com> | 2026-05-13 01:59:22 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-13 01:59:22 -0300 |
| commit | af6073dedffd1a16aff7a283ded50545dc40b179 (patch) | |
| tree | a4b8fbfb4842f5ac27bf7fa641555de3fac6b7f3 /include/IStorageBackend.h | |
| parent | c1b70cfe745d935bded3053fba8c1f9573aa07aa (diff) | |
| download | RNT-af6073dedffd1a16aff7a283ded50545dc40b179.tar.gz RNT-af6073dedffd1a16aff7a283ded50545dc40b179.zip | |
Extern handles for embedded runtime
Diffstat (limited to 'include/IStorageBackend.h')
| -rw-r--r-- | include/IStorageBackend.h | 51 |
1 files changed, 13 insertions, 38 deletions
diff --git a/include/IStorageBackend.h b/include/IStorageBackend.h index 884af2d..e408c95 100644 --- a/include/IStorageBackend.h +++ b/include/IStorageBackend.h @@ -7,27 +7,27 @@ /** * @file IStorageBackend.h - * @brief Abstract KV storage backend consumed by CursorManager. + * @brief Abstract KV storage backend consumed by CursorManager and Merkle. * * Storage is strictly content-addressed: every value is stored under its - * SHA256 hex digest. This mirrors the Sakura physical layer in which the - * key is always `Sha256.to_hex (Sha256.string serialized_bytes)` and the - * value is the raw serialized bytes. - * - * Relation membership (which tuple hashes belong to a given relation) is - * tracked via a separate index managed by LinkTuple / TupleHashes. This - * corresponds to Sakura's B+ tree of tuple hashes stored under each relation. + * SHA256 hex digest. Relation membership (which tuple hashes belong to a + * given relation) is now tracked via the Merkle B-tree maintained by the + * Merkle class, not by this interface. Only Put and Get are required. */ namespace nt { /** * @interface IStorageBackend - * @brief Contract between CursorManager and a physical (or mock) storage engine. + * @brief Contract between CursorManager / Merkle and a physical storage engine. + * + * Two primitives are sufficient: + * - Put: store bytes, get back the content-address (SHA256 hex). + * - Get: retrieve bytes by content-address. * - * Storage is strictly content-addressed: every value lives under its own - * SHA256 digest. Relation membership is tracked separately via - * LinkTuple / TupleHashes, mirroring Sakura's per-relation B+ tree. + * Both are idempotent. The Merkle class stores node blobs via Put/Get and + * maintains insertion-order-independent relation membership on top of these + * two primitives. */ class IStorageBackend { @@ -38,7 +38,7 @@ namespace nt * @brief Stores a serialized value and returns its SHA256 hex hash. * * Idempotent: storing the same bytes twice does not create a duplicate. - * The hash is the only valid key for subsequent Get calls. + * The returned hash is the only valid key for subsequent Get calls. */ virtual std::string Put(std::vector<uint8_t> value) = 0; @@ -47,30 +47,5 @@ namespace nt * @return The stored bytes, or std::nullopt when the hash is unknown. */ virtual std::optional<std::vector<uint8_t>> Get(const std::string& hash) = 0; - - /** - * @brief Records that a tuple (by hash) belongs to a relation (by path). - * - * Idempotent. Corresponds to appending a tuple hash to a relation's - * B+ tree in Sakura's physical layer. - */ - virtual void LinkTuple(const std::vector<std::string>& relation_path, - const std::string& tuple_hash) = 0; - - /** - * @brief Returns a page of tuple hashes for a relation. - * - * Pagination is tuple-level: @p offset and @p limit count whole tuples. - * Hashes are returned in insertion order. - * - * @param relation_path Logical relation path. - * @param offset Zero-based index of the first tuple to return. - * @param limit Maximum number of tuple hashes to return. - * @return Ordered list of SHA256 hex hashes. Empty when past the end. - */ - virtual std::vector<std::string> TupleHashes( - const std::vector<std::string>& relation_path, - std::size_t offset, - std::size_t limit) = 0; }; } |
