001package gudusoft.gsqlparser.ir.logical; 002 003import gudusoft.gsqlparser.ir.common.SourceAnchor; 004 005import java.util.Collections; 006import java.util.List; 007 008/** 009 * Base class for all relational nodes in the Logical IR. 010 * <p> 011 * All trees are immutable after construction. Traversal must use iterative 012 * visitor with explicit {@code Deque<RelNode>} stack (no recursion). 013 */ 014public abstract class RelNode { 015 016 private final RelNodeKind kind; 017 private final SourceAnchor anchor; 018 019 protected RelNode(RelNodeKind kind, SourceAnchor anchor) { 020 this.kind = kind; 021 this.anchor = anchor; 022 } 023 024 public RelNodeKind getKind() { return kind; } 025 public SourceAnchor getAnchor() { return anchor; } 026 027 /** 028 * Returns the child RelNodes of this node (for iterative traversal). 029 */ 030 public abstract List<RelNode> getInputs(); 031 032 /** 033 * Accept method for the visitor pattern. 034 */ 035 public abstract <R> R accept(RelNodeVisitor<R> visitor); 036 037 @Override 038 public String toString() { 039 return kind.name(); 040 } 041}