fix: descending array cursor should include end time

Fixes https://github.com/influxdata/influxdb/issues/18897.
pull/18905/head
jlapacik 2020-07-09 10:55:13 -07:00
parent e6e55038e8
commit 49bdad8681
2 changed files with 24 additions and 12 deletions

View File

@ -293,9 +293,11 @@ func (c *floatArrayDescendingCursor) Next() *cursors.FloatArray {
} }
} }
if pos > 0 && c.res.Timestamps[pos-1] <= c.end { // If the earliest timestamp is strictly earlier than
// the end time, remove it from the result and repeat.
if pos > 0 && c.res.Timestamps[pos-1] < c.end {
pos -= 2 pos -= 2
for pos >= 0 && c.res.Timestamps[pos] <= c.end { for pos >= 0 && c.res.Timestamps[pos] < c.end {
pos-- pos--
} }
pos++ pos++
@ -603,9 +605,11 @@ func (c *integerArrayDescendingCursor) Next() *cursors.IntegerArray {
} }
} }
if pos > 0 && c.res.Timestamps[pos-1] <= c.end { // If the earliest timestamp is strictly earlier than
// the end time, remove it from the result and repeat.
if pos > 0 && c.res.Timestamps[pos-1] < c.end {
pos -= 2 pos -= 2
for pos >= 0 && c.res.Timestamps[pos] <= c.end { for pos >= 0 && c.res.Timestamps[pos] < c.end {
pos-- pos--
} }
pos++ pos++
@ -913,9 +917,11 @@ func (c *unsignedArrayDescendingCursor) Next() *cursors.UnsignedArray {
} }
} }
if pos > 0 && c.res.Timestamps[pos-1] <= c.end { // If the earliest timestamp is strictly earlier than
// the end time, remove it from the result and repeat.
if pos > 0 && c.res.Timestamps[pos-1] < c.end {
pos -= 2 pos -= 2
for pos >= 0 && c.res.Timestamps[pos] <= c.end { for pos >= 0 && c.res.Timestamps[pos] < c.end {
pos-- pos--
} }
pos++ pos++
@ -1225,9 +1231,11 @@ func (c *stringArrayDescendingCursor) Next() *cursors.StringArray {
} }
} }
if pos > 0 && c.res.Timestamps[pos-1] <= c.end { // If the earliest timestamp is strictly earlier than
// the end time, remove it from the result and repeat.
if pos > 0 && c.res.Timestamps[pos-1] < c.end {
pos -= 2 pos -= 2
for pos >= 0 && c.res.Timestamps[pos] <= c.end { for pos >= 0 && c.res.Timestamps[pos] < c.end {
pos-- pos--
} }
pos++ pos++
@ -1537,9 +1545,11 @@ func (c *booleanArrayDescendingCursor) Next() *cursors.BooleanArray {
} }
} }
if pos > 0 && c.res.Timestamps[pos-1] <= c.end { // If the earliest timestamp is strictly earlier than
// the end time, remove it from the result and repeat.
if pos > 0 && c.res.Timestamps[pos-1] < c.end {
pos -= 2 pos -= 2
for pos >= 0 && c.res.Timestamps[pos] <= c.end { for pos >= 0 && c.res.Timestamps[pos] < c.end {
pos-- pos--
} }
pos++ pos++

View File

@ -300,9 +300,11 @@ func (c *{{$type}}) Next() {{$arrayType}} {
} }
} }
if pos > 0 && c.res.Timestamps[pos-1] <= c.end { // If the earliest timestamp is strictly earlier than
// the end time, remove it from the result and repeat.
if pos > 0 && c.res.Timestamps[pos-1] < c.end {
pos -= 2 pos -= 2
for pos >= 0 && c.res.Timestamps[pos] <= c.end { for pos >= 0 && c.res.Timestamps[pos] < c.end {
pos-- pos--
} }
pos++ pos++