Skip to content

Commit aaa03d7

Browse files
authored
planner: move PhysicalIndexMergeJoin related logic into physical op dir (pingcap#63134)
ref pingcap#52714
1 parent 46543df commit aaa03d7

21 files changed

+135
-91
lines changed

pkg/executor/builder.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ func (b *executorBuilder) build(p base.Plan) exec.Executor {
271271
return b.buildMergeJoin(v)
272272
case *physicalop.PhysicalIndexJoin:
273273
return b.buildIndexLookUpJoin(v)
274-
case *plannercore.PhysicalIndexMergeJoin:
274+
case *physicalop.PhysicalIndexMergeJoin:
275275
return b.buildIndexLookUpMergeJoin(v)
276276
case *physicalop.PhysicalIndexHashJoin:
277277
return b.buildIndexNestedLoopHashJoin(v)
@@ -3618,7 +3618,7 @@ func (b *executorBuilder) buildIndexLookUpJoin(v *physicalop.PhysicalIndexJoin)
36183618
return e
36193619
}
36203620

3621-
func (b *executorBuilder) buildIndexLookUpMergeJoin(v *plannercore.PhysicalIndexMergeJoin) exec.Executor {
3621+
func (b *executorBuilder) buildIndexLookUpMergeJoin(v *physicalop.PhysicalIndexMergeJoin) exec.Executor {
36223622
outerExec := b.build(v.Children()[1-v.InnerChildIdx])
36233623
if b.err != nil {
36243624
return nil

pkg/planner/core/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ go_library(
1010
"debugtrace.go",
1111
"encode.go",
1212
"exhaust_physical_plans.go",
13-
"explain.go",
1413
"expression_codec_fn.go",
1514
"expression_rewriter.go",
1615
"find_best_task.go",

pkg/planner/core/core_init.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ func init() {
115115
utilfuncp.GetCost4PhysicalIndexHashJoin = getCost4PhysicalIndexHashJoin
116116
utilfuncp.GetPlanCostVer1PhysicalIndexHashJoin = getPlanCostVer1PhysicalIndexHashJoin
117117
utilfuncp.Attach2Task4PhysicalIndexHashJoin = attach2Task4PhysicalIndexHashJoin
118+
// for physical index merge join
119+
utilfuncp.GetCost4PhysicalIndexMergeJoin = getCost4PhysicalIndexMergeJoin
120+
utilfuncp.GetPlanCostVer14PhysicalIndexMergeJoin = getPlanCostVer14PhysicalIndexMergeJoin
121+
utilfuncp.Attach2Task4PhysicalIndexMergeJoin = attach2Task4PhysicalIndexMergeJoin
118122
// for physical hash agg
119123
utilfuncp.GetCost4PhysicalHashAgg = getCost4PhysicalHashAgg
120124
utilfuncp.Attach2Task4PhysicalHashAgg = attach2Task4PhysicalHashAgg

pkg/planner/core/exhaust_physical_plans.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ func constructIndexMergeJoin(
626626
// or outer join keys the prefix of the prop items. So we need `canKeepOuterOrder` or
627627
// `isOuterKeysPrefix` to be true.
628628
if canKeepOuterOrder || isOuterKeysPrefix {
629-
indexMergeJoin := PhysicalIndexMergeJoin{
629+
indexMergeJoin := physicalop.PhysicalIndexMergeJoin{
630630
PhysicalIndexJoin: *join,
631631
KeyOff2KeyOffOrderByIdx: keyOff2KeyOffOrderByIdx,
632632
NeedOuterSort: !isOuterKeysPrefix,
@@ -1729,7 +1729,7 @@ func filterIndexJoinBySessionVars(sc base.PlanContext, indexJoins []base.Physica
17291729
return indexJoins
17301730
}
17311731
return slices.DeleteFunc(indexJoins, func(indexJoin base.PhysicalPlan) bool {
1732-
_, ok := indexJoin.(*PhysicalIndexMergeJoin)
1732+
_, ok := indexJoin.(*physicalop.PhysicalIndexMergeJoin)
17331733
return ok
17341734
})
17351735
}
@@ -1751,7 +1751,7 @@ func getIndexJoinSideAndMethod(join base.PhysicalPlan) (innerSide, joinMethod in
17511751
case *physicalop.PhysicalIndexHashJoin:
17521752
innerIdx = ij.GetInnerChildIdx()
17531753
joinMethod = indexHashJoinMethod
1754-
case *PhysicalIndexMergeJoin:
1754+
case *physicalop.PhysicalIndexMergeJoin:
17551755
innerIdx = ij.GetInnerChildIdx()
17561756
joinMethod = indexMergeJoinMethod
17571757
default:

pkg/planner/core/explain.go

Lines changed: 0 additions & 25 deletions
This file was deleted.

pkg/planner/core/find_best_task.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ func appendCandidate4PhysicalOptimizeOp(pop *optimizetrace.PhysicalOptimizeOp, l
745745
index := -1
746746
var plan base.PhysicalPlan
747747
switch join := pp.(type) {
748-
case *PhysicalIndexMergeJoin:
748+
case *physicalop.PhysicalIndexMergeJoin:
749749
index = join.InnerChildIdx
750750
plan = join.InnerPlan
751751
case *physicalop.PhysicalIndexHashJoin:

pkg/planner/core/flat_plan.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ func (f *FlatPhysicalPlan) flattenRecursively(p base.Plan, info *operatorCtx, ta
303303
case *physicalop.PhysicalIndexJoin:
304304
label[plan.InnerChildIdx] = ProbeSide
305305
label[1-plan.InnerChildIdx] = BuildSide
306-
case *PhysicalIndexMergeJoin:
306+
case *physicalop.PhysicalIndexMergeJoin:
307307
label[plan.InnerChildIdx] = ProbeSide
308308
label[1-plan.InnerChildIdx] = BuildSide
309309
case *physicalop.PhysicalIndexHashJoin:

pkg/planner/core/hint_utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ func genHintsFromSingle(p base.PhysicalPlan, nodeType h.NodeType, storeType kv.S
276276
if hint != nil {
277277
res = append(res, hint)
278278
}
279-
case *PhysicalIndexMergeJoin:
279+
case *physicalop.PhysicalIndexMergeJoin:
280280
hint := genJoinMethodHintForSinglePhysicalJoin(
281281
p.SCtx(),
282282
h.HintINLMJ,

pkg/planner/core/initialize.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,6 @@ func (p ImportInto) Init(ctx base.PlanContext) *ImportInto {
5454
return &p
5555
}
5656

57-
// Init initializes PhysicalIndexMergeJoin.
58-
func (p PhysicalIndexMergeJoin) Init(ctx base.PlanContext) *PhysicalIndexMergeJoin {
59-
p.SetTP(plancodec.TypeIndexMergeJoin)
60-
p.SetID(int(ctx.GetSessionVars().PlanID.Add(1)))
61-
p.SetSCtx(ctx)
62-
p.Self = &p
63-
return &p
64-
}
65-
6657
// Init initializes BatchPointGetPlan.
6758
func (p *BatchPointGetPlan) Init(ctx base.PlanContext, stats *property.StatsInfo, schema *expression.Schema, names []*types.FieldName, offset int) *BatchPointGetPlan {
6859
p.Plan = baseimpl.NewBasePlan(ctx, plancodec.TypeBatchPointGet, offset)

pkg/planner/core/operator/physicalop/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ go_library(
1616
"physical_hash_join.go",
1717
"physical_index_hash_join.go",
1818
"physical_index_join.go",
19+
"physical_index_merge_join.go",
1920
"physical_index_reader.go",
2021
"physical_index_scan.go",
2122
"physical_indexlookup_reader.go",

0 commit comments

Comments
 (0)