-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
60 lines (51 loc) · 1.06 KB
/
main.go
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
49
50
51
52
53
54
55
56
57
58
59
60
package executor
import "fmt"
import "bigpot/access"
import "bigpot/planner"
type Executor interface {
Start()
Execute()
End()
}
type ExecutorImpl struct {
planRoot *planner.PlanRoot
TupleDesc *access.TupleDesc
execRoot Node
}
func NewExecutor(planRoot *planner.PlanRoot) *ExecutorImpl {
return &ExecutorImpl{
planRoot: planRoot,
}
}
func (exec *ExecutorImpl) initExecNode(node planner.Node) Node{
switch node.(type) {
case *planner.SeqScan:
scan := &SeqScan{}
scan.SeqScan = *(node.(*planner.SeqScan))
scan.executor = exec
scan.Init()
/* TODO: return Exec node */
return Node(scan)
}
panic("unknown node type")
}
func (exec *ExecutorImpl) Start() {
exec.execRoot = exec.initExecNode(exec.planRoot.Plan)
}
func (exec *ExecutorImpl) Execute() {
for {
tuple := exec.execRoot.Exec()
if tuple == nil {
break
}
/* TODO: Receiver */
for attnum, _ := range exec.TupleDesc.Attrs {
datum := tuple.Get(int32(attnum + 1))
fmt.Printf("%s ", datum.ToString())
}
fmt.Println("")
}
}
func (exec *ExecutorImpl) End() {
exec.execRoot.End()
}