Record Class OptimizationResult

java.lang.Object
java.lang.Record
com.darkcollective.relix.optimizer.internal.OptimizationResult
Record Components:
queryName - name of the query or relation that was optimized; must not be blank
original - the unoptimized source tree; must not be null
optimized - the rewritten tree; must not be null
applied - the transformations applied; must not be null; empty when no rules fired

public record OptimizationResult(String queryName, RelNode original, RelNode optimized, List<TransformationRecord> applied) extends Record
The immutable result of optimizing a single query's RelNode tree.

Carries three things together:

  1. The original() unoptimized tree as received from semantic analysis.
  2. The optimized() rewritten tree; reference-equal to original() when no rules fired.
  3. The ordered list of TransformationRecords describing every change made.

Instances are created by QueryOptimizer and consumed by the console's optimization report.

  • Constructor Details

    • OptimizationResult

      public OptimizationResult(String queryName, RelNode original, RelNode optimized, List<TransformationRecord> applied)
      Creates an instance of a OptimizationResult record class.
      Parameters:
      queryName - the value for the queryName record component
      original - the value for the original record component
      optimized - the value for the optimized record component
      applied - the value for the applied record component
  • Method Details

    • wasOptimized

      public boolean wasOptimized()
      Returns true when at least one transformation was applied to this query's tree.
      Returns:
      true iff applied() is non-empty
    • transformationCount

      public int transformationCount()
      Returns the number of transformations applied to this query.
      Returns:
      count ≥ 0; equal to applied().size()
    • 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.
    • queryName

      public String queryName()
      Returns the value of the queryName record component.
      Returns:
      the value of the queryName record component
    • original

      public RelNode original()
      Returns the value of the original record component.
      Returns:
      the value of the original record component
    • optimized

      public RelNode optimized()
      Returns the value of the optimized record component.
      Returns:
      the value of the optimized record component
    • applied

      public List<TransformationRecord> applied()
      Returns the value of the applied record component.
      Returns:
      the value of the applied record component