aboutsummaryrefslogtreecommitdiffstats
path: root/src/RelationalNT.cpp
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-06-05 21:40:44 -0300
committerGitHub <noreply@github.com>2026-06-05 21:40:44 -0300
commit5174fc25698cff33b03b5746bf1742e417988f7d (patch)
tree232a3acdd9b458de481dbd5cbde889505168c8e8 /src/RelationalNT.cpp
parent85ed897de3676af866cc619dc700025820c02201 (diff)
downloadRNT-5174fc25698cff33b03b5746bf1742e417988f7d.tar.gz
RNT-5174fc25698cff33b03b5746bf1742e417988f7d.zip
Project C interface, reroute FOL plan enums & format
Diffstat (limited to 'src/RelationalNT.cpp')
-rw-r--r--src/RelationalNT.cpp52
1 files changed, 22 insertions, 30 deletions
diff --git a/src/RelationalNT.cpp b/src/RelationalNT.cpp
index b1302ee..f27179f 100644
--- a/src/RelationalNT.cpp
+++ b/src/RelationalNT.cpp
@@ -16,50 +16,46 @@
#include <iostream>
#endif
-namespace nt
-{
- bool NT::IsRunning() const
- {
+namespace nt {
+ bool NT::IsRunning() const {
return true;
}
- void NT::SimulateEntryCall()
- {
+ void NT::SimulateEntryCall() {
}
-}
+} // namespace nt
#ifdef NT_CONSOLE_APP
-int main()
-{
+int main() {
const nt::NT runtime;
std::cout << "RNT running: " << (runtime.IsRunning() ? "yes" : "no") << '\n';
// --- Mock: register villager in the object registry ---
nt::ObjectManager objects;
- std::unique_ptr<nt::ObjectManager::object_type> type = std::make_unique<nt::ObjectManager::object_type>();
+ std::unique_ptr<nt::ObjectManager::object_type> type =
+ std::make_unique<nt::ObjectManager::object_type>();
type->label = RELATION;
type->disposable = false;
- type->methods = { OPEN, CLOSE };
+ type->methods = {OPEN, CLOSE};
- const std::vector<std::string> path = { "multigroups", "sakura", "relations", "villager" };
+ const std::vector<std::string> path = {"multigroups", "sakura", "relations", "villager"};
objects.Register(path, std::make_unique<nt::ObjectManager::Relation>(), std::move(type));
- auto* villager_rel = dynamic_cast<nt::ObjectManager::Relation*>(
- objects.Find(path)->object.get());
+ auto* villager_rel =
+ dynamic_cast<nt::ObjectManager::Relation*>(objects.Find(path)->object.get());
// --- Populate backend with three tuples via the Merkle tree ---
nt::SqliteBackend backend;
auto store = [&](std::vector<nt::Attribute> attrs) {
auto bytes = nt::TupleCodec::Serialize(attrs);
- auto hash = backend.Put(std::move(bytes));
+ auto hash = backend.Put(std::move(bytes));
auto hash_bin = nt::hex_to_bin(hash);
villager_rel->merkle_root =
- nt::Merkle<nt::Hash32>::Insert(backend, villager_rel->merkle_root,
- hash_bin, hash_bin);
+ nt::Merkle<nt::Hash32>::Insert(backend, villager_rel->merkle_root, hash_bin, hash_bin);
};
- store({ { "name", "Blathers" }, { "profession", "Museum Curator" } });
- store({ { "name", "Rover" }, { "profession", "Traveller" } });
- store({ { "name", "K.K." }, { "profession", "Artist" } });
+ store({{"name", "Blathers"}, {"profession", "Museum Curator"}});
+ store({{"name", "Rover"}, {"profession", "Traveller"}});
+ store({{"name", "K.K."}, {"profession", "Artist"}});
nt::CursorManager cursors(backend);
// --- Open a handle on villager through the full manager pipeline ---
@@ -69,18 +65,16 @@ int main()
nt::NamespaceReferenceManager references(objects, backend);
nt::HandlerManager handler(objects, permissions, identities, lifecycles, references);
- int connection = 1; // dummy connection context
+ int connection = 1; // dummy connection context
nt::HandlerManager::handle* handle = handler.Open(path, &connection);
- if (handle == nullptr)
- {
+ if (handle == nullptr) {
std::cout << "Failed to open handle for villager\n";
return 1;
}
// --- Open a cursor on the relation ---
nt::CursorManager::cursor* cursor = cursors.Open(handle, villager_rel->merkle_root);
- if (cursor == nullptr)
- {
+ if (cursor == nullptr) {
std::cout << "Failed to open cursor for villager\n";
handler.Close(handle);
return 1;
@@ -88,17 +82,15 @@ int main()
// --- Build a SCAN plan and pull all tuples lazily through the FOL VM ---
nt::PlanNode plan;
- plan.op = nt::PlanNode::Op::SCAN;
+ plan.op = nt::FOL_OPERATION_SCAN;
plan.scan_cursor = cursor;
nt::VM vm(cursors);
std::cout << "Tuples in villager:\n";
- while (nt::Tuple* t = vm.Next(&plan))
- {
+ while (nt::Tuple* t = vm.Next(&plan)) {
std::cout << " ";
const nt::Attribute* attr = t->Next();
- while (attr != nullptr)
- {
+ while (attr != nullptr) {
std::cout << attr->name << "=" << attr->value;
attr = t->Next();
if (attr != nullptr)