promql: refactor: initialize aggregation before storing in map
This seems more consistent to me. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
parent
29244fb841
commit
e5f667537c
|
@ -2686,9 +2686,6 @@ func (ev *evaluator) aggregation(e *parser.AggregateExpr, grouping []string, par
|
||||||
newAgg.groupCount = 0
|
newAgg.groupCount = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
result[groupingKey] = newAgg
|
|
||||||
orderedResult = append(orderedResult, newAgg)
|
|
||||||
|
|
||||||
inputVecLen := int64(len(vec))
|
inputVecLen := int64(len(vec))
|
||||||
resultSize := k
|
resultSize := k
|
||||||
switch {
|
switch {
|
||||||
|
@ -2699,22 +2696,25 @@ func (ev *evaluator) aggregation(e *parser.AggregateExpr, grouping []string, par
|
||||||
}
|
}
|
||||||
switch op {
|
switch op {
|
||||||
case parser.STDVAR, parser.STDDEV:
|
case parser.STDVAR, parser.STDDEV:
|
||||||
result[groupingKey].floatValue = 0
|
newAgg.floatValue = 0
|
||||||
case parser.TOPK, parser.QUANTILE:
|
case parser.TOPK, parser.QUANTILE:
|
||||||
result[groupingKey].heap = make(vectorByValueHeap, 1, resultSize)
|
newAgg.heap = make(vectorByValueHeap, 1, resultSize)
|
||||||
result[groupingKey].heap[0] = Sample{
|
newAgg.heap[0] = Sample{
|
||||||
F: s.F,
|
F: s.F,
|
||||||
Metric: s.Metric,
|
Metric: s.Metric,
|
||||||
}
|
}
|
||||||
case parser.BOTTOMK:
|
case parser.BOTTOMK:
|
||||||
result[groupingKey].reverseHeap = make(vectorByReverseValueHeap, 1, resultSize)
|
newAgg.reverseHeap = make(vectorByReverseValueHeap, 1, resultSize)
|
||||||
result[groupingKey].reverseHeap[0] = Sample{
|
newAgg.reverseHeap[0] = Sample{
|
||||||
F: s.F,
|
F: s.F,
|
||||||
Metric: s.Metric,
|
Metric: s.Metric,
|
||||||
}
|
}
|
||||||
case parser.GROUP:
|
case parser.GROUP:
|
||||||
result[groupingKey].floatValue = 1
|
newAgg.floatValue = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result[groupingKey] = newAgg
|
||||||
|
orderedResult = append(orderedResult, newAgg)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue