Skip to content

Commit

Permalink
refine cop task as a capital one for latter pkg move
Browse files Browse the repository at this point in the history
Signed-off-by: AilinKid <[email protected]>
  • Loading branch information
AilinKid committed Apr 11, 2024
1 parent 66a6d4c commit e09d7f5
Show file tree
Hide file tree
Showing 5 changed files with 251 additions and 242 deletions.
4 changes: 2 additions & 2 deletions pkg/planner/core/exhaust_physical_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ func (p *LogicalJoin) constructInnerTableScanTask(
if usedStats != nil && usedStats.GetUsedInfo(ts.physicalTableID) != nil {
ts.usedStatsInfo = usedStats.GetUsedInfo(ts.physicalTableID)
}
copTask := &copTask{
copTask := &CopTask{
tablePlan: ts,
indexPlanFinished: true,
tblColHists: ds.TblColHists,
Expand Down Expand Up @@ -1237,7 +1237,7 @@ func (p *LogicalJoin) constructInnerIndexScanTask(
tblColHists: ds.TblColHists,
pkIsHandleCol: ds.getPKIsHandleCol(),
}.Init(ds.SCtx(), ds.QueryBlockOffset())
cop := &copTask{
cop := &CopTask{
indexPlan: is,
tblColHists: ds.TblColHists,
tblCols: ds.TblCols,
Expand Down
16 changes: 8 additions & 8 deletions pkg/planner/core/find_best_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ func getTaskPlanCost(t Task, pop *coreusage.PhysicalOptimizeOp) (float64, bool,
switch t.(type) {
case *RootTask:
taskType = property.RootTaskType
case *copTask: // no need to know whether the task is single-read or double-read, so both CopSingleReadTaskType and CopDoubleReadTaskType are OK
cop := t.(*copTask)
case *CopTask: // no need to know whether the task is single-read or double-read, so both CopSingleReadTaskType and CopDoubleReadTaskType are OK
cop := t.(*CopTask)
if cop.indexPlan != nil && cop.tablePlan != nil { // handle IndexLookup specially
taskType = property.CopMultiReadTaskType
// keep compatible with the old cost interface, for CopMultiReadTask, the cost is idxCost + tblCost.
Expand Down Expand Up @@ -481,7 +481,7 @@ func getTaskPlanCost(t Task, pop *coreusage.PhysicalOptimizeOp) (float64, bool,
// It's a very special case for index merge case.
// t.plan() == nil in index merge COP case, it means indexPlanFinished is false in other words.
cost := 0.0
copTsk := t.(*copTask)
copTsk := t.(*CopTask)
for _, partialScan := range copTsk.idxMergePartPlans {
partialCost, err := getPlanCost(partialScan, taskType, coreusage.NewDefaultPlanCostOption().WithOptimizeTracer(pop))
if err != nil {
Expand Down Expand Up @@ -1610,7 +1610,7 @@ func (ds *DataSource) convertToIndexMergeScan(prop *property.PhysicalProperty, c
})
path := candidate.path
scans := make([]PhysicalPlan, 0, len(path.PartialIndexPaths))
cop := &copTask{
cop := &CopTask{
indexPlanFinished: false,
tblColHists: ds.TblColHists,
}
Expand Down Expand Up @@ -2019,7 +2019,7 @@ func (ds *DataSource) convertToIndexScan(prop *property.PhysicalProperty,
}
path := candidate.path
is := ds.getOriginalPhysicalIndexScan(prop, path, candidate.isMatchProp, candidate.path.IsSingleScan)
cop := &copTask{
cop := &CopTask{
indexPlan: is,
tblColHists: ds.TblColHists,
tblCols: ds.TblCols,
Expand Down Expand Up @@ -2204,7 +2204,7 @@ func (is *PhysicalIndexScan) initSchema(idxExprCols []*expression.Column, isDoub
is.SetSchema(expression.NewSchema(indexCols...))
}

func (is *PhysicalIndexScan) addPushedDownSelection(copTask *copTask, p *DataSource, path *util.AccessPath, finalStats *property.StatsInfo) {
func (is *PhysicalIndexScan) addPushedDownSelection(copTask *CopTask, p *DataSource, path *util.AccessPath, finalStats *property.StatsInfo) {
// Add filter condition to table plan now.
indexConds, tableConds := path.IndexFilters, path.TableFilters
tableConds, copTask.rootTaskConds = SplitSelCondsWithVirtualColumn(tableConds)
Expand Down Expand Up @@ -2477,7 +2477,7 @@ func (ds *DataSource) convertToTableScan(prop *property.PhysicalProperty, candid
// prop.TaskTp is cop related, just return invalidTask.
return invalidTask, nil
}
copTask := &copTask{
copTask := &CopTask{
tablePlan: ts,
indexPlanFinished: true,
tblColHists: ds.TblColHists,
Expand Down Expand Up @@ -2711,7 +2711,7 @@ func (ts *PhysicalTableScan) addPushedDownSelectionToMppTask(mpp *MppTask, stats
return mpp
}

func (ts *PhysicalTableScan) addPushedDownSelection(copTask *copTask, stats *property.StatsInfo) {
func (ts *PhysicalTableScan) addPushedDownSelection(copTask *CopTask, stats *property.StatsInfo) {
ts.filterCondition, copTask.rootTaskConds = SplitSelCondsWithVirtualColumn(ts.filterCondition)
var newRootConds []expression.Expression
ts.filterCondition, newRootConds = expression.PushDownExprs(GetPushDownCtx(ts.SCtx()), ts.filterCondition, ts.StoreType)
Expand Down
2 changes: 1 addition & 1 deletion pkg/planner/core/planbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1555,7 +1555,7 @@ func (b *PlanBuilder) buildPhysicalIndexLookUpReader(_ context.Context, dbName m
}
}

cop := &copTask{
cop := &CopTask{
indexPlan: is,
tablePlan: ts,
tblColHists: is.StatsInfo().HistColl,
Expand Down
Loading

0 comments on commit e09d7f5

Please sign in to comment.