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

Commit 29b65f6

Browse files
committed
Add batch/aggfuncs to consolidation
Note that this fixes bug --> unable to get cnt aggfunc Also ignores archive which seems to be different
1 parent 40e260f commit 29b65f6

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

consolidation/consolidation.go

+46-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ const (
2323
Max
2424
Min
2525
Cnt // not available through http api
26+
Mult
27+
Med
28+
Diff
29+
StdDev
30+
Range
2631
)
2732

2833
// String provides human friendly names
@@ -40,6 +45,16 @@ func (c Consolidator) String() string {
4045
return "MinimumConsolidator"
4146
case Max:
4247
return "MaximumConsolidator"
48+
case Mult:
49+
return "MultiplyConsolidator"
50+
case Med:
51+
return "MedianConsolidator"
52+
case Diff:
53+
return "DifferenceConsolidator"
54+
case StdDev:
55+
return "StdDevConsolidator"
56+
case Range:
57+
return "RangeConsolidator"
4358
case Sum:
4459
return "SumConsolidator"
4560
}
@@ -96,6 +111,16 @@ func FromConsolidateBy(c string) Consolidator {
96111
return Min
97112
case "max":
98113
return Max
114+
case "mult", "multiply":
115+
return Mult
116+
case "med", "median":
117+
return Med
118+
case "diff":
119+
return Diff
120+
case "stddev":
121+
return StdDev
122+
case "range":
123+
return Range
99124
case "sum":
100125
return Sum
101126
}
@@ -116,14 +141,34 @@ func GetAggFunc(consolidator Consolidator) batch.AggFunc {
116141
consFunc = batch.Min
117142
case Max:
118143
consFunc = batch.Max
144+
case Mult:
145+
consFunc = batch.Mult
146+
case Med:
147+
consFunc = batch.Med
148+
case Diff:
149+
consFunc = batch.Diff
150+
case StdDev:
151+
consFunc = batch.StdDev
152+
case Range:
153+
consFunc = batch.Range
119154
case Sum:
120155
consFunc = batch.Sum
121156
}
122157
return consFunc
123158
}
124159

125160
func Validate(fn string) error {
126-
if fn == "avg" || fn == "average" || fn == "last" || fn == "min" || fn == "max" || fn == "sum" {
161+
if fn == "avg" ||
162+
fn == "average" ||
163+
fn == "count" || fn == "last" || // bonus
164+
fn == "min" ||
165+
fn == "max" ||
166+
fn == "mult" || fn == "multiply" ||
167+
fn == "med" || fn == "median" ||
168+
fn == "diff" ||
169+
fn == "stddev" ||
170+
fn == "range" ||
171+
fn == "sum" {
127172
return nil
128173
}
129174
return errUnknownConsolidationFunction

0 commit comments

Comments
 (0)