-
Notifications
You must be signed in to change notification settings - Fork 219
Expand file tree
/
Copy pathplan_engine.go
More file actions
45 lines (40 loc) · 1.23 KB
/
plan_engine.go
File metadata and controls
45 lines (40 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* Radon
*
* Copyright 2018 The Radon Authors.
* Code is licensed under the GPLv3.
*
*/
package engine
import (
"backend"
"planner/builder"
"xcontext"
querypb "github.com/xelabs/go-mysqlstack/sqlparser/depends/query"
"github.com/xelabs/go-mysqlstack/xlog"
)
// PlanEngine interface.
type PlanEngine interface {
Execute(ctx *xcontext.ResultContext) error
execBindVars(ctx *xcontext.ResultContext, bindVars map[string]*querypb.BindVariable, wantfields bool) error
getFields(ctx *xcontext.ResultContext, bindVars map[string]*querypb.BindVariable) error
}
// BuildEngine used to build the executor tree.
func BuildEngine(log *xlog.Log, plan builder.PlanNode, txn backend.Transaction) PlanEngine {
var engine PlanEngine
switch node := plan.(type) {
case *builder.MergeNode:
engine = NewMergeEngine(log, node, txn)
case *builder.JoinNode:
joinEngine := NewJoinEngine(log, node, txn)
joinEngine.left = BuildEngine(log, node.Left, txn)
joinEngine.right = BuildEngine(log, node.Right, txn)
engine = joinEngine
case *builder.UnionNode:
unionEngine := NewUnionEngine(log, node, txn)
unionEngine.left = BuildEngine(log, node.Left, txn)
unionEngine.right = BuildEngine(log, node.Right, txn)
engine = unionEngine
}
return engine
}