Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return the correct auxiliary values for top/bottom #9869

Merged
merged 1 commit into from
May 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions query/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1337,11 +1337,14 @@ func (r *FloatTopReducer) AggregateFloat(p *FloatPoint) {
if !r.h.cmp(&r.h.points[0], p) {
return
}
r.h.points[0] = *p
p.CopyTo(&r.h.points[0])
heap.Fix(r.h, 0)
return
}
heap.Push(r.h, *p)

var clone FloatPoint
p.CopyTo(&clone)
heap.Push(r.h, clone)
}

func (r *FloatTopReducer) Emit() []FloatPoint {
Expand Down Expand Up @@ -1380,11 +1383,14 @@ func (r *IntegerTopReducer) AggregateInteger(p *IntegerPoint) {
if !r.h.cmp(&r.h.points[0], p) {
return
}
r.h.points[0] = *p
p.CopyTo(&r.h.points[0])
heap.Fix(r.h, 0)
return
}
heap.Push(r.h, *p)

var clone IntegerPoint
p.CopyTo(&clone)
heap.Push(r.h, clone)
}

func (r *IntegerTopReducer) Emit() []IntegerPoint {
Expand Down Expand Up @@ -1423,11 +1429,14 @@ func (r *UnsignedTopReducer) AggregateUnsigned(p *UnsignedPoint) {
if !r.h.cmp(&r.h.points[0], p) {
return
}
r.h.points[0] = *p
p.CopyTo(&r.h.points[0])
heap.Fix(r.h, 0)
return
}
heap.Push(r.h, *p)

var clone UnsignedPoint
p.CopyTo(&clone)
heap.Push(r.h, clone)
}

func (r *UnsignedTopReducer) Emit() []UnsignedPoint {
Expand Down Expand Up @@ -1466,11 +1475,14 @@ func (r *FloatBottomReducer) AggregateFloat(p *FloatPoint) {
if !r.h.cmp(&r.h.points[0], p) {
return
}
r.h.points[0] = *p
p.CopyTo(&r.h.points[0])
heap.Fix(r.h, 0)
return
}
heap.Push(r.h, *p)

var clone FloatPoint
p.CopyTo(&clone)
heap.Push(r.h, clone)
}

func (r *FloatBottomReducer) Emit() []FloatPoint {
Expand Down Expand Up @@ -1509,11 +1521,14 @@ func (r *IntegerBottomReducer) AggregateInteger(p *IntegerPoint) {
if !r.h.cmp(&r.h.points[0], p) {
return
}
r.h.points[0] = *p
p.CopyTo(&r.h.points[0])
heap.Fix(r.h, 0)
return
}
heap.Push(r.h, *p)

var clone IntegerPoint
p.CopyTo(&clone)
heap.Push(r.h, clone)
}

func (r *IntegerBottomReducer) Emit() []IntegerPoint {
Expand Down Expand Up @@ -1552,11 +1567,14 @@ func (r *UnsignedBottomReducer) AggregateUnsigned(p *UnsignedPoint) {
if !r.h.cmp(&r.h.points[0], p) {
return
}
r.h.points[0] = *p
p.CopyTo(&r.h.points[0])
heap.Fix(r.h, 0)
return
}
heap.Push(r.h, *p)

var clone UnsignedPoint
p.CopyTo(&clone)
heap.Push(r.h, clone)
}

func (r *UnsignedBottomReducer) Emit() []UnsignedPoint {
Expand Down
40 changes: 30 additions & 10 deletions query/point.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,13 @@ func (v *FloatPoint) Clone() *FloatPoint {

// CopyTo makes a deep copy into the point.
func (v *FloatPoint) CopyTo(other *FloatPoint) {
*other = *v
other.Name, other.Tags = v.Name, v.Tags
other.Time = v.Time
other.Value, other.Nil = v.Value, v.Nil
if v.Aux != nil {
other.Aux = make([]interface{}, len(v.Aux))
if len(other.Aux) != len(v.Aux) {
other.Aux = make([]interface{}, len(v.Aux))
}
copy(other.Aux, v.Aux)
}
}
Expand Down Expand Up @@ -282,9 +286,13 @@ func (v *IntegerPoint) Clone() *IntegerPoint {

// CopyTo makes a deep copy into the point.
func (v *IntegerPoint) CopyTo(other *IntegerPoint) {
*other = *v
other.Name, other.Tags = v.Name, v.Tags
other.Time = v.Time
other.Value, other.Nil = v.Value, v.Nil
if v.Aux != nil {
other.Aux = make([]interface{}, len(v.Aux))
if len(other.Aux) != len(v.Aux) {
other.Aux = make([]interface{}, len(v.Aux))
}
copy(other.Aux, v.Aux)
}
}
Expand Down Expand Up @@ -503,9 +511,13 @@ func (v *UnsignedPoint) Clone() *UnsignedPoint {

// CopyTo makes a deep copy into the point.
func (v *UnsignedPoint) CopyTo(other *UnsignedPoint) {
*other = *v
other.Name, other.Tags = v.Name, v.Tags
other.Time = v.Time
other.Value, other.Nil = v.Value, v.Nil
if v.Aux != nil {
other.Aux = make([]interface{}, len(v.Aux))
if len(other.Aux) != len(v.Aux) {
other.Aux = make([]interface{}, len(v.Aux))
}
copy(other.Aux, v.Aux)
}
}
Expand Down Expand Up @@ -722,9 +734,13 @@ func (v *StringPoint) Clone() *StringPoint {

// CopyTo makes a deep copy into the point.
func (v *StringPoint) CopyTo(other *StringPoint) {
*other = *v
other.Name, other.Tags = v.Name, v.Tags
other.Time = v.Time
other.Value, other.Nil = v.Value, v.Nil
if v.Aux != nil {
other.Aux = make([]interface{}, len(v.Aux))
if len(other.Aux) != len(v.Aux) {
other.Aux = make([]interface{}, len(v.Aux))
}
copy(other.Aux, v.Aux)
}
}
Expand Down Expand Up @@ -943,9 +959,13 @@ func (v *BooleanPoint) Clone() *BooleanPoint {

// CopyTo makes a deep copy into the point.
func (v *BooleanPoint) CopyTo(other *BooleanPoint) {
*other = *v
other.Name, other.Tags = v.Name, v.Tags
other.Time = v.Time
other.Value, other.Nil = v.Value, v.Nil
if v.Aux != nil {
other.Aux = make([]interface{}, len(v.Aux))
if len(other.Aux) != len(v.Aux) {
other.Aux = make([]interface{}, len(v.Aux))
}
copy(other.Aux, v.Aux)
}
}
Expand Down
8 changes: 6 additions & 2 deletions query/point.gen.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@ func (v *{{.Name}}Point) Clone() *{{.Name}}Point {

// CopyTo makes a deep copy into the point.
func (v *{{.Name}}Point) CopyTo(other *{{.Name}}Point) {
*other = *v
other.Name, other.Tags = v.Name, v.Tags
other.Time = v.Time
other.Value, other.Nil = v.Value, v.Nil
if v.Aux != nil {
other.Aux = make([]interface{}, len(v.Aux))
if len(other.Aux) != len(v.Aux) {
other.Aux = make([]interface{}, len(v.Aux))
}
copy(other.Aux, v.Aux)
}
}
Expand Down
Loading