Remove unused query code
This code was previously used to implement binary expressions and other transfomation iterators. It is no longer needed.pull/9648/head
parent
4044d41e10
commit
a49a8dce6b
File diff suppressed because it is too large
Load Diff
|
@ -1271,218 +1271,7 @@ func (itr *{{$k.name}}Stream{{$v.Name}}Iterator) reduce() ([]{{$v.Name}}Point, e
|
||||||
return points, nil
|
return points, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// {{$k.name}}{{if ne $k.Name $v.Name}}{{$v.Name}}{{end}}ExprIterator executes a function to modify an existing point
|
|
||||||
// for every output of the input iterator.
|
|
||||||
type {{$k.name}}{{if ne $k.Name $v.Name}}{{$v.Name}}{{end}}ExprIterator struct {
|
|
||||||
left *buf{{$k.Name}}Iterator
|
|
||||||
right *buf{{$k.Name}}Iterator
|
|
||||||
fn {{$k.name}}{{if ne $k.Name $v.Name}}{{$v.Name}}{{end}}ExprFunc
|
|
||||||
points []{{$k.Name}}Point // must be size 2
|
|
||||||
storePrev bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func new{{$k.Name}}{{if ne $k.Name $v.Name}}{{$v.Name}}{{end}}ExprIterator(left, right {{$k.Name}}Iterator, opt IteratorOptions, fn func(a, b {{$k.Type}}) {{$v.Type}}) *{{$k.name}}{{if ne $k.Name $v.Name}}{{$v.Name}}{{end}}ExprIterator {
|
|
||||||
var points []{{$k.Name}}Point
|
|
||||||
switch opt.Fill {
|
|
||||||
case influxql.NullFill, influxql.PreviousFill:
|
|
||||||
points = []{{$k.Name}}Point{ {Nil: true}, {Nil: true} }
|
|
||||||
case influxql.NumberFill:
|
|
||||||
value := castTo{{$k.Name}}(opt.FillValue)
|
|
||||||
points = []{{$k.Name}}Point{ {Value: value}, {Value: value} }
|
|
||||||
}
|
|
||||||
return &{{$k.name}}{{if ne $k.Name $v.Name}}{{$v.Name}}{{end}}ExprIterator{
|
|
||||||
left: newBuf{{$k.Name}}Iterator(left),
|
|
||||||
right: newBuf{{$k.Name}}Iterator(right),
|
|
||||||
points: points,
|
|
||||||
fn: fn,
|
|
||||||
storePrev: opt.Fill == influxql.PreviousFill,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (itr *{{$k.name}}{{if ne $k.Name $v.Name}}{{$v.Name}}{{end}}ExprIterator) Stats() IteratorStats {
|
|
||||||
stats := itr.left.Stats()
|
|
||||||
stats.Add(itr.right.Stats())
|
|
||||||
return stats
|
|
||||||
}
|
|
||||||
|
|
||||||
func (itr *{{$k.name}}{{if ne $k.Name $v.Name}}{{$v.Name}}{{end}}ExprIterator) Close() error {
|
|
||||||
itr.left.Close()
|
|
||||||
itr.right.Close()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (itr *{{$k.name}}{{if ne $k.Name $v.Name}}{{$v.Name}}{{end}}ExprIterator) Next() (*{{$v.Name}}Point, error) {
|
|
||||||
for {
|
|
||||||
a, b, err := itr.next()
|
|
||||||
if err != nil || (a == nil && b == nil) {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// If any of these are nil and we are using fill(none), skip these points.
|
|
||||||
if (a == nil || a.Nil || b == nil || b.Nil) && itr.points == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// If one of the two points is nil, we need to fill it with a fake nil
|
|
||||||
// point that has the same name, tags, and time as the other point.
|
|
||||||
// There should never be a time when both of these are nil.
|
|
||||||
if a == nil {
|
|
||||||
p := *b
|
|
||||||
a = &p
|
|
||||||
a.Value = {{$k.Nil}}
|
|
||||||
a.Nil = true
|
|
||||||
} else if b == nil {
|
|
||||||
p := *a
|
|
||||||
b = &p
|
|
||||||
b.Value = {{$k.Nil}}
|
|
||||||
b.Nil = true
|
|
||||||
}
|
|
||||||
|
|
||||||
// If a value is nil, use the fill values if the fill value is non-nil.
|
|
||||||
if a.Nil && !itr.points[0].Nil {
|
|
||||||
a.Value = itr.points[0].Value
|
|
||||||
a.Nil = false
|
|
||||||
}
|
|
||||||
if b.Nil && !itr.points[1].Nil {
|
|
||||||
b.Value = itr.points[1].Value
|
|
||||||
b.Nil = false
|
|
||||||
}
|
|
||||||
|
|
||||||
if itr.storePrev {
|
|
||||||
itr.points[0], itr.points[1] = *a, *b
|
|
||||||
}
|
|
||||||
|
|
||||||
{{if eq $k.Name $v.Name}}
|
|
||||||
if a.Nil {
|
|
||||||
return a, nil
|
|
||||||
} else if b.Nil {
|
|
||||||
return b, nil
|
|
||||||
}
|
|
||||||
a.Value = itr.fn(a.Value, b.Value)
|
|
||||||
return a, nil
|
|
||||||
{{else}}
|
|
||||||
p := &{{$v.Name}}Point{
|
|
||||||
Name: a.Name,
|
|
||||||
Tags: a.Tags,
|
|
||||||
Time: a.Time,
|
|
||||||
Nil: a.Nil || b.Nil,
|
|
||||||
Aggregated: a.Aggregated,
|
|
||||||
}
|
|
||||||
if !p.Nil {
|
|
||||||
p.Value = itr.fn(a.Value, b.Value)
|
|
||||||
}
|
|
||||||
return p, nil
|
|
||||||
{{end}}
|
{{end}}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// next returns the next points within each iterator. If the iterators are
|
|
||||||
// uneven, it organizes them so only matching points are returned.
|
|
||||||
func (itr *{{$k.name}}{{if ne $k.Name $v.Name}}{{$v.Name}}{{end}}ExprIterator) next() (a, b *{{$k.Name}}Point, err error) {
|
|
||||||
// Retrieve the next value for both the left and right.
|
|
||||||
a, err = itr.left.Next()
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
b, err = itr.right.Next()
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we have a point from both, make sure that they match each other.
|
|
||||||
if a != nil && b != nil {
|
|
||||||
if a.Name > b.Name {
|
|
||||||
itr.left.unread(a)
|
|
||||||
return nil, b, nil
|
|
||||||
} else if a.Name < b.Name {
|
|
||||||
itr.right.unread(b)
|
|
||||||
return a, nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if ltags, rtags := a.Tags.ID(), b.Tags.ID(); ltags > rtags {
|
|
||||||
itr.left.unread(a)
|
|
||||||
return nil, b, nil
|
|
||||||
} else if ltags < rtags {
|
|
||||||
itr.right.unread(b)
|
|
||||||
return a, nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if a.Time > b.Time {
|
|
||||||
itr.left.unread(a)
|
|
||||||
return nil, b, nil
|
|
||||||
} else if a.Time < b.Time {
|
|
||||||
itr.right.unread(b)
|
|
||||||
return a, nil, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return a, b, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// {{$k.name}}{{if ne $k.Name $v.Name}}{{$v.Name}}{{end}}ExprFunc creates or modifies a point by combining two
|
|
||||||
// points. The point passed in may be modified and returned rather than
|
|
||||||
// allocating a new point if possible. One of the points may be nil, but at
|
|
||||||
// least one of the points will be non-nil.
|
|
||||||
type {{$k.name}}{{if ne $k.Name $v.Name}}{{$v.Name}}{{end}}ExprFunc func(a, b {{$k.Type}}) {{$v.Type}}
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
// {{$k.name}}TransformIterator executes a function to modify an existing point for every
|
|
||||||
// output of the input iterator.
|
|
||||||
type {{$k.name}}TransformIterator struct {
|
|
||||||
input {{$k.Name}}Iterator
|
|
||||||
fn {{$k.name}}TransformFunc
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stats returns stats from the input iterator.
|
|
||||||
func (itr *{{$k.name}}TransformIterator) Stats() IteratorStats { return itr.input.Stats() }
|
|
||||||
|
|
||||||
// Close closes the iterator and all child iterators.
|
|
||||||
func (itr *{{$k.name}}TransformIterator) Close() error { return itr.input.Close() }
|
|
||||||
|
|
||||||
// Next returns the minimum value for the next available interval.
|
|
||||||
func (itr *{{$k.name}}TransformIterator) Next() (*{{$k.Name}}Point, error) {
|
|
||||||
p, err := itr.input.Next()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
} else if p != nil {
|
|
||||||
p = itr.fn(p)
|
|
||||||
}
|
|
||||||
return p, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// {{$k.name}}TransformFunc creates or modifies a point.
|
|
||||||
// The point passed in may be modified and returned rather than allocating a
|
|
||||||
// new point if possible.
|
|
||||||
type {{$k.name}}TransformFunc func(p *{{$k.Name}}Point) *{{$k.Name}}Point
|
|
||||||
|
|
||||||
// {{$k.name}}BoolTransformIterator executes a function to modify an existing point for every
|
|
||||||
// output of the input iterator.
|
|
||||||
type {{$k.name}}BoolTransformIterator struct {
|
|
||||||
input {{$k.Name}}Iterator
|
|
||||||
fn {{$k.name}}BoolTransformFunc
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stats returns stats from the input iterator.
|
|
||||||
func (itr *{{$k.name}}BoolTransformIterator) Stats() IteratorStats { return itr.input.Stats() }
|
|
||||||
|
|
||||||
// Close closes the iterator and all child iterators.
|
|
||||||
func (itr *{{$k.name}}BoolTransformIterator) Close() error { return itr.input.Close() }
|
|
||||||
|
|
||||||
// Next returns the minimum value for the next available interval.
|
|
||||||
func (itr *{{$k.name}}BoolTransformIterator) Next() (*BooleanPoint, error) {
|
|
||||||
p, err := itr.input.Next()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
} else if p != nil {
|
|
||||||
return itr.fn(p), nil
|
|
||||||
}
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// {{$k.name}}BoolTransformFunc creates or modifies a point.
|
|
||||||
// The point passed in may be modified and returned rather than allocating a
|
|
||||||
// new point if possible.
|
|
||||||
type {{$k.name}}BoolTransformFunc func(p *{{$k.Name}}Point) *BooleanPoint
|
|
||||||
|
|
||||||
// {{$k.name}}DedupeIterator only outputs unique points.
|
// {{$k.name}}DedupeIterator only outputs unique points.
|
||||||
// This differs from the DistinctIterator in that it compares all aux fields too.
|
// This differs from the DistinctIterator in that it compares all aux fields too.
|
||||||
|
|
Loading…
Reference in New Issue