Skip to content

Commit ecb8a9e

Browse files
authored
planner: rename base plan implemention's pkg from base to baseImpl (pingcap#52659)
ref pingcap#51664
1 parent 3b6a9db commit ecb8a9e

File tree

9 files changed

+247
-247
lines changed

9 files changed

+247
-247
lines changed

pkg/planner/core/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ go_library(
114114
"//pkg/planner/context",
115115
"//pkg/planner/core/base",
116116
"//pkg/planner/core/metrics",
117-
"//pkg/planner/core/operator/base",
117+
"//pkg/planner/core/operator/baseimpl",
118118
"//pkg/planner/funcdep",
119119
"//pkg/planner/property",
120120
"//pkg/planner/util",

pkg/planner/core/initialize.go

+92-92
Large diffs are not rendered by default.

pkg/planner/core/operator/base/BUILD.bazel pkg/planner/core/operator/baseimpl/BUILD.bazel

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
load("@io_bazel_rules_go//go:def.bzl", "go_library")
22

33
go_library(
4-
name = "base",
4+
name = "baseimpl",
55
srcs = ["plan.go"],
6-
importpath = "github.com/pingcap/tidb/pkg/planner/core/operator/base",
6+
importpath = "github.com/pingcap/tidb/pkg/planner/core/operator/baseimpl",
77
visibility = ["//visibility:public"],
88
deps = [
99
"//pkg/expression",

pkg/planner/core/operator/base/plan.go pkg/planner/core/operator/baseimpl/plan.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package base
15+
package baseimpl
1616

1717
import (
1818
"fmt"

pkg/planner/core/plan.go

+38-38
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import (
2121
"github.com/pingcap/tidb/pkg/expression"
2222
"github.com/pingcap/tidb/pkg/kv"
2323
"github.com/pingcap/tidb/pkg/planner/cardinality"
24-
base2 "github.com/pingcap/tidb/pkg/planner/core/base"
25-
"github.com/pingcap/tidb/pkg/planner/core/operator/base"
24+
"github.com/pingcap/tidb/pkg/planner/core/base"
25+
"github.com/pingcap/tidb/pkg/planner/core/operator/baseimpl"
2626
fd "github.com/pingcap/tidb/pkg/planner/funcdep"
2727
"github.com/pingcap/tidb/pkg/planner/property"
2828
"github.com/pingcap/tidb/pkg/planner/util"
@@ -35,15 +35,15 @@ import (
3535
)
3636

3737
// AsSctx converts PlanContext to sessionctx.Context.
38-
func AsSctx(pctx base2.PlanContext) (sessionctx.Context, error) {
38+
func AsSctx(pctx base.PlanContext) (sessionctx.Context, error) {
3939
sctx, ok := pctx.(sessionctx.Context)
4040
if !ok {
4141
return nil, errors.New("the current PlanContext cannot be converted to sessionctx.Context")
4242
}
4343
return sctx, nil
4444
}
4545

46-
func enforceProperty(p *property.PhysicalProperty, tsk base2.Task, ctx base2.PlanContext) base2.Task {
46+
func enforceProperty(p *property.PhysicalProperty, tsk base.Task, ctx base.PlanContext) base.Task {
4747
if p.TaskTp == property.MppTaskType {
4848
mpp, ok := tsk.(*MppTask)
4949
if !ok || mpp.Invalid() {
@@ -75,7 +75,7 @@ func enforceProperty(p *property.PhysicalProperty, tsk base2.Task, ctx base2.Pla
7575
}
7676

7777
// optimizeByShuffle insert `PhysicalShuffle` to optimize performance by running in a parallel manner.
78-
func optimizeByShuffle(tsk base2.Task, ctx base2.PlanContext) base2.Task {
78+
func optimizeByShuffle(tsk base.Task, ctx base.PlanContext) base.Task {
7979
if tsk.Plan() == nil {
8080
return tsk
8181
}
@@ -97,7 +97,7 @@ func optimizeByShuffle(tsk base2.Task, ctx base2.PlanContext) base2.Task {
9797
return tsk
9898
}
9999

100-
func optimizeByShuffle4Window(pp *PhysicalWindow, ctx base2.PlanContext) *PhysicalShuffle {
100+
func optimizeByShuffle4Window(pp *PhysicalWindow, ctx base.PlanContext) *PhysicalShuffle {
101101
concurrency := ctx.GetSessionVars().WindowConcurrency()
102102
if concurrency <= 1 {
103103
return nil
@@ -128,15 +128,15 @@ func optimizeByShuffle4Window(pp *PhysicalWindow, ctx base2.PlanContext) *Physic
128128
reqProp := &property.PhysicalProperty{ExpectedCnt: math.MaxFloat64}
129129
shuffle := PhysicalShuffle{
130130
Concurrency: concurrency,
131-
Tails: []base2.PhysicalPlan{tail},
132-
DataSources: []base2.PhysicalPlan{dataSource},
131+
Tails: []base.PhysicalPlan{tail},
132+
DataSources: []base.PhysicalPlan{dataSource},
133133
SplitterType: PartitionHashSplitterType,
134134
ByItemArrays: [][]expression.Expression{byItems},
135135
}.Init(ctx, pp.StatsInfo(), pp.QueryBlockOffset(), reqProp)
136136
return shuffle
137137
}
138138

139-
func optimizeByShuffle4StreamAgg(pp *PhysicalStreamAgg, ctx base2.PlanContext) *PhysicalShuffle {
139+
func optimizeByShuffle4StreamAgg(pp *PhysicalStreamAgg, ctx base.PlanContext) *PhysicalShuffle {
140140
concurrency := ctx.GetSessionVars().StreamAggConcurrency()
141141
if concurrency <= 1 {
142142
return nil
@@ -165,23 +165,23 @@ func optimizeByShuffle4StreamAgg(pp *PhysicalStreamAgg, ctx base2.PlanContext) *
165165
reqProp := &property.PhysicalProperty{ExpectedCnt: math.MaxFloat64}
166166
shuffle := PhysicalShuffle{
167167
Concurrency: concurrency,
168-
Tails: []base2.PhysicalPlan{tail},
169-
DataSources: []base2.PhysicalPlan{dataSource},
168+
Tails: []base.PhysicalPlan{tail},
169+
DataSources: []base.PhysicalPlan{dataSource},
170170
SplitterType: PartitionHashSplitterType,
171171
ByItemArrays: [][]expression.Expression{util.CloneExprs(pp.GroupByItems)},
172172
}.Init(ctx, pp.StatsInfo(), pp.QueryBlockOffset(), reqProp)
173173
return shuffle
174174
}
175175

176-
func optimizeByShuffle4MergeJoin(pp *PhysicalMergeJoin, ctx base2.PlanContext) *PhysicalShuffle {
176+
func optimizeByShuffle4MergeJoin(pp *PhysicalMergeJoin, ctx base.PlanContext) *PhysicalShuffle {
177177
concurrency := ctx.GetSessionVars().MergeJoinConcurrency()
178178
if concurrency <= 1 {
179179
return nil
180180
}
181181

182182
children := pp.Children()
183-
dataSources := make([]base2.PhysicalPlan, len(children))
184-
tails := make([]base2.PhysicalPlan, len(children))
183+
dataSources := make([]base.PhysicalPlan, len(children))
184+
tails := make([]base.PhysicalPlan, len(children))
185185

186186
for i := range children {
187187
sort, ok := children[i].(*PhysicalSort)
@@ -215,7 +215,7 @@ func optimizeByShuffle4MergeJoin(pp *PhysicalMergeJoin, ctx base2.PlanContext) *
215215
// LogicalPlan is a tree of logical operators.
216216
// We can do a lot of logical optimizations to it, like predicate pushdown and column pruning.
217217
type LogicalPlan interface {
218-
base2.Plan
218+
base.Plan
219219

220220
// HashCode encodes a LogicalPlan to fast compare whether a LogicalPlan equals to another.
221221
// We use a strict encode method here which ensures there is no conflict.
@@ -237,7 +237,7 @@ type LogicalPlan interface {
237237
// If planCounter > 0, the clock_th plan generated in this function will be returned.
238238
// If planCounter = 0, the plan generated in this function will not be considered.
239239
// If planCounter = -1, then we will not force plan.
240-
findBestTask(prop *property.PhysicalProperty, planCounter *PlanCounterTp, op *coreusage.PhysicalOptimizeOp) (base2.Task, int64, error)
240+
findBestTask(prop *property.PhysicalProperty, planCounter *PlanCounterTp, op *coreusage.PhysicalOptimizeOp) (base.Task, int64, error)
241241

242242
// BuildKeyInfo will collect the information of unique keys into schema.
243243
// Because this method is also used in cascades planner, we cannot use
@@ -283,7 +283,7 @@ type LogicalPlan interface {
283283
// It will return:
284284
// 1. All possible plans that can match the required property.
285285
// 2. Whether the SQL hint can work. Return true if there is no hint.
286-
exhaustPhysicalPlans(*property.PhysicalProperty) (physicalPlans []base2.PhysicalPlan, hintCanWork bool, err error)
286+
exhaustPhysicalPlans(*property.PhysicalProperty) (physicalPlans []base.PhysicalPlan, hintCanWork bool, err error)
287287

288288
// ExtractCorrelatedCols extracts correlated columns inside the LogicalPlan.
289289
ExtractCorrelatedCols() []*expression.CorrelatedColumn
@@ -311,9 +311,9 @@ type LogicalPlan interface {
311311
}
312312

313313
type baseLogicalPlan struct {
314-
base.Plan
314+
baseimpl.Plan
315315

316-
taskMap map[string]base2.Task
316+
taskMap map[string]base.Task
317317
// taskMapBak forms a backlog stack of taskMap, used to roll back the taskMap.
318318
taskMapBak []string
319319
// taskMapBakTS stores the timestamps of logs.
@@ -349,7 +349,7 @@ func (*baseLogicalPlan) ExplainInfo() string {
349349
return ""
350350
}
351351

352-
func getEstimatedProbeCntFromProbeParents(probeParents []base2.PhysicalPlan) float64 {
352+
func getEstimatedProbeCntFromProbeParents(probeParents []base.PhysicalPlan) float64 {
353353
res := float64(1)
354354
for _, pp := range probeParents {
355355
switch pp.(type) {
@@ -363,7 +363,7 @@ func getEstimatedProbeCntFromProbeParents(probeParents []base2.PhysicalPlan) flo
363363
return res
364364
}
365365

366-
func getActualProbeCntFromProbeParents(pps []base2.PhysicalPlan, statsColl *execdetails.RuntimeStatsColl) int64 {
366+
func getActualProbeCntFromProbeParents(pps []base.PhysicalPlan, statsColl *execdetails.RuntimeStatsColl) int64 {
367367
res := int64(1)
368368
for _, pp := range pps {
369369
switch pp.(type) {
@@ -386,11 +386,11 @@ func getActualProbeCntFromProbeParents(pps []base2.PhysicalPlan, statsColl *exec
386386
}
387387

388388
type basePhysicalPlan struct {
389-
base.Plan
389+
baseimpl.Plan
390390

391391
childrenReqProps []*property.PhysicalProperty
392-
self base2.PhysicalPlan
393-
children []base2.PhysicalPlan
392+
self base.PhysicalPlan
393+
children []base.PhysicalPlan
394394

395395
// used by the new cost interface
396396
planCostInit bool
@@ -399,15 +399,15 @@ type basePhysicalPlan struct {
399399

400400
// probeParents records the IndexJoins and Applys with this operator in their inner children.
401401
// Please see comments in op.PhysicalPlan for details.
402-
probeParents []base2.PhysicalPlan
402+
probeParents []base.PhysicalPlan
403403

404404
// Only for MPP. If TiFlashFineGrainedShuffleStreamCount > 0:
405405
// 1. For ExchangeSender, means its output will be partitioned by hash key.
406406
// 2. For ExchangeReceiver/Window/Sort, means its input is already partitioned.
407407
TiFlashFineGrainedShuffleStreamCount uint64
408408
}
409409

410-
func (p *basePhysicalPlan) cloneWithSelf(newSelf base2.PhysicalPlan) (*basePhysicalPlan, error) {
410+
func (p *basePhysicalPlan) cloneWithSelf(newSelf base.PhysicalPlan) (*basePhysicalPlan, error) {
411411
base := &basePhysicalPlan{
412412
Plan: p.Plan,
413413
self: newSelf,
@@ -431,7 +431,7 @@ func (p *basePhysicalPlan) cloneWithSelf(newSelf base2.PhysicalPlan) (*basePhysi
431431
}
432432

433433
// Clone implements op.PhysicalPlan interface.
434-
func (p *basePhysicalPlan) Clone() (base2.PhysicalPlan, error) {
434+
func (p *basePhysicalPlan) Clone() (base.PhysicalPlan, error) {
435435
return nil, errors.Errorf("%T doesn't support cloning", p.self)
436436
}
437437

@@ -487,7 +487,7 @@ func (p *basePhysicalPlan) GetActualProbeCnt(statsColl *execdetails.RuntimeStats
487487
return getActualProbeCntFromProbeParents(p.probeParents, statsColl)
488488
}
489489

490-
func (p *basePhysicalPlan) SetProbeParents(probeParents []base2.PhysicalPlan) {
490+
func (p *basePhysicalPlan) SetProbeParents(probeParents []base.PhysicalPlan) {
491491
p.probeParents = probeParents
492492
}
493493

@@ -525,12 +525,12 @@ func (p *baseLogicalPlan) rollBackTaskMap(ts uint64) {
525525
}
526526
}
527527

528-
func (p *baseLogicalPlan) getTask(prop *property.PhysicalProperty) base2.Task {
528+
func (p *baseLogicalPlan) getTask(prop *property.PhysicalProperty) base.Task {
529529
key := prop.HashCode()
530530
return p.taskMap[string(key)]
531531
}
532532

533-
func (p *baseLogicalPlan) storeTask(prop *property.PhysicalProperty, task base2.Task) {
533+
func (p *baseLogicalPlan) storeTask(prop *property.PhysicalProperty, task base.Task) {
534534
key := prop.HashCode()
535535
if p.SCtx().GetSessionVars().StmtCtx.StmtHints.TaskMapNeedBackUp() {
536536
// Empty string for useless change.
@@ -597,19 +597,19 @@ func (p *logicalSchemaProducer) BuildKeyInfo(selfSchema *expression.Schema, chil
597597
}
598598
}
599599

600-
func newBaseLogicalPlan(ctx base2.PlanContext, tp string, self LogicalPlan, qbOffset int) baseLogicalPlan {
600+
func newBaseLogicalPlan(ctx base.PlanContext, tp string, self LogicalPlan, qbOffset int) baseLogicalPlan {
601601
return baseLogicalPlan{
602-
taskMap: make(map[string]base2.Task),
602+
taskMap: make(map[string]base.Task),
603603
taskMapBak: make([]string, 0, 10),
604604
taskMapBakTS: make([]uint64, 0, 10),
605-
Plan: base.NewBasePlan(ctx, tp, qbOffset),
605+
Plan: baseimpl.NewBasePlan(ctx, tp, qbOffset),
606606
self: self,
607607
}
608608
}
609609

610-
func newBasePhysicalPlan(ctx base2.PlanContext, tp string, self base2.PhysicalPlan, offset int) basePhysicalPlan {
610+
func newBasePhysicalPlan(ctx base.PlanContext, tp string, self base.PhysicalPlan, offset int) basePhysicalPlan {
611611
return basePhysicalPlan{
612-
Plan: base.NewBasePlan(ctx, tp, offset),
612+
Plan: baseimpl.NewBasePlan(ctx, tp, offset),
613613
self: self,
614614
}
615615
}
@@ -655,7 +655,7 @@ func (p *baseLogicalPlan) Children() []LogicalPlan {
655655
}
656656

657657
// Children implements op.PhysicalPlan Children interface.
658-
func (p *basePhysicalPlan) Children() []base2.PhysicalPlan {
658+
func (p *basePhysicalPlan) Children() []base.PhysicalPlan {
659659
return p.children
660660
}
661661

@@ -665,7 +665,7 @@ func (p *baseLogicalPlan) SetChildren(children ...LogicalPlan) {
665665
}
666666

667667
// SetChildren implements op.PhysicalPlan SetChildren interface.
668-
func (p *basePhysicalPlan) SetChildren(children ...base2.PhysicalPlan) {
668+
func (p *basePhysicalPlan) SetChildren(children ...base.PhysicalPlan) {
669669
p.children = children
670670
}
671671

@@ -675,7 +675,7 @@ func (p *baseLogicalPlan) SetChild(i int, child LogicalPlan) {
675675
}
676676

677677
// SetChild implements op.PhysicalPlan SetChild interface.
678-
func (p *basePhysicalPlan) SetChild(i int, child base2.PhysicalPlan) {
678+
func (p *basePhysicalPlan) SetChild(i int, child base.PhysicalPlan) {
679679
p.children[i] = child
680680
}
681681

0 commit comments

Comments
 (0)