File: filtercol.tmpl

package info (click to toggle)
golang-github-kshedden-dstream 0.0~git20190512.c4c4106-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 596 kB
  • sloc: makefile: 30
file content (60 lines) | stat: -rw-r--r-- 1,018 bytes parent folder | download
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 dstream

import (
	"time"
    "fmt"
)

func (fc *filterCol) Next() bool {

	if !fc.source.Next() {
		fc.nobsKnown = true
		return false
	}

	n := ilen(fc.source.GetPos(0))
	if n == 0 {
		return true
	}

	fc.keep = resizeBool(fc.keep, n)
	for i := range fc.keep {
		fc.keep[i] = true
	}

	vm := VarMap(fc.source)
	fc.filter(vm, fc.keep)

	fc.keeppos = fc.keeppos[0:0]
	for j := range fc.keep {
		if fc.keep[j] {
			fc.keeppos = append(fc.keeppos, j)
		}
	}
	fc.nobs += len(fc.keeppos)

	q := len(fc.keeppos)
	for k, na := range fc.source.Names() {
	    v := fc.source.Get(na)
		switch x := v.(type) {
	    	{{- range . }}
				case []{{ .Type }}:
					var u []{{ .Type }}
					if fc.bdata[k] != nil {
						u = fc.bdata[k].([]{{ .Type}})
					}
					u = resize{{ .Utype }}(u, q)
					u = u[0:q]
					for i, j := range fc.keeppos {
						u[i] = x[j]
					}
					fc.bdata[k] = u
		    {{- end }}
		    default:
				msg := fmt.Sprintf("Unkown data type '%T'\n", v)
		        panic(msg)
	    }
    }

	return true
}