2016-04-15 16:19:15 +00:00
|
|
|
package tsm1
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/influxdata/influxdb/influxql"
|
|
|
|
)
|
|
|
|
|
|
|
|
func newLimitIterator(input influxql.Iterator, opt influxql.IteratorOptions) influxql.Iterator {
|
|
|
|
switch input := input.(type) {
|
|
|
|
case influxql.FloatIterator:
|
|
|
|
return newFloatLimitIterator(input, opt)
|
|
|
|
case influxql.IntegerIterator:
|
|
|
|
return newIntegerLimitIterator(input, opt)
|
|
|
|
case influxql.StringIterator:
|
|
|
|
return newStringLimitIterator(input, opt)
|
|
|
|
case influxql.BooleanIterator:
|
|
|
|
return newBooleanLimitIterator(input, opt)
|
|
|
|
default:
|
|
|
|
panic(fmt.Sprintf("unsupported limit iterator type: %T", input))
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 16:08:28 +00:00
|
|
|
|
|
|
|
type floatCastIntegerCursor struct {
|
|
|
|
cursor integerCursor
|
|
|
|
}
|
|
|
|
|
2016-08-29 15:24:52 +00:00
|
|
|
func (c *floatCastIntegerCursor) close() error { return c.cursor.close() }
|
2016-07-20 04:33:48 +00:00
|
|
|
|
2016-05-16 16:08:28 +00:00
|
|
|
func (c *floatCastIntegerCursor) next() (t int64, v interface{}) { return c.nextFloat() }
|
|
|
|
|
|
|
|
func (c *floatCastIntegerCursor) nextFloat() (int64, float64) {
|
|
|
|
t, v := c.cursor.nextInteger()
|
|
|
|
return t, float64(v)
|
|
|
|
}
|
|
|
|
|
|
|
|
type integerCastFloatCursor struct {
|
|
|
|
cursor floatCursor
|
|
|
|
}
|
|
|
|
|
2016-08-29 15:24:52 +00:00
|
|
|
func (c *integerCastFloatCursor) close() error { return c.cursor.close() }
|
2016-07-20 04:33:48 +00:00
|
|
|
|
2016-05-16 16:08:28 +00:00
|
|
|
func (c *integerCastFloatCursor) next() (t int64, v interface{}) { return c.nextInteger() }
|
|
|
|
|
|
|
|
func (c *integerCastFloatCursor) nextInteger() (int64, int64) {
|
|
|
|
t, v := c.cursor.nextFloat()
|
|
|
|
return t, int64(v)
|
|
|
|
}
|