Record Class ClusterNode

java.lang.Object
java.lang.Record
com.darkcollective.relix.ast.ClusterNode
Record Components:
input - the edge relation; must not be null
fromColumn - the first edge-endpoint column; also names the output node column; must not be blank
toColumn - the second edge-endpoint column; must not be blank
labelColumn - the name of the appended component-label column; must not be blank
location - the source location of this node; never null
All Implemented Interfaces:
RelNode

public record ClusterNode(RelNode input, String fromColumn, String toColumn, String labelColumn, SourceLocation location) extends Record implements RelNode
Connected-components labelling of an undirected graph — the entity-resolution / network-island operator.

The input() relation is read as a set of undirected edges over two columns, fromColumn() and toColumn() (the edge is treated symmetrically — from ↔ to). The operator partitions the graph's nodes into maximal connected components and emits one row per distinct node, carrying the node together with the id of the component it belongs to. The result is therefore the relational equivalent of an undirected union-find / connected-components pass — what otherwise requires a hand-rolled recursive self-join.

Output is a binary relation: the node-identifier column (keeping the fromColumn() name and type) and the component-label column (labelColumn(), type NUMBER). Component labels are canonical: each component is identified by a dense, 1-based integer assigned in ascending order of the component's minimum node id, so a given graph always produces the same labels regardless of input row order.

Evaluation is an in-engine union-find over the whole edge set — a blocking operator (it must see every edge before any node can be labelled), so it never pushes down to a source and is subject to the boundedness check over unbounded inputs.

Surface syntax: CLUSTER from, to AS label (Edges).

  • Constructor Details

    • ClusterNode

      public ClusterNode(RelNode input, String fromColumn, String toColumn, String labelColumn, SourceLocation location)
      Creates an instance of a ClusterNode record class.
      Parameters:
      input - the value for the input record component
      fromColumn - the value for the fromColumn record component
      toColumn - the value for the toColumn record component
      labelColumn - the value for the labelColumn record component
      location - the value for the location record component
    • ClusterNode

      public ClusterNode(RelNode input, String fromColumn, String toColumn, String labelColumn)
      Convenience constructor for tests: SourceLocation.UNKNOWN.
  • 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.
    • input

      public RelNode input()
      Returns the value of the input record component.
      Returns:
      the value of the input record component
    • fromColumn

      public String fromColumn()
      Returns the value of the fromColumn record component.
      Returns:
      the value of the fromColumn record component
    • toColumn

      public String toColumn()
      Returns the value of the toColumn record component.
      Returns:
      the value of the toColumn record component
    • labelColumn

      public String labelColumn()
      Returns the value of the labelColumn record component.
      Returns:
      the value of the labelColumn 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