-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmaterialize.go
53 lines (48 loc) · 1014 Bytes
/
materialize.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
package exectoy
// materializeOp takes dataFlows and turns them into tuples.
type materializeOp struct {
input ExecOp
cols []int
rowsBuf []tuple
rows []tuple
}
func (t *materializeOp) Init() {
if t.cols == nil {
panic("didn't set cols on materializeOp")
}
t.rowsBuf = make([]tuple, batchRowLen)
for i := range t.rowsBuf {
t.rowsBuf[i] = make(tuple, len(t.cols))
}
t.rows = t.rowsBuf[:0]
}
func (t *materializeOp) NextTuple() tuple {
if len(t.rows) == 0 {
flow := t.input.Next()
if flow.n == 0 {
return nil
}
t.rows = t.rowsBuf
if flow.useSel {
for outIdx, cIdx := range t.cols {
col := flow.b[cIdx].(intColumn)
for s := 0; s < flow.n; s++ {
i := flow.sel[s]
n := col[i]
t.rows[s][outIdx] = n
}
}
} else {
for outIdx, cIdx := range t.cols {
col := flow.b[cIdx].(intColumn)
for i := 0; i < flow.n; i++ {
t.rows[i][outIdx] = col[i]
}
}
}
t.rows = t.rows[:flow.n]
}
ret := t.rows[0]
t.rows = t.rows[1:]
return ret
}