Skip to content

Commit

Permalink
planner: rename base plan implemention's pkg from base to baseImpl (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
AilinKid authored Apr 17, 2024
1 parent 3b6a9db commit ecb8a9e
Show file tree
Hide file tree
Showing 9 changed files with 247 additions and 247 deletions.
2 changes: 1 addition & 1 deletion pkg/planner/core/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ go_library(
"//pkg/planner/context",
"//pkg/planner/core/base",
"//pkg/planner/core/metrics",
"//pkg/planner/core/operator/base",
"//pkg/planner/core/operator/baseimpl",
"//pkg/planner/funcdep",
"//pkg/planner/property",
"//pkg/planner/util",
Expand Down
184 changes: 92 additions & 92 deletions pkg/planner/core/initialize.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "base",
name = "baseimpl",
srcs = ["plan.go"],
importpath = "github.com/pingcap/tidb/pkg/planner/core/operator/base",
importpath = "github.com/pingcap/tidb/pkg/planner/core/operator/baseimpl",
visibility = ["//visibility:public"],
deps = [
"//pkg/expression",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package base
package baseimpl

import (
"fmt"
Expand Down
76 changes: 38 additions & 38 deletions pkg/planner/core/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"github.com/pingcap/tidb/pkg/expression"
"github.com/pingcap/tidb/pkg/kv"
"github.com/pingcap/tidb/pkg/planner/cardinality"
base2 "github.com/pingcap/tidb/pkg/planner/core/base"
"github.com/pingcap/tidb/pkg/planner/core/operator/base"
"github.com/pingcap/tidb/pkg/planner/core/base"
"github.com/pingcap/tidb/pkg/planner/core/operator/baseimpl"
fd "github.com/pingcap/tidb/pkg/planner/funcdep"
"github.com/pingcap/tidb/pkg/planner/property"
"github.com/pingcap/tidb/pkg/planner/util"
Expand All @@ -35,15 +35,15 @@ import (
)

// AsSctx converts PlanContext to sessionctx.Context.
func AsSctx(pctx base2.PlanContext) (sessionctx.Context, error) {
func AsSctx(pctx base.PlanContext) (sessionctx.Context, error) {
sctx, ok := pctx.(sessionctx.Context)
if !ok {
return nil, errors.New("the current PlanContext cannot be converted to sessionctx.Context")
}
return sctx, nil
}

func enforceProperty(p *property.PhysicalProperty, tsk base2.Task, ctx base2.PlanContext) base2.Task {
func enforceProperty(p *property.PhysicalProperty, tsk base.Task, ctx base.PlanContext) base.Task {
if p.TaskTp == property.MppTaskType {
mpp, ok := tsk.(*MppTask)
if !ok || mpp.Invalid() {
Expand Down Expand Up @@ -75,7 +75,7 @@ func enforceProperty(p *property.PhysicalProperty, tsk base2.Task, ctx base2.Pla
}

// optimizeByShuffle insert `PhysicalShuffle` to optimize performance by running in a parallel manner.
func optimizeByShuffle(tsk base2.Task, ctx base2.PlanContext) base2.Task {
func optimizeByShuffle(tsk base.Task, ctx base.PlanContext) base.Task {
if tsk.Plan() == nil {
return tsk
}
Expand All @@ -97,7 +97,7 @@ func optimizeByShuffle(tsk base2.Task, ctx base2.PlanContext) base2.Task {
return tsk
}

func optimizeByShuffle4Window(pp *PhysicalWindow, ctx base2.PlanContext) *PhysicalShuffle {
func optimizeByShuffle4Window(pp *PhysicalWindow, ctx base.PlanContext) *PhysicalShuffle {
concurrency := ctx.GetSessionVars().WindowConcurrency()
if concurrency <= 1 {
return nil
Expand Down Expand Up @@ -128,15 +128,15 @@ func optimizeByShuffle4Window(pp *PhysicalWindow, ctx base2.PlanContext) *Physic
reqProp := &property.PhysicalProperty{ExpectedCnt: math.MaxFloat64}
shuffle := PhysicalShuffle{
Concurrency: concurrency,
Tails: []base2.PhysicalPlan{tail},
DataSources: []base2.PhysicalPlan{dataSource},
Tails: []base.PhysicalPlan{tail},
DataSources: []base.PhysicalPlan{dataSource},
SplitterType: PartitionHashSplitterType,
ByItemArrays: [][]expression.Expression{byItems},
}.Init(ctx, pp.StatsInfo(), pp.QueryBlockOffset(), reqProp)
return shuffle
}

func optimizeByShuffle4StreamAgg(pp *PhysicalStreamAgg, ctx base2.PlanContext) *PhysicalShuffle {
func optimizeByShuffle4StreamAgg(pp *PhysicalStreamAgg, ctx base.PlanContext) *PhysicalShuffle {
concurrency := ctx.GetSessionVars().StreamAggConcurrency()
if concurrency <= 1 {
return nil
Expand Down Expand Up @@ -165,23 +165,23 @@ func optimizeByShuffle4StreamAgg(pp *PhysicalStreamAgg, ctx base2.PlanContext) *
reqProp := &property.PhysicalProperty{ExpectedCnt: math.MaxFloat64}
shuffle := PhysicalShuffle{
Concurrency: concurrency,
Tails: []base2.PhysicalPlan{tail},
DataSources: []base2.PhysicalPlan{dataSource},
Tails: []base.PhysicalPlan{tail},
DataSources: []base.PhysicalPlan{dataSource},
SplitterType: PartitionHashSplitterType,
ByItemArrays: [][]expression.Expression{util.CloneExprs(pp.GroupByItems)},
}.Init(ctx, pp.StatsInfo(), pp.QueryBlockOffset(), reqProp)
return shuffle
}

func optimizeByShuffle4MergeJoin(pp *PhysicalMergeJoin, ctx base2.PlanContext) *PhysicalShuffle {
func optimizeByShuffle4MergeJoin(pp *PhysicalMergeJoin, ctx base.PlanContext) *PhysicalShuffle {
concurrency := ctx.GetSessionVars().MergeJoinConcurrency()
if concurrency <= 1 {
return nil
}

children := pp.Children()
dataSources := make([]base2.PhysicalPlan, len(children))
tails := make([]base2.PhysicalPlan, len(children))
dataSources := make([]base.PhysicalPlan, len(children))
tails := make([]base.PhysicalPlan, len(children))

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

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

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

// ExtractCorrelatedCols extracts correlated columns inside the LogicalPlan.
ExtractCorrelatedCols() []*expression.CorrelatedColumn
Expand Down Expand Up @@ -311,9 +311,9 @@ type LogicalPlan interface {
}

type baseLogicalPlan struct {
base.Plan
baseimpl.Plan

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

func getEstimatedProbeCntFromProbeParents(probeParents []base2.PhysicalPlan) float64 {
func getEstimatedProbeCntFromProbeParents(probeParents []base.PhysicalPlan) float64 {
res := float64(1)
for _, pp := range probeParents {
switch pp.(type) {
Expand All @@ -363,7 +363,7 @@ func getEstimatedProbeCntFromProbeParents(probeParents []base2.PhysicalPlan) flo
return res
}

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

type basePhysicalPlan struct {
base.Plan
baseimpl.Plan

childrenReqProps []*property.PhysicalProperty
self base2.PhysicalPlan
children []base2.PhysicalPlan
self base.PhysicalPlan
children []base.PhysicalPlan

// used by the new cost interface
planCostInit bool
Expand All @@ -399,15 +399,15 @@ type basePhysicalPlan struct {

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

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

func (p *basePhysicalPlan) cloneWithSelf(newSelf base2.PhysicalPlan) (*basePhysicalPlan, error) {
func (p *basePhysicalPlan) cloneWithSelf(newSelf base.PhysicalPlan) (*basePhysicalPlan, error) {
base := &basePhysicalPlan{
Plan: p.Plan,
self: newSelf,
Expand All @@ -431,7 +431,7 @@ func (p *basePhysicalPlan) cloneWithSelf(newSelf base2.PhysicalPlan) (*basePhysi
}

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

Expand Down Expand Up @@ -487,7 +487,7 @@ func (p *basePhysicalPlan) GetActualProbeCnt(statsColl *execdetails.RuntimeStats
return getActualProbeCntFromProbeParents(p.probeParents, statsColl)
}

func (p *basePhysicalPlan) SetProbeParents(probeParents []base2.PhysicalPlan) {
func (p *basePhysicalPlan) SetProbeParents(probeParents []base.PhysicalPlan) {
p.probeParents = probeParents
}

Expand Down Expand Up @@ -525,12 +525,12 @@ func (p *baseLogicalPlan) rollBackTaskMap(ts uint64) {
}
}

func (p *baseLogicalPlan) getTask(prop *property.PhysicalProperty) base2.Task {
func (p *baseLogicalPlan) getTask(prop *property.PhysicalProperty) base.Task {
key := prop.HashCode()
return p.taskMap[string(key)]
}

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

func newBaseLogicalPlan(ctx base2.PlanContext, tp string, self LogicalPlan, qbOffset int) baseLogicalPlan {
func newBaseLogicalPlan(ctx base.PlanContext, tp string, self LogicalPlan, qbOffset int) baseLogicalPlan {
return baseLogicalPlan{
taskMap: make(map[string]base2.Task),
taskMap: make(map[string]base.Task),
taskMapBak: make([]string, 0, 10),
taskMapBakTS: make([]uint64, 0, 10),
Plan: base.NewBasePlan(ctx, tp, qbOffset),
Plan: baseimpl.NewBasePlan(ctx, tp, qbOffset),
self: self,
}
}

func newBasePhysicalPlan(ctx base2.PlanContext, tp string, self base2.PhysicalPlan, offset int) basePhysicalPlan {
func newBasePhysicalPlan(ctx base.PlanContext, tp string, self base.PhysicalPlan, offset int) basePhysicalPlan {
return basePhysicalPlan{
Plan: base.NewBasePlan(ctx, tp, offset),
Plan: baseimpl.NewBasePlan(ctx, tp, offset),
self: self,
}
}
Expand Down Expand Up @@ -655,7 +655,7 @@ func (p *baseLogicalPlan) Children() []LogicalPlan {
}

// Children implements op.PhysicalPlan Children interface.
func (p *basePhysicalPlan) Children() []base2.PhysicalPlan {
func (p *basePhysicalPlan) Children() []base.PhysicalPlan {
return p.children
}

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

// SetChildren implements op.PhysicalPlan SetChildren interface.
func (p *basePhysicalPlan) SetChildren(children ...base2.PhysicalPlan) {
func (p *basePhysicalPlan) SetChildren(children ...base.PhysicalPlan) {
p.children = children
}

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

// SetChild implements op.PhysicalPlan SetChild interface.
func (p *basePhysicalPlan) SetChild(i int, child base2.PhysicalPlan) {
func (p *basePhysicalPlan) SetChild(i int, child base.PhysicalPlan) {
p.children[i] = child
}

Expand Down
Loading

0 comments on commit ecb8a9e

Please sign in to comment.