Skip to content

Commit

Permalink
planner: move getTaskPlanCost to planner core util (#53218)
Browse files Browse the repository at this point in the history
ref #51664, ref #52714
  • Loading branch information
AilinKid authored May 13, 2024
1 parent b1818cd commit 4fe70da
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/planner/core/core_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
func init() {
// For code refactor init.
utilfuncp.HasMaxOneRowUtil = HasMaxOneRow
utilfuncp.GetTaskPlanCost = getTaskPlanCost
utilfuncp.AppendCandidate4PhysicalOptimizeOp = appendCandidate4PhysicalOptimizeOp

// For mv index init.
Expand Down
4 changes: 2 additions & 2 deletions pkg/planner/core/find_best_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,11 @@ func (p *LogicalSequence) iterateChildPlan(

// compareTaskCost compares cost of curTask and bestTask and returns whether curTask's cost is smaller than bestTask's.
func compareTaskCost(curTask, bestTask base.Task, op *optimizetrace.PhysicalOptimizeOp) (curIsBetter bool, err error) {
curCost, curInvalid, err := getTaskPlanCost(curTask, op)
curCost, curInvalid, err := utilfuncp.GetTaskPlanCost(curTask, op)
if err != nil {
return false, err
}
bestCost, bestInvalid, err := getTaskPlanCost(bestTask, op)
bestCost, bestInvalid, err := utilfuncp.GetTaskPlanCost(bestTask, op)
if err != nil {
return false, err
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/planner/util/utilfuncp/func_pointer_misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,10 @@ var HasMaxOneRowUtil func(p base.LogicalPlan, childMaxOneRow []bool) bool
// todo: (2) arenatlx, remove this func pointer when concrete Logical Operators moved out of core.
var AppendCandidate4PhysicalOptimizeOp func(pop *optimizetrace.PhysicalOptimizeOp, lp base.LogicalPlan,
pp base.PhysicalPlan, prop *property.PhysicalProperty)

// GetTaskPlanCost returns the cost of this task.
// The new cost interface will be used if EnableNewCostInterface is true.
// The second returned value indicates whether this task is valid.
// todo: (3) arenatlx, remove this func pointer when Task pkg is moved out of core, and
// getTaskPlanCost can be some member function usage of its family.
var GetTaskPlanCost func(t base.Task, pop *optimizetrace.PhysicalOptimizeOp) (float64, bool, error)

0 comments on commit 4fe70da

Please sign in to comment.