influxdb/pkg/data/gen/arrays.gen.go.tmpl

36 lines
800 B
Cheetah

package gen
import (
"github.com/influxdata/influxdb/tsdb"
"github.com/influxdata/influxdb/tsdb/tsm1"
)
{{range .}}
{{ $typename := print .name "Array" }}
{{ $tsdbname := print .Name "Array" }}
type {{.Name}}Values interface {
Copy(*tsdb.{{$tsdbname}})
}
type {{$typename}} struct {
tsdb.{{$tsdbname}}
}
func new{{$tsdbname}}Len(sz int) *{{$typename}} {
return &{{$typename}}{
{{$tsdbname}}: tsdb.{{$tsdbname}}{
Timestamps: make([]int64, sz),
Values: make([]{{.Type}}, sz),
},
}
}
func (a *{{$typename}}) Encode(b []byte) ([]byte, error) {
return tsm1.Encode{{$tsdbname}}Block(&a.{{$tsdbname}}, b)
}
func (a *{{$typename}}) Copy(dst *tsdb.{{$tsdbname}}) {
dst.Timestamps = append(dst.Timestamps[:0], a.Timestamps...)
dst.Values = append(dst.Values[:0], a.Values...)
}
{{end}}