Interface RelOptCost

  • All Known Implementing Classes:
    RelOptCostImpl, VolcanoCost

    public interface RelOptCost
    RelOptCost defines an interface for optimizer cost in terms of number of rows processed, CPU cost, and I/O cost. Optimizer implementations may use all of this information, or selectively ignore portions of it. The specific units for all of these quantities are rather vague; most relational expressions provide a default cost calculation, but optimizers can override this by plugging in their own cost models with well-defined meanings for each unit. Optimizers which supply their own cost models may also extend this interface with additional cost metrics such as memory usage.
    • Method Detail

      • getCpu

        double getCpu()
        Returns:
        usage of CPU resources
      • getIo

        double getIo()
        Returns:
        usage of I/O resources
      • isInfinite

        boolean isInfinite()
        Returns:
        true iff this cost represents an expression that hasn't actually been implemented (e.g. a pure relational algebra expression) or can't actually be implemented, e.g. a transfer of data between two disconnected sites
      • equals

        boolean equals​(RelOptCost cost)
        Compares this to another cost.
        Parameters:
        cost - another cost
        Returns:
        true iff this is exactly equal to other cost
      • isEqWithEpsilon

        boolean isEqWithEpsilon​(RelOptCost cost)
        Compares this to another cost, allowing for slight roundoff errors.
        Parameters:
        cost - another cost
        Returns:
        true iff this is the same as the other cost within a roundoff margin of error
      • isLe

        boolean isLe​(RelOptCost cost)
        Compares this to another cost.
        Parameters:
        cost - another cost
        Returns:
        true iff this is less than or equal to other cost
      • isLt

        boolean isLt​(RelOptCost cost)
        Compares this to another cost.
        Parameters:
        cost - another cost
        Returns:
        true iff this is strictly less than other cost
      • plus

        RelOptCost plus​(RelOptCost cost)
        Adds another cost to this.
        Parameters:
        cost - another cost
        Returns:
        sum of this and other cost
      • minus

        RelOptCost minus​(RelOptCost cost)
        Subtracts another cost from this.
        Parameters:
        cost - another cost
        Returns:
        difference between this and other cost
      • multiplyBy

        RelOptCost multiplyBy​(double factor)
        Multiplies this cost by a scalar factor.
        Parameters:
        factor - scalar factor
        Returns:
        scalar product of this and factor
      • divideBy

        double divideBy​(RelOptCost cost)
        Computes the ratio between this cost and another cost.

        divideBy is the inverse of multiplyBy(double). For any finite, non-zero cost and factor f, cost.divideBy(cost.multiplyBy(f)) yields 1 / f.

        Parameters:
        cost - Other cost
        Returns:
        Ratio between costs
      • toString

        java.lang.String toString()
        Forces implementations to override Object.toString() and provide a good cost rendering to use during tracing.
        Overrides:
        toString in class java.lang.Object