SSE: Refactor to simplify Series type (#35063)

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
Kyle Brandt
2021-06-02 12:29:19 -04:00
committed by GitHub
co-authored by Arve Knudsen
parent 134dba5101
commit 4093fae99a
16 changed files with 517 additions and 849 deletions
+2 -3
View File
@@ -13,7 +13,7 @@ func (s Series) Resample(refID string, interval time.Duration, downsampler strin
if newSeriesLength <= 0 {
return s, fmt.Errorf("the series cannot be sampled further; the time range is shorter than the interval")
}
resampled := NewSeries(refID, s.GetLabels(), s.TimeIdx, true, s.ValueIdx, true, newSeriesLength+1)
resampled := NewSeries(refID, s.GetLabels(), newSeriesLength+1)
bookmark := 0
var lastSeen *float64
idx := 0
@@ -72,8 +72,7 @@ func (s Series) Resample(refID string, interval time.Duration, downsampler strin
}
value = tmp
}
tv := t // his is required otherwise all points keep the latest timestamp; anything better?
if err := resampled.SetPoint(idx, &tv, value); err != nil {
if err := resampled.SetPoint(idx, t, value); err != nil {
return resampled, err
}
t = t.Add(interval)