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

Hosts the first-order logic (FOL) and second-order logic (SOL) cores. More...

#include <VM.h>

Public Member Functions

 VM (CursorManager &cursors)
Tuple * Next (PlanNode *node)
 Pulls the next tuple from the plan tree (Tarski/FOL core).

Detailed Description

Hosts the first-order logic (FOL) and second-order logic (SOL) cores.

This partitioning exists to ensure retrieval terminates when execution is constrained to first-order logic.

  • Tarski runtime (FOL): a relational engine that implements Tarski's relational calculus. It uses a deterministic Volcano-iterator model to perform relational algebra operations such as joins, projections, and selects directly against the CursorManager and a prepared plan.
  • Karuta runtime (SOL): an isolated WAM-based environment for higher-order logic programming. It handles recursion, choice points, and other programming constructs that do not guarantee termination.
Remarks
Lazy evaluation and paging strategy

Both the Tarski first-order engine and the Karuta second-order engine are strictly pull-based. Data is streamed lazily from the CursorManager to preserve a constant memory footprint regardless of relation size.

Pipeline dynamics:

  • Demand-driven: the Karuta WAM requests a fact only when a goal needs satisfaction. A request propagates down the algebra tree as a chain of Next() calls.
  • Short-circuiting: if the Karuta engine finds a solution or reaches a failure that invalidates a branch, the Tarski iterator is discarded or reset without materializing the remaining tuples.
  • Resource stewardship: by maintaining laziness up to the highest logical level, the runtime minimizes pressure on ObjectManager and keeps snapshots pinned through LifecycleManager::Monitor only for the minimum time required.

Member Function Documentation

◆ Next()

Tuple * nt::VM::Next ( PlanNode * node)

Pulls the next tuple from the plan tree (Tarski/FOL core).

Propagates a Next() call down the operator tree:

  • SCAN delegates to CursorManager::Next.
  • JOIN drives the nested-loop: for each outer tuple it resolves scan_args on the inner SCAN, resets the inner cursor, and probes until a match is found or the inner is exhausted.
  • TAKE counts emitted tuples and returns nullptr once the limit is reached.
  • PROJECT filters an input tuple to the requested attribute names.
Parameters
nodeRoot of the plan subtree to evaluate.
Returns
Next matching tuple, or nullptr when the plan is exhausted.

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