Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

Commit 11000bb

Browse files
committed
Don't use alignToEnd && modify QueryPatt
1 parent 433184c commit 11000bb

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

expr/func_summarize.go

+5-10
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,11 @@ func (s *FuncSummarize) Exec(cache map[Req][]models.Series) ([]models.Series, er
6565
newEnd = newEnd - (newEnd % interval) + interval
6666
}
6767

68-
out, alignedEnd := summarizeValues(serie, aggFunc, interval, newStart, newEnd)
69-
70-
if s.alignToFrom {
71-
newEnd = alignedEnd
72-
}
68+
out := summarizeValues(serie, aggFunc, interval, newStart, newEnd)
7369

7470
output := models.Series{
7571
Target: newName(serie.Target),
76-
QueryPatt: newName(serie.QueryPatt), // Should this match target?
72+
QueryPatt: newName(serie.QueryPatt),
7773
Tags: serie.Tags,
7874
Datapoints: out,
7975
Interval: interval,
@@ -84,13 +80,12 @@ func (s *FuncSummarize) Exec(cache map[Req][]models.Series) ([]models.Series, er
8480
return outputs, nil
8581
}
8682

87-
func summarizeValues(serie models.Series, aggFunc batch.AggFunc, interval, start, end uint32) ([]schema.Point, uint32) {
83+
func summarizeValues(serie models.Series, aggFunc batch.AggFunc, interval, start, end uint32) []schema.Point {
8884
out := pointSlicePool.Get().([]schema.Point)
8985

9086
numPoints := int(util.Min(uint32(len(serie.Datapoints)), (start-end)/interval))
9187

92-
ts := start
93-
for i := 0; i < numPoints && ts < end; ts += interval {
88+
for ts, i := start, 0; i < numPoints && ts < end; ts += interval {
9489
s := i
9590
for ; i < numPoints && serie.Datapoints[i].Ts < ts+interval; i++ {
9691
if serie.Datapoints[i].Ts <= ts {
@@ -101,5 +96,5 @@ func summarizeValues(serie models.Series, aggFunc batch.AggFunc, interval, start
10196
out = append(out, schema.Point{Val: aggFunc(serie.Datapoints[s:i]), Ts: ts})
10297
}
10398

104-
return out, ts
99+
return out
105100
}

0 commit comments

Comments
 (0)