SSE: Refactor to simplify Series type (#35063) (#35123)

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
(cherry picked from commit 4093fae99a)

Co-authored-by: Kyle Brandt <kyle@grafana.com>
This commit is contained in:
Grot (@grafanabot)
2021-06-02 19:24:54 +02:00
committed by GitHub
co-authored by Kyle Brandt
parent 0924f4e268
commit d97bc8c0a9
16 changed files with 517 additions and 849 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ func (cr classicReducer) Reduce(series mathexp.Series) mathexp.Number {
value := float64(0)
allNull := true
vF := series.Frame.Fields[series.ValueIdx]
vF := series.Frame.Fields[1]
ff := mathexp.Float64Field(*vF)
switch cr {
+4 -9
View File
@@ -399,9 +399,9 @@ func TestPercentDiffAbsReducer(t *testing.T) {
}
func valBasedSeries(vals ...*float64) mathexp.Series {
newSeries := mathexp.NewSeries("", nil, 0, false, 1, true, len(vals))
newSeries := mathexp.NewSeries("", nil, len(vals))
for idx, f := range vals {
err := newSeries.SetPoint(idx, unixTimePointer(int64(idx)), f)
err := newSeries.SetPoint(idx, time.Unix(int64(idx), 0), f)
if err != nil {
panic(err)
}
@@ -410,9 +410,9 @@ func valBasedSeries(vals ...*float64) mathexp.Series {
}
func valBasedSeriesWithLabels(l data.Labels, vals ...*float64) mathexp.Series {
newSeries := mathexp.NewSeries("", l, 0, false, 1, true, len(vals))
newSeries := mathexp.NewSeries("", l, len(vals))
for idx, f := range vals {
err := newSeries.SetPoint(idx, unixTimePointer(int64(idx)), f)
err := newSeries.SetPoint(idx, time.Unix(int64(idx), 0), f)
if err != nil {
panic(err)
}
@@ -420,11 +420,6 @@ func valBasedSeriesWithLabels(l data.Labels, vals ...*float64) mathexp.Series {
return newSeries
}
func unixTimePointer(sec int64) *time.Time {
t := time.Unix(sec, 0)
return &t
}
func valBasedNumber(f *float64) mathexp.Number {
newNumber := mathexp.NewNumber("", nil)
newNumber.SetValue(f)