Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

distribute framework: add planner #46395

Merged
merged 16 commits into from
Sep 4, 2023
Prev Previous commit
Next Next commit
address comment
  • Loading branch information
GMHDBJD committed Sep 1, 2023
commit 977899126f7ecc488af7ec40c2e636b610d760d6
5 changes: 5 additions & 0 deletions disttask/framework/planner/planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ import "github.com/pingcap/tidb/disttask/framework/storage"
// Planner represents a distribute plan planner.
type Planner struct{}

// NewPlanner creates a new planer instance.
func NewPlanner() *Planner {
return &Planner{}
}

// Run runs the distribute plan.
func (*Planner) Run(planCtx PlanCtx, plan LogicalPlan) (int64, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No usage?

globalTaskManager, err := storage.GetTaskManager()
Expand Down
14 changes: 9 additions & 5 deletions disttask/importinto/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/pingcap/errors"
"github.com/pingcap/tidb/br/pkg/lightning/checkpoints"
"github.com/pingcap/tidb/disttask/framework/handle"
"github.com/pingcap/tidb/disttask/framework/planner"
"github.com/pingcap/tidb/disttask/framework/proto"
"github.com/pingcap/tidb/disttask/framework/storage"
"github.com/pingcap/tidb/domain/infosync"
Expand Down Expand Up @@ -185,12 +186,15 @@ func (ti *DistImporter) SubmitTask(ctx context.Context) (int64, *proto.Task, err
EligibleInstances: instances,
ChunkMap: ti.chunkMap,
}
taskMeta, err2 := logicalPlan.ToTaskMeta()
if err2 != nil {
return err2
planCtx := planner.PlanCtx{
Ctx: ctx,
SessionCtx: se,
TaskKey: TaskKey(jobID),
TaskType: proto.ImportInto,
ThreadCnt: int(plan.ThreadCnt),
}
taskID, err2 = globalTaskManager.AddGlobalTaskWithSession(se, TaskKey(jobID), proto.ImportInto,
int(plan.ThreadCnt), taskMeta)
p := planner.NewPlanner()
taskID, err2 = p.Run(planCtx, logicalPlan)
if err2 != nil {
return err2
}
Expand Down