Record Class RelationNode

java.lang.Object
java.lang.Record
com.darkcollective.relix.ast.RelationNode
Record Components:
name - the relation name; must not be blank
produceBound - optional generator production stop; never null, possibly empty
location - the source location of this node; never null
All Implemented Interfaces:
RelNode

public record RelationNode(String name, Optional<ProduceBound> produceBound, SourceLocation location) extends Record implements RelNode
A base relation (table) reference — a leaf node in the relational algebra tree.

Example: Users refers to the relation named "Users".

produceBound() is an optional production stop folded in by the optimizer (GEN-001) when this leaf is a monotone generator (Naturals/Primes) under an upper-bound selection; it is always Optional.empty() on a parsed tree and for every non-generator relation, and never changes the output schema.

  • Constructor Details

    • RelationNode

      public RelationNode(String name, Optional<ProduceBound> produceBound, SourceLocation location)
      Creates an instance of a RelationNode record class.
      Parameters:
      name - the value for the name record component
      produceBound - the value for the produceBound record component
      location - the value for the location record component
    • RelationNode

      public RelationNode(String name, SourceLocation location)
      Constructor without a production bound.
    • RelationNode

      public RelationNode(String name)
      Convenience constructor for tests; uses SourceLocation.UNKNOWN.
  • Method Details

    • withProduceBound

      public RelationNode withProduceBound(ProduceBound bound)
      Returns a copy of this leaf carrying the given generator production bound.
      Parameters:
      bound - the production stop to fold in; must not be null
      Returns:
      a bounded copy, preserving name and location
    • 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
    • produceBound

      public Optional<ProduceBound> produceBound()
      Returns the value of the produceBound record component.
      Returns:
      the value of the produceBound 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