Relational NT
A relational database kernel shaped around NT-style object management.
Loading...
Searching...
No Matches
nt::PlanNode Struct Reference

A node in the Volcano operator tree executed by the Tarski (FOL) runtime. More...

#include <VM.h>

Public Attributes

Operation op
PlanNode * left = nullptr
PlanNode * right = nullptr
CursorManager::cursor * scan_cursor = nullptr
 SCAN: pre-opened cursor.
std::vector< PathArg > scan_args
 SCAN: argument template for parameterized relations.
std::size_t take_limit = 0
 TAKE: maximum number of tuples to emit before returning nullptr.
std::size_t take_count = 0
 Runtime counter; mutable during execution.
std::unordered_set< std::string > project_attrs
 PROJECT: unordered set of attribute names to keep.
std::optional< Tuple > project_buffer
Tuple * join_left = nullptr
 JOIN runtime state.
std::optional< Tuple > join_buffer
std::unordered_set< std::string > join_attrs
std::vector< Tuple > mat_buffer
 MATERIALIZE runtime state.
std::size_t mat_pos = 0
bool mat_done = false
PlanNode * upstream = nullptr
 RENAME runtime state.
std::unordered_map< std::string, std::string > attrs
std::vector< PlanNode * > nodes
 UNION runtime state.
std::vector< PlanNode * >::iterator current_node

Detailed Description

A node in the Volcano operator tree executed by the Tarski (FOL) runtime.

Each node represents one relational algebra operator. The tree is demand-driven: VM::Next() propagates pull requests from root to leaves.

Supported operators:

  • SCAN : pulls tuples from a pre-opened cursor (stored or ephemeral relation).
  • JOIN : nested-loop join. For each outer (left) tuple, resolves scan_args on the inner (right) SCAN, resets its cursor, and probes it. Works for both stored relations (full re-scan of inner) and ephemeral relations (O(1) membership probe when all args are bound).
  • TAKE : passes at most take_limit tuples through, then returns nullptr. Use this to bound scans over AlephZero ephemeral relations.
  • PROJECT: filters each input tuple to the named attributes in project_attrs.
  • MATERIALIZE: on its first scan it pulls the whole child and keeps a private copy of every tuple. On later scans it replays that copy and never reads the child again. Sits on the inner side of a nested-loop JOIN so the inner relation is read once instead of once per outer tuple. This only works when the child does not depend on the outer tuple, meaning it has no Var SCAN leaves that the JOIN binds, because the same cached tuples are handed back for every outer tuple. Rewind does not pass the outer tuple through this node, so it is up to the planner to place it only where the child is independent of the outer side.

Member Data Documentation

◆ join_left

Tuple* nt::PlanNode::join_left = nullptr

JOIN runtime state.

join_left holds the current outer tuple while probing the inner (right) side. The pointer is stable for the lifetime of one outer iteration because Next(left) is only called when join_left is reset to nullptr, which happens only after the inner side is exhausted.

join_buffer holds the merged output tuple and is overwritten on each successful join. Callers must consume the returned pointer before calling Next() again — same contract as a cursor page pointer.

◆ mat_buffer

std::vector<Tuple> nt::PlanNode::mat_buffer

MATERIALIZE runtime state.

mat_buffer holds owned copies of the child's tuples, filled on the first scan. mat_done marks the cache complete (child exhausted). mat_pos is the replay cursor, reset to 0 by Rewind on each later scan.

◆ scan_args

std::vector<PathArg> nt::PlanNode::scan_args

SCAN: argument template for parameterized relations.

Var entries are resolved from the outer JOIN tuple; Const entries are used as-is. The resolved values are written into scan_cursor->args by the JOIN before it calls Next() on this node.

◆ scan_cursor

CursorManager::cursor* nt::PlanNode::scan_cursor = nullptr

SCAN: pre-opened cursor.

For ephemeral relations the JOIN resets it (args, offset, exhausted flag) with resolved args before each probe, overwriting whatever standalone-scan state it opened with.


The documentation for this struct was generated from the following file: