java.lang.Object
java.lang.Record
com.darkcollective.relix.optimizer.internal.PassRule
Record Components:
name - short stable identifier, e.g. "selection-pushdown"
codes - every code the pass can emit, primary first
pass - the pass entry point to delegate to
All Implemented Interfaces:
OptimizationRule

public record PassRule(String name, List<OptimizationCode> codes, com.darkcollective.relix.optimizer.internal.PassRule.Pass pass) extends Record implements OptimizationRule
The registry entry for one optimizer pass — an OptimizationRule whose apply(com.darkcollective.relix.ast.RelNode, java.lang.String, com.darkcollective.relix.semantic.SchemaAnnotations, com.darkcollective.relix.optimizer.internal.OptimizationContext) delegates to that pass.

Every pass is a package-private final class with a static apply, and their signatures are deliberately not uniform — SortEliminationPass, for one, takes no SchemaAnnotations. Adapting them here, rather than reshaping twenty classes to a common signature, keeps each pass's own entry point honest about what it actually needs; a rule wanting more than the four standard arguments can capture it in the closure OptimizationPipeline registers.

  • Constructor Details

    • PassRule

      public PassRule(String name, List<OptimizationCode> codes, com.darkcollective.relix.optimizer.internal.PassRule.Pass pass)
      Validates and defensively copies the code list.
  • Method Details

    • code

      public OptimizationCode code()
      Returns the OptimizationCode that identifies this rule.

      For a rule that emits several codes this is the primary one — the first entry of OptimizationRule.codes().

      Specified by:
      code in interface OptimizationRule
      Returns:
      the code; never null
    • apply

      public RelNode apply(RelNode node, String queryName, SchemaAnnotations schemas, OptimizationContext ctx)
      Applies this rule to the given node, returning either the original node (if the rule did not fire) or a rewritten node (if it did).
      Specified by:
      apply in interface OptimizationRule
      Parameters:
      node - the node to inspect and possibly rewrite; never null
      queryName - display name of the relation/query being optimized, used in TransformationRecords; never blank
      schemas - schema annotations from semantic analysis; rules that need to know a node's output schema use this to look it up; never null
      ctx - mutable context that accumulates transformation records; never null
      Returns:
      the original node when the rule did not fire, or a new RelNode representing the rewritten tree; never null
    • 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.
      Specified by:
      name in interface OptimizationRule
      Returns:
      the value of the name record component
    • codes

      public List<OptimizationCode> codes()
      Returns the value of the codes record component.
      Specified by:
      codes in interface OptimizationRule
      Returns:
      the value of the codes record component
    • pass

      public com.darkcollective.relix.optimizer.internal.PassRule.Pass pass()
      Returns the value of the pass record component.
      Returns:
      the value of the pass record component