Record Class PassRule
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 firstpass- 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 Summary
ConstructorsConstructorDescriptionPassRule(String name, List<OptimizationCode> codes, com.darkcollective.relix.optimizer.internal.PassRule.Pass pass) Validates and defensively copies the code list. -
Method Summary
Modifier and TypeMethodDescriptionapply(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).code()Returns theOptimizationCodethat identifies this rule.codes()Returns the value of thecodesrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.name()Returns the value of thenamerecord component.com.darkcollective.relix.optimizer.internal.PassRule.Passpass()Returns the value of thepassrecord component.final StringtoString()Returns a string representation of this record class.
-
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
Returns theOptimizationCodethat identifies this rule.For a rule that emits several codes this is the primary one — the first entry of
OptimizationRule.codes().- Specified by:
codein interfaceOptimizationRule- 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:
applyin interfaceOptimizationRule- Parameters:
node- the node to inspect and possibly rewrite; never nullqueryName- display name of the relation/query being optimized, used inTransformationRecords; never blankschemas- schema annotations from semantic analysis; rules that need to know a node's output schema use this to look it up; never nullctx- mutable context that accumulates transformation records; never null- Returns:
- the original
nodewhen the rule did not fire, or a newRelNoderepresenting the rewritten tree; never null
-
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). -
name
Returns the value of thenamerecord component.- Specified by:
namein interfaceOptimizationRule- Returns:
- the value of the
namerecord component
-
codes
Returns the value of thecodesrecord component.- Specified by:
codesin interfaceOptimizationRule- Returns:
- the value of the
codesrecord component
-
pass
public com.darkcollective.relix.optimizer.internal.PassRule.Pass pass()Returns the value of thepassrecord component.- Returns:
- the value of the
passrecord component
-