-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaggregations.go
More file actions
37 lines (29 loc) · 1.14 KB
/
aggregations.go
File metadata and controls
37 lines (29 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package godruid
import (
"encoding/json"
)
type Aggregator struct {
AggType string `json:"type"`
Name string `json:"name,omitempty"`
FieldName string `json:"fieldName,omitempty"`
Filter *Filter `json:"filter,omitempty"`
Aggregator *Aggregator `json:"aggregator,omitempty"`
}
func (a *Aggregator) toJSON() ([]byte, error) {
return json.Marshal(a)
}
func NewHyperUniqueAggregator(metricName, outputName string) *Aggregator {
return &Aggregator{AggType: "hyperUnique", Name: outputName, FieldName: metricName}
}
func NewDoubleSumAggregator(metricName, outputName string) *Aggregator {
return &Aggregator{AggType: "doubleSum", Name: outputName, FieldName: metricName}
}
func NewCountAggregator(outputName string) *Aggregator {
return &Aggregator{AggType: "count", Name: outputName}
}
func NewFilteredAggregator(name string, filter *Filter, agg *Aggregator) *Aggregator {
return &Aggregator{AggType: "filtered", Name: name, Filter: filter, Aggregator: agg}
}
func NewThetaSketchAggregator(metricName, outputName string) *Aggregator {
return &Aggregator{AggType: "thetaSketch", Name: outputName, FieldName: metricName}
}