diff options
| author | Estevan Castilho <tevo@riajuu.net> | 2026-06-22 23:07:12 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-06-22 20:07:12 -0300 |
| commit | 9f0e1c642680c69e10eb1760be07984f9ecc6d39 (patch) | |
| tree | 7846831cdab248b8c27706e3ab67296c7100786c /src/RNT_C_API.cpp | |
| parent | a4f6637601548a7158869ad155f29db50b151823 (diff) | |
| download | RNT-9f0e1c642680c69e10eb1760be07984f9ecc6d39.tar.gz RNT-9f0e1c642680c69e10eb1760be07984f9ecc6d39.zip | |
Fix joins, rename, union
Co-authored-by: Marcos Magueta <maguetamarcos@gmail.com>
Diffstat (limited to 'src/RNT_C_API.cpp')
| -rw-r--r-- | src/RNT_C_API.cpp | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/src/RNT_C_API.cpp b/src/RNT_C_API.cpp index abd683c..a632ab9 100644 --- a/src/RNT_C_API.cpp +++ b/src/RNT_C_API.cpp @@ -503,6 +503,10 @@ namespace { node->left = l->root; node->right = r->root; + if (a.attrs) + for (const char** p = a.attrs; *p; ++p) + node->join_attrs.emplace(*p); + auto* pw = new PlanWrapper(); pw->root = node.get(); pw->nodes.push_back(std::move(node)); @@ -577,6 +581,85 @@ namespace { delete s; return pw; } + + PlanWrapper* build_materialize(const PlanArgsMaterialize& a) { + auto* s = static_cast<PlanWrapper*>(a.source); + if (!s) + return nullptr; + + auto node = std::make_unique<nt::PlanNode>(); + node->op = nt::FOL_OPERATION_MATERIALIZE; + node->left = s->root; + + auto* pw = new PlanWrapper(); + pw->root = node.get(); + pw->nodes.push_back(std::move(node)); + for (auto& n : s->nodes) + pw->nodes.push_back(std::move(n)); + for (auto* c : s->cursors) + pw->cursors.push_back(c); + for (auto* h : s->handles) + pw->handles.push_back(h); + + delete s; + return pw; + } + + PlanWrapper* build_rename(const PlanArgsRename& a) { + auto* s = static_cast<PlanWrapper*>(a.source); + if (!s) + return nullptr; + + auto node = std::make_unique<nt::PlanNode>(); + node->op = nt::FOL_OPERATION_RENAME; + node->upstream = s->root; + + for (const char** k = a.pairs; *k; k++) + node->attrs[*k] = *++k; + + auto* pw = new PlanWrapper(); + pw->root = node.get(); + pw->nodes.push_back(std::move(node)); + + for (auto& n : s->nodes) + pw->nodes.push_back(std::move(n)); + for (auto* c : s->cursors) + pw->cursors.push_back(c); + for (auto* h : s->handles) + pw->handles.push_back(h); + + delete s; + return pw; + } + + PlanWrapper* build_union(const PlanArgsUnion& a) { + if (!*a.sources) + return nullptr; + + auto node = std::make_unique<nt::PlanNode>(); + node->op = nt::FOL_OPERATION_UNION; + + auto* pw = new PlanWrapper(); + for (auto* s = a.sources; *s; s++) { + auto* source = static_cast<PlanWrapper*>(*s); + + node->nodes.push_back(source->root); + + for (auto& n : source->nodes) + pw->nodes.push_back(std::move(n)); + for (auto* c : source->cursors) + pw->cursors.push_back(std::move(c)); + for (auto* h : source->handles) + pw->handles.push_back(std::move(h)); + + delete source; + } + + pw->root = node.get(); + pw->nodes.push_back(std::move(node)); + + return pw; + } } // namespace // --------------------------------------------------------------------------- @@ -1019,6 +1102,12 @@ rnt_plan_t rnt_plan_assemble(PlanAction action) { return build_take(action.take); case nt::FOL_OPERATION_PROJECT: return build_project(action.project); + case nt::FOL_OPERATION_MATERIALIZE: + return build_materialize(action.materialize); + case nt::FOL_OPERATION_RENAME: + return build_rename(action.rename); + case nt::FOL_OPERATION_UNION: + return build_union(action.union_); } return nullptr; |
