fix: Explicilty handle overflow of currentTime is storage source

pull/10616/head
Nathaniel Cook 2018-07-31 11:07:46 -06:00
parent 422612fca7
commit 1a4bd6825b
1 changed files with 16 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package storage
import (
"context"
"log"
"math"
"github.com/influxdata/platform"
"github.com/influxdata/platform/query"
@ -73,6 +74,7 @@ type source struct {
ts []execute.Transformation
currentTime execute.Time
overflow bool
}
func NewSource(id execute.DatasetID, r Reader, readSpec ReadSpec, bounds execute.Bounds, w execute.Window, currentTime execute.Time) execute.Source {
@ -133,13 +135,25 @@ func (s *source) run(ctx context.Context) error {
}
func (s *source) next(ctx context.Context, trace map[string]string) (query.TableIterator, execute.Time, bool) {
if s.overflow {
return nil, 0, false
}
start := s.currentTime - execute.Time(s.window.Period)
stop := s.currentTime
s.currentTime = s.currentTime + execute.Time(s.window.Every)
if stop > s.bounds.Stop {
return nil, 0, false
}
// Check if we will overflow, if so we are done after this pass
every := execute.Time(s.window.Every)
if every > 0 {
s.overflow = s.currentTime > math.MaxInt64-every
} else {
s.overflow = s.currentTime < math.MinInt64-every
}
s.currentTime = s.currentTime + every
bi, err := s.reader.Read(
ctx,
trace,