Record Class IterateNode

java.lang.Object
java.lang.Record
com.darkcollective.relix.ast.IterateNode
Record Components:
name - the bound relation name; must not be blank
base - the relation the first round reads; must not be null
step - the body computing each round from the previous one; must not be null
stop - when the iteration stops; must not be null
location - the source location of this node; never null
All Implemented Interfaces:
RelNode

public record IterateNode(String name, RelNode base, RelNode step, IterateStop stop, SourceLocation location) extends Record implements RelNode
Replace-each-round iteration — the binder ITERATE.

ITERATE name (base, step) <stop> binds name over step exactly as FixpointNode does: occurrences of name inside step are RecursiveRefNode leaves, and name is not in scope in base. What differs is what a round does with the step's output. FIX adds it to everything derived so far; ITERATE replaces the relation with it. The relation bound to name in a round is the whole of the previous round's output, and the result is the last round's output.

Because nothing accumulates, the step is free of FIX's restrictions: it may reference name any number of times and through any operator — aggregation, outer joins and difference included — which is what numeric iterations such as PageRank and state machines such as cellular automata need. The price is that nothing guarantees it stops, so stop() says when it does (see IterateStop).

The operator materialises a set: each round is deduplicated, and IterateStop.Stable compares rounds as sets. It never pushes down to a source.

Surface syntax: ITERATE R (base, step) ROUNDS n, … UNTIL STABLE MAX n ROUNDS, or … UNTIL c WITHIN ε PER k MAX n ROUNDS (keyword-only, no glyph).

  • Constructor Details

  • Method Details

    • accept

      public <R> R accept(RelNodeVisitor<R> visitor)
      Specified by:
      accept in interface RelNode
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • base

      public RelNode base()
      Returns the value of the base record component.
      Returns:
      the value of the base record component
    • step

      public RelNode step()
      Returns the value of the step record component.
      Returns:
      the value of the step record component
    • stop

      public IterateStop stop()
      Returns the value of the stop record component.
      Returns:
      the value of the stop record component
    • location

      public SourceLocation location()
      Returns the value of the location record component.
      Specified by:
      location in interface RelNode
      Returns:
      the value of the location record component