-
Notifications
You must be signed in to change notification settings - Fork 219
Expand file tree
/
Copy pathoperator.go
More file actions
48 lines (43 loc) · 1.06 KB
/
operator.go
File metadata and controls
48 lines (43 loc) · 1.06 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
46
47
48
/*
* Radon
*
* Copyright 2018 The Radon Authors.
* Code is licensed under the GPLv3.
*
*/
package operator
import (
"planner/builder"
"xcontext"
"github.com/xelabs/go-mysqlstack/xlog"
)
// Operator interface.
type Operator interface {
Execute(*xcontext.ResultContext) error
}
// ExecSubPlan used to execute all the children plan.
func ExecSubPlan(log *xlog.Log, node builder.PlanNode, ctx *xcontext.ResultContext) error {
subPlanTree := node.Children()
if subPlanTree != nil {
for _, subPlan := range subPlanTree {
switch subPlan.Type() {
case builder.ChildTypeAggregate:
aggrOperator := NewAggregateOperator(log, subPlan)
if err := aggrOperator.Execute(ctx); err != nil {
return err
}
case builder.ChildTypeOrderby:
orderByOperator := NewOrderByOperator(log, subPlan)
if err := orderByOperator.Execute(ctx); err != nil {
return err
}
case builder.ChildTypeLimit:
limitOperator := NewLimitOperator(log, subPlan)
if err := limitOperator.Execute(ctx); err != nil {
return err
}
}
}
}
return nil
}