influxdb/storage/reads/table.gen.go

1021 lines
16 KiB
Go

// Generated by tmpl
// https://github.com/benbjohnson/tmpl
//
// DO NOT EDIT!
// Source: table.gen.go.tmpl
package reads
import (
"github.com/influxdata/flux"
"github.com/influxdata/flux/execute"
"github.com/influxdata/platform/models"
"github.com/influxdata/platform/tsdb/cursors"
"github.com/pkg/errors"
)
//
// *********** Float ***********
//
type floatTable struct {
table
cur cursors.FloatArrayCursor
valBuf []float64
}
func newFloatTable(
cur cursors.FloatArrayCursor,
bounds execute.Bounds,
key flux.GroupKey,
cols []flux.ColMeta,
tags models.Tags,
defs [][]byte,
) *floatTable {
t := &floatTable{
table: newTable(bounds, key, cols, defs),
cur: cur,
}
t.readTags(tags)
t.more = t.advance()
return t
}
func (t *floatTable) Close() {
if t.cur != nil {
t.cur.Close()
t.cur = nil
}
if t.done != nil {
close(t.done)
t.done = nil
}
}
func (t *floatTable) Do(f func(flux.ColReader) error) error {
defer t.Close()
if t.more {
t.err = f(t)
for t.err == nil && t.advance() {
t.err = f(t)
}
}
return t.err
}
func (t *floatTable) advance() bool {
a := t.cur.Next()
t.l = a.Len()
if t.l == 0 {
return false
}
if cap(t.timeBuf) < t.l {
t.timeBuf = make([]execute.Time, t.l)
} else {
t.timeBuf = t.timeBuf[:t.l]
}
for i := range a.Timestamps {
t.timeBuf[i] = execute.Time(a.Timestamps[i])
}
if cap(t.valBuf) < t.l {
t.valBuf = make([]float64, t.l)
} else {
t.valBuf = t.valBuf[:t.l]
}
copy(t.valBuf, a.Values)
t.colBufs[timeColIdx] = t.timeBuf
t.colBufs[valueColIdx] = t.valBuf
t.appendTags()
t.appendBounds()
t.empty = false
return true
}
// group table
type floatGroupTable struct {
table
gc GroupCursor
cur cursors.FloatArrayCursor
valBuf []float64
}
func newFloatGroupTable(
gc GroupCursor,
cur cursors.FloatArrayCursor,
bounds execute.Bounds,
key flux.GroupKey,
cols []flux.ColMeta,
tags models.Tags,
defs [][]byte,
) *floatGroupTable {
t := &floatGroupTable{
table: newTable(bounds, key, cols, defs),
gc: gc,
cur: cur,
}
t.readTags(tags)
t.more = t.advance()
return t
}
func (t *floatGroupTable) Close() {
if t.cur != nil {
t.cur.Close()
t.cur = nil
}
if t.gc != nil {
t.gc.Close()
t.gc = nil
}
if t.done != nil {
close(t.done)
t.done = nil
}
}
func (t *floatGroupTable) Do(f func(flux.ColReader) error) error {
defer t.Close()
if t.more {
t.err = f(t)
for t.err == nil && t.advance() {
t.err = f(t)
}
}
return t.err
}
func (t *floatGroupTable) advance() bool {
RETRY:
a := t.cur.Next()
t.l = a.Len()
if t.l == 0 {
if t.advanceCursor() {
goto RETRY
}
return false
}
if cap(t.timeBuf) < t.l {
t.timeBuf = make([]execute.Time, t.l)
} else {
t.timeBuf = t.timeBuf[:t.l]
}
for i := range a.Timestamps {
t.timeBuf[i] = execute.Time(a.Timestamps[i])
}
if cap(t.valBuf) < t.l {
t.valBuf = make([]float64, t.l)
} else {
t.valBuf = t.valBuf[:t.l]
}
copy(t.valBuf, a.Values)
t.colBufs[timeColIdx] = t.timeBuf
t.colBufs[valueColIdx] = t.valBuf
t.appendTags()
t.appendBounds()
t.empty = false
return true
}
func (t *floatGroupTable) advanceCursor() bool {
t.cur.Close()
t.cur = nil
for t.gc.Next() {
cur := t.gc.Cursor()
if cur == nil {
continue
}
if typedCur, ok := cur.(cursors.FloatArrayCursor); !ok {
// TODO(sgc): error or skip?
cur.Close()
t.err = errors.Errorf("expected float cursor type, got %T", cur)
return false
} else {
t.readTags(t.gc.Tags())
t.cur = typedCur
return true
}
}
return false
}
//
// *********** Integer ***********
//
type integerTable struct {
table
cur cursors.IntegerArrayCursor
valBuf []int64
}
func newIntegerTable(
cur cursors.IntegerArrayCursor,
bounds execute.Bounds,
key flux.GroupKey,
cols []flux.ColMeta,
tags models.Tags,
defs [][]byte,
) *integerTable {
t := &integerTable{
table: newTable(bounds, key, cols, defs),
cur: cur,
}
t.readTags(tags)
t.more = t.advance()
return t
}
func (t *integerTable) Close() {
if t.cur != nil {
t.cur.Close()
t.cur = nil
}
if t.done != nil {
close(t.done)
t.done = nil
}
}
func (t *integerTable) Do(f func(flux.ColReader) error) error {
defer t.Close()
if t.more {
t.err = f(t)
for t.err == nil && t.advance() {
t.err = f(t)
}
}
return t.err
}
func (t *integerTable) advance() bool {
a := t.cur.Next()
t.l = a.Len()
if t.l == 0 {
return false
}
if cap(t.timeBuf) < t.l {
t.timeBuf = make([]execute.Time, t.l)
} else {
t.timeBuf = t.timeBuf[:t.l]
}
for i := range a.Timestamps {
t.timeBuf[i] = execute.Time(a.Timestamps[i])
}
if cap(t.valBuf) < t.l {
t.valBuf = make([]int64, t.l)
} else {
t.valBuf = t.valBuf[:t.l]
}
copy(t.valBuf, a.Values)
t.colBufs[timeColIdx] = t.timeBuf
t.colBufs[valueColIdx] = t.valBuf
t.appendTags()
t.appendBounds()
t.empty = false
return true
}
// group table
type integerGroupTable struct {
table
gc GroupCursor
cur cursors.IntegerArrayCursor
valBuf []int64
}
func newIntegerGroupTable(
gc GroupCursor,
cur cursors.IntegerArrayCursor,
bounds execute.Bounds,
key flux.GroupKey,
cols []flux.ColMeta,
tags models.Tags,
defs [][]byte,
) *integerGroupTable {
t := &integerGroupTable{
table: newTable(bounds, key, cols, defs),
gc: gc,
cur: cur,
}
t.readTags(tags)
t.more = t.advance()
return t
}
func (t *integerGroupTable) Close() {
if t.cur != nil {
t.cur.Close()
t.cur = nil
}
if t.gc != nil {
t.gc.Close()
t.gc = nil
}
if t.done != nil {
close(t.done)
t.done = nil
}
}
func (t *integerGroupTable) Do(f func(flux.ColReader) error) error {
defer t.Close()
if t.more {
t.err = f(t)
for t.err == nil && t.advance() {
t.err = f(t)
}
}
return t.err
}
func (t *integerGroupTable) advance() bool {
RETRY:
a := t.cur.Next()
t.l = a.Len()
if t.l == 0 {
if t.advanceCursor() {
goto RETRY
}
return false
}
if cap(t.timeBuf) < t.l {
t.timeBuf = make([]execute.Time, t.l)
} else {
t.timeBuf = t.timeBuf[:t.l]
}
for i := range a.Timestamps {
t.timeBuf[i] = execute.Time(a.Timestamps[i])
}
if cap(t.valBuf) < t.l {
t.valBuf = make([]int64, t.l)
} else {
t.valBuf = t.valBuf[:t.l]
}
copy(t.valBuf, a.Values)
t.colBufs[timeColIdx] = t.timeBuf
t.colBufs[valueColIdx] = t.valBuf
t.appendTags()
t.appendBounds()
t.empty = false
return true
}
func (t *integerGroupTable) advanceCursor() bool {
t.cur.Close()
t.cur = nil
for t.gc.Next() {
cur := t.gc.Cursor()
if cur == nil {
continue
}
if typedCur, ok := cur.(cursors.IntegerArrayCursor); !ok {
// TODO(sgc): error or skip?
cur.Close()
t.err = errors.Errorf("expected integer cursor type, got %T", cur)
return false
} else {
t.readTags(t.gc.Tags())
t.cur = typedCur
return true
}
}
return false
}
//
// *********** Unsigned ***********
//
type unsignedTable struct {
table
cur cursors.UnsignedArrayCursor
valBuf []uint64
}
func newUnsignedTable(
cur cursors.UnsignedArrayCursor,
bounds execute.Bounds,
key flux.GroupKey,
cols []flux.ColMeta,
tags models.Tags,
defs [][]byte,
) *unsignedTable {
t := &unsignedTable{
table: newTable(bounds, key, cols, defs),
cur: cur,
}
t.readTags(tags)
t.more = t.advance()
return t
}
func (t *unsignedTable) Close() {
if t.cur != nil {
t.cur.Close()
t.cur = nil
}
if t.done != nil {
close(t.done)
t.done = nil
}
}
func (t *unsignedTable) Do(f func(flux.ColReader) error) error {
defer t.Close()
if t.more {
t.err = f(t)
for t.err == nil && t.advance() {
t.err = f(t)
}
}
return t.err
}
func (t *unsignedTable) advance() bool {
a := t.cur.Next()
t.l = a.Len()
if t.l == 0 {
return false
}
if cap(t.timeBuf) < t.l {
t.timeBuf = make([]execute.Time, t.l)
} else {
t.timeBuf = t.timeBuf[:t.l]
}
for i := range a.Timestamps {
t.timeBuf[i] = execute.Time(a.Timestamps[i])
}
if cap(t.valBuf) < t.l {
t.valBuf = make([]uint64, t.l)
} else {
t.valBuf = t.valBuf[:t.l]
}
copy(t.valBuf, a.Values)
t.colBufs[timeColIdx] = t.timeBuf
t.colBufs[valueColIdx] = t.valBuf
t.appendTags()
t.appendBounds()
t.empty = false
return true
}
// group table
type unsignedGroupTable struct {
table
gc GroupCursor
cur cursors.UnsignedArrayCursor
valBuf []uint64
}
func newUnsignedGroupTable(
gc GroupCursor,
cur cursors.UnsignedArrayCursor,
bounds execute.Bounds,
key flux.GroupKey,
cols []flux.ColMeta,
tags models.Tags,
defs [][]byte,
) *unsignedGroupTable {
t := &unsignedGroupTable{
table: newTable(bounds, key, cols, defs),
gc: gc,
cur: cur,
}
t.readTags(tags)
t.more = t.advance()
return t
}
func (t *unsignedGroupTable) Close() {
if t.cur != nil {
t.cur.Close()
t.cur = nil
}
if t.gc != nil {
t.gc.Close()
t.gc = nil
}
if t.done != nil {
close(t.done)
t.done = nil
}
}
func (t *unsignedGroupTable) Do(f func(flux.ColReader) error) error {
defer t.Close()
if t.more {
t.err = f(t)
for t.err == nil && t.advance() {
t.err = f(t)
}
}
return t.err
}
func (t *unsignedGroupTable) advance() bool {
RETRY:
a := t.cur.Next()
t.l = a.Len()
if t.l == 0 {
if t.advanceCursor() {
goto RETRY
}
return false
}
if cap(t.timeBuf) < t.l {
t.timeBuf = make([]execute.Time, t.l)
} else {
t.timeBuf = t.timeBuf[:t.l]
}
for i := range a.Timestamps {
t.timeBuf[i] = execute.Time(a.Timestamps[i])
}
if cap(t.valBuf) < t.l {
t.valBuf = make([]uint64, t.l)
} else {
t.valBuf = t.valBuf[:t.l]
}
copy(t.valBuf, a.Values)
t.colBufs[timeColIdx] = t.timeBuf
t.colBufs[valueColIdx] = t.valBuf
t.appendTags()
t.appendBounds()
t.empty = false
return true
}
func (t *unsignedGroupTable) advanceCursor() bool {
t.cur.Close()
t.cur = nil
for t.gc.Next() {
cur := t.gc.Cursor()
if cur == nil {
continue
}
if typedCur, ok := cur.(cursors.UnsignedArrayCursor); !ok {
// TODO(sgc): error or skip?
cur.Close()
t.err = errors.Errorf("expected unsigned cursor type, got %T", cur)
return false
} else {
t.readTags(t.gc.Tags())
t.cur = typedCur
return true
}
}
return false
}
//
// *********** String ***********
//
type stringTable struct {
table
cur cursors.StringArrayCursor
valBuf []string
}
func newStringTable(
cur cursors.StringArrayCursor,
bounds execute.Bounds,
key flux.GroupKey,
cols []flux.ColMeta,
tags models.Tags,
defs [][]byte,
) *stringTable {
t := &stringTable{
table: newTable(bounds, key, cols, defs),
cur: cur,
}
t.readTags(tags)
t.more = t.advance()
return t
}
func (t *stringTable) Close() {
if t.cur != nil {
t.cur.Close()
t.cur = nil
}
if t.done != nil {
close(t.done)
t.done = nil
}
}
func (t *stringTable) Do(f func(flux.ColReader) error) error {
defer t.Close()
if t.more {
t.err = f(t)
for t.err == nil && t.advance() {
t.err = f(t)
}
}
return t.err
}
func (t *stringTable) advance() bool {
a := t.cur.Next()
t.l = a.Len()
if t.l == 0 {
return false
}
if cap(t.timeBuf) < t.l {
t.timeBuf = make([]execute.Time, t.l)
} else {
t.timeBuf = t.timeBuf[:t.l]
}
for i := range a.Timestamps {
t.timeBuf[i] = execute.Time(a.Timestamps[i])
}
if cap(t.valBuf) < t.l {
t.valBuf = make([]string, t.l)
} else {
t.valBuf = t.valBuf[:t.l]
}
copy(t.valBuf, a.Values)
t.colBufs[timeColIdx] = t.timeBuf
t.colBufs[valueColIdx] = t.valBuf
t.appendTags()
t.appendBounds()
t.empty = false
return true
}
// group table
type stringGroupTable struct {
table
gc GroupCursor
cur cursors.StringArrayCursor
valBuf []string
}
func newStringGroupTable(
gc GroupCursor,
cur cursors.StringArrayCursor,
bounds execute.Bounds,
key flux.GroupKey,
cols []flux.ColMeta,
tags models.Tags,
defs [][]byte,
) *stringGroupTable {
t := &stringGroupTable{
table: newTable(bounds, key, cols, defs),
gc: gc,
cur: cur,
}
t.readTags(tags)
t.more = t.advance()
return t
}
func (t *stringGroupTable) Close() {
if t.cur != nil {
t.cur.Close()
t.cur = nil
}
if t.gc != nil {
t.gc.Close()
t.gc = nil
}
if t.done != nil {
close(t.done)
t.done = nil
}
}
func (t *stringGroupTable) Do(f func(flux.ColReader) error) error {
defer t.Close()
if t.more {
t.err = f(t)
for t.err == nil && t.advance() {
t.err = f(t)
}
}
return t.err
}
func (t *stringGroupTable) advance() bool {
RETRY:
a := t.cur.Next()
t.l = a.Len()
if t.l == 0 {
if t.advanceCursor() {
goto RETRY
}
return false
}
if cap(t.timeBuf) < t.l {
t.timeBuf = make([]execute.Time, t.l)
} else {
t.timeBuf = t.timeBuf[:t.l]
}
for i := range a.Timestamps {
t.timeBuf[i] = execute.Time(a.Timestamps[i])
}
if cap(t.valBuf) < t.l {
t.valBuf = make([]string, t.l)
} else {
t.valBuf = t.valBuf[:t.l]
}
copy(t.valBuf, a.Values)
t.colBufs[timeColIdx] = t.timeBuf
t.colBufs[valueColIdx] = t.valBuf
t.appendTags()
t.appendBounds()
t.empty = false
return true
}
func (t *stringGroupTable) advanceCursor() bool {
t.cur.Close()
t.cur = nil
for t.gc.Next() {
cur := t.gc.Cursor()
if cur == nil {
continue
}
if typedCur, ok := cur.(cursors.StringArrayCursor); !ok {
// TODO(sgc): error or skip?
cur.Close()
t.err = errors.Errorf("expected string cursor type, got %T", cur)
return false
} else {
t.readTags(t.gc.Tags())
t.cur = typedCur
return true
}
}
return false
}
//
// *********** Boolean ***********
//
type booleanTable struct {
table
cur cursors.BooleanArrayCursor
valBuf []bool
}
func newBooleanTable(
cur cursors.BooleanArrayCursor,
bounds execute.Bounds,
key flux.GroupKey,
cols []flux.ColMeta,
tags models.Tags,
defs [][]byte,
) *booleanTable {
t := &booleanTable{
table: newTable(bounds, key, cols, defs),
cur: cur,
}
t.readTags(tags)
t.more = t.advance()
return t
}
func (t *booleanTable) Close() {
if t.cur != nil {
t.cur.Close()
t.cur = nil
}
if t.done != nil {
close(t.done)
t.done = nil
}
}
func (t *booleanTable) Do(f func(flux.ColReader) error) error {
defer t.Close()
if t.more {
t.err = f(t)
for t.err == nil && t.advance() {
t.err = f(t)
}
}
return t.err
}
func (t *booleanTable) advance() bool {
a := t.cur.Next()
t.l = a.Len()
if t.l == 0 {
return false
}
if cap(t.timeBuf) < t.l {
t.timeBuf = make([]execute.Time, t.l)
} else {
t.timeBuf = t.timeBuf[:t.l]
}
for i := range a.Timestamps {
t.timeBuf[i] = execute.Time(a.Timestamps[i])
}
if cap(t.valBuf) < t.l {
t.valBuf = make([]bool, t.l)
} else {
t.valBuf = t.valBuf[:t.l]
}
copy(t.valBuf, a.Values)
t.colBufs[timeColIdx] = t.timeBuf
t.colBufs[valueColIdx] = t.valBuf
t.appendTags()
t.appendBounds()
t.empty = false
return true
}
// group table
type booleanGroupTable struct {
table
gc GroupCursor
cur cursors.BooleanArrayCursor
valBuf []bool
}
func newBooleanGroupTable(
gc GroupCursor,
cur cursors.BooleanArrayCursor,
bounds execute.Bounds,
key flux.GroupKey,
cols []flux.ColMeta,
tags models.Tags,
defs [][]byte,
) *booleanGroupTable {
t := &booleanGroupTable{
table: newTable(bounds, key, cols, defs),
gc: gc,
cur: cur,
}
t.readTags(tags)
t.more = t.advance()
return t
}
func (t *booleanGroupTable) Close() {
if t.cur != nil {
t.cur.Close()
t.cur = nil
}
if t.gc != nil {
t.gc.Close()
t.gc = nil
}
if t.done != nil {
close(t.done)
t.done = nil
}
}
func (t *booleanGroupTable) Do(f func(flux.ColReader) error) error {
defer t.Close()
if t.more {
t.err = f(t)
for t.err == nil && t.advance() {
t.err = f(t)
}
}
return t.err
}
func (t *booleanGroupTable) advance() bool {
RETRY:
a := t.cur.Next()
t.l = a.Len()
if t.l == 0 {
if t.advanceCursor() {
goto RETRY
}
return false
}
if cap(t.timeBuf) < t.l {
t.timeBuf = make([]execute.Time, t.l)
} else {
t.timeBuf = t.timeBuf[:t.l]
}
for i := range a.Timestamps {
t.timeBuf[i] = execute.Time(a.Timestamps[i])
}
if cap(t.valBuf) < t.l {
t.valBuf = make([]bool, t.l)
} else {
t.valBuf = t.valBuf[:t.l]
}
copy(t.valBuf, a.Values)
t.colBufs[timeColIdx] = t.timeBuf
t.colBufs[valueColIdx] = t.valBuf
t.appendTags()
t.appendBounds()
t.empty = false
return true
}
func (t *booleanGroupTable) advanceCursor() bool {
t.cur.Close()
t.cur = nil
for t.gc.Next() {
cur := t.gc.Cursor()
if cur == nil {
continue
}
if typedCur, ok := cur.(cursors.BooleanArrayCursor); !ok {
// TODO(sgc): error or skip?
cur.Close()
t.err = errors.Errorf("expected boolean cursor type, got %T", cur)
return false
} else {
t.readTags(t.gc.Tags())
t.cur = typedCur
return true
}
}
return false
}