- Record Components:
input- the source adjacency relation; must not be nullkeyColumn- the node-identity column; must not be blankparentColumn- the parent-key column; must not be blankorderSpecs- the optional sibling ordering; empty = input order; must not be nullchildrenColumn- the name of the appended nested array column; must not be blanklocation- the source location of this node; never null
- All Implemented Interfaces:
RelNode
ANY document.
TREE is the recursive generalisation of COLLECT
(NEST): where COLLECT gathers a single level of children into an
array, TREE follows the keyColumn() → parentColumn() edge
to fixpoint, assembling an unbounded-depth tree in one pass. Its marquee use is
dogfooding the engine's own IR — TREE(relix.plan) renders the logical tree
as a nested document — but it is general (org charts, bill-of-materials, threaded
comments, file trees).
Surface syntax:
TREE node_id BY parent_id ORDER ordinal AS children (relix.plan) TREE id BY manager_id AS reports (Employees)
keyColumn()— the node-identity column (e.g.node_id).parentColumn()— the column pointing at the parent's key; a row whose parent-key isNULL, or references a key absent from the input, is a root (forest semantics).orderSpecs()— optional sibling ordering; empty = input order.childrenColumn()— the name of the added nested array column.
Output: one row per root. Each row is the root's own input
columns ⊕ childrenColumn: ANY, where the children column is an array of
documents of the same recursive shape. Leaves carry an empty children array. The
recursive document is typed ANY (schema-on-read; there is no recursive
static type).
Well-formedness: a cycle in the key→parent-key graph and a
duplicate keyColumn() are user errors raised at evaluation time (the
recursion engine's bounded-fixpoint cap is the cycle safety valve).
Evaluation must see the whole relation to build the forest, so TREE is a
blocking operator (MaterializationMode.BAG); it never pushes down to a
source and is subject to the boundedness check over unbounded inputs.
-
Constructor Summary
ConstructorsConstructorDescriptionTreeNode(RelNode input, String keyColumn, String parentColumn, List<SortSpecification> orderSpecs, String childrenColumn) Convenience constructor for tests:SourceLocation.UNKNOWN.TreeNode(RelNode input, String keyColumn, String parentColumn, List<SortSpecification> orderSpecs, String childrenColumn, SourceLocation location) Creates an instance of aTreeNoderecord class. -
Method Summary
Modifier and TypeMethodDescription<R> Raccept(RelNodeVisitor<R> visitor) Returns the value of thechildrenColumnrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.input()Returns the value of theinputrecord component.Returns the value of thekeyColumnrecord component.location()Returns the value of thelocationrecord component.Returns the value of theorderSpecsrecord component.Returns the value of theparentColumnrecord component.final StringtoString()Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.darkcollective.relix.ast.RelNode
children, mapChildren, materializationMode, prettyPrint
-
Constructor Details
-
TreeNode
public TreeNode(RelNode input, String keyColumn, String parentColumn, List<SortSpecification> orderSpecs, String childrenColumn, SourceLocation location) Creates an instance of aTreeNoderecord class.- Parameters:
input- the value for theinputrecord componentkeyColumn- the value for thekeyColumnrecord componentparentColumn- the value for theparentColumnrecord componentorderSpecs- the value for theorderSpecsrecord componentchildrenColumn- the value for thechildrenColumnrecord componentlocation- the value for thelocationrecord component
-
TreeNode
public TreeNode(RelNode input, String keyColumn, String parentColumn, List<SortSpecification> orderSpecs, String childrenColumn) Convenience constructor for tests:SourceLocation.UNKNOWN.
-
-
Method Details
-
accept
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
input
Returns the value of theinputrecord component.- Returns:
- the value of the
inputrecord component
-
keyColumn
Returns the value of thekeyColumnrecord component.- Returns:
- the value of the
keyColumnrecord component
-
parentColumn
Returns the value of theparentColumnrecord component.- Returns:
- the value of the
parentColumnrecord component
-
orderSpecs
Returns the value of theorderSpecsrecord component.- Returns:
- the value of the
orderSpecsrecord component
-
childrenColumn
Returns the value of thechildrenColumnrecord component.- Returns:
- the value of the
childrenColumnrecord component
-
location
Returns the value of thelocationrecord component.
-