Interface RelNode

All Known Subinterfaces:
ConditionalJoinNode
All Known Implementing Classes:
AggregationNode, AntiJoinNode, AsOfJoinNode, ClosureNode, ClusterNode, CompositionNode, CoverNode, DifferenceNode, DistinctNode, DivisionNode, DownsampleNode, EmptyRelationNode, FixpointNode, FullOuterJoinNode, IntersectionNode, IntervalJoinNode, IterateNode, LateralJoinNode, LeftOuterJoinNode, LimitNode, NaturalJoinNode, OptimizeNode, OuterUnionNode, PairwiseUniversalNode, PathNode, PivotNode, ProductNode, ProjectionNode, RecursiveRefNode, RelationFunctionCall, RelationNode, RenameNode, ReservoirSampleNode, RightOuterJoinNode, SampleNode, SelectionNode, SemiJoinNode, SessionizeNode, SolveNode, SortNode, SymmetricDifferenceNode, ThetaJoinNode, TopKNode, TraceNode, TreeNode, TruthRelationNode, UnionAllNode, UnionNode, UniversalNode, UnnestNode, UnpivotNode, WhyNode, WindowNode

Root sealed interface for all relational algebra operation nodes.

Every node in the AST implements this interface and participates in the visitor pattern via accept(com.darkcollective.relix.ast.visitor.RelNodeVisitor<R>). The sealed hierarchy is exhaustive — all permitted implementations are listed in the permits clause — so pattern matching and visitor dispatch are guaranteed to be complete at compile time.

Use prettyPrint() to serialise any node to a Unicode relational algebra string.

See Also:
  • Method Details

    • accept

      <R> R accept(RelNodeVisitor<R> visitor)
    • location

      SourceLocation location()
      Returns the source location of the first token of this node.
    • materializationMode

      default MaterializationMode materializationMode()
      Returns the output materialisation mode of this node.

      The default implementation derives the mode from the concrete node type via an exhaustive pattern switch over the sealed hierarchy:

      Returns:
      the materialisation mode; never null
    • prettyPrint

      default String prettyPrint()
    • children

      default List<RelNode> children()
      Returns this node's direct child sub-expressions, in left-to-right order.

      Leaf nodes (RelationNode) return an empty list; unary operators return their single input; binary operators return [left, right]. This is the canonical structural-traversal accessor — prefer it over a hand-written switch when walking a tree read-only.

      Returns:
      an immutable list of direct children; never null, possibly empty
    • mapChildren

      default RelNode mapChildren(UnaryOperator<RelNode> f)
      Returns a copy of this node with each direct child replaced by the result of applying f to it, preserving all other fields (predicates, attributes, join conditions, source location, …).

      As an optimization and a convenient no-op signal, this node is returned unchanged (reference-identical) when f returns the same reference for every child — so a tree rewrite can detect "nothing changed" with a == check. This is the canonical structural-rewrite helper; prefer it over a hand-written reconstruction switch.

      Parameters:
      f - the transformation to apply to each direct child; must not be null
      Returns:
      the rewritten node, or this if no child changed