-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge Grafana's fork changes #686
Changes from 111 commits
39ec0ce
b7dbb6f
b4f114b
f61c410
af21cba
a7fbdaa
4c11a5a
718cc5d
40f705f
92d075e
28ae5c2
160f16f
695fb3f
d6e2e70
4d8e542
8c74625
89fda16
ecb1570
5aafd59
fb037b2
af4020b
ac97c47
06d3807
a212c8c
6d961d0
9fb499c
f0b0db2
ddbff9b
598f2f0
8d18608
cd6459e
8100462
faf9910
74ee465
da64eae
90386ae
4fa361d
62d60dd
cdfb110
8468b38
2487ecd
3f952f6
7e14877
3e79874
2dde0b6
cce3163
b82ff49
577ad8b
cff82c6
5ff1e97
d3bd455
23be4f9
2e11a50
d59c9f5
0771e43
c4d464a
aa8c074
1e641f6
7c77d61
5f96514
0e2942f
0dd4873
1fa2058
4018fb6
8138b60
40310c2
9d91243
2b62fc1
dfa2c72
babf638
0a50700
3640a73
064b23d
e81ff9d
f7e907b
80622bb
f862d03
aa5337a
0bcdac8
a5b8ada
67f0e64
0333910
cab938e
8455d27
e18e46e
ff089eb
23e4e7e
65e84f0
ed01aa6
454bfe0
dd4a8e2
f0faed3
adff392
70c5ee5
1cf8078
a418fbd
c627d84
072c479
299dc9d
5e17caf
7d90fad
45cf761
9485b87
af3bd4c
846e900
14050d5
5d001e9
4ae1e1f
d511d4c
1c79b04
9eb0a9e
1ecf628
58d7087
6b03de9
d77e3ee
7b2a1ee
4214530
9faff07
2f8c064
25738b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ jobs: | |
|
||
tests: | ||
name: Test code | ||
runs-on: ubuntu-latest | ||
runs-on: ubuntu-22.04 | ||
strategy: | ||
matrix: | ||
go: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,13 +24,16 @@ var ConsolidationToFunc = map[string]func([]float64) float64{ | |
"minimum": AggMin, | ||
"multiply": summarizeToAggregate("multiply"), | ||
"range": summarizeToAggregate("range"), | ||
"rangeOf": summarizeToAggregate("rangeOf"), | ||
"sum": AggSum, | ||
"total": AggSum, | ||
"stddev": summarizeToAggregate("stddev"), | ||
"first": AggFirst, | ||
"last": AggLast, | ||
"current": AggLast, | ||
} | ||
|
||
var AvailableSummarizers = []string{"sum", "total", "avg", "average", "avg_zero", "max", "min", "last", "range", "median", "multiply", "diff", "count", "stddev"} | ||
var AvailableSummarizers = []string{"sum", "total", "avg", "average", "avg_zero", "max", "min", "last", "current", "range", "rangeOf", "median", "multiply", "diff", "count", "stddev"} | ||
|
||
// AvgValue returns average of list of values | ||
func AvgValue(f64s []float64) float64 { | ||
|
@@ -167,10 +170,10 @@ func SummarizeValues(f string, values []float64, XFilesFactor float32) float64 { | |
} | ||
} | ||
} | ||
case "last": | ||
case "last", "current": | ||
rv = values[len(values)-1] | ||
total = notNans(values) | ||
case "range": | ||
case "range", "rangeOf": | ||
vMax := math.Inf(-1) | ||
vMin := math.Inf(1) | ||
isNaN := true | ||
|
@@ -195,11 +198,14 @@ func SummarizeValues(f string, values []float64, XFilesFactor float32) float64 { | |
rv = Percentile(values, 50, true) | ||
total = notNans(values) | ||
case "multiply": | ||
rv = values[0] | ||
for _, av := range values[1:] { | ||
if !math.IsNaN(av) { | ||
rv = 1.0 | ||
for _, v := range values { | ||
if math.IsNaN(v) { | ||
rv = math.NaN() | ||
break | ||
} else { | ||
total++ | ||
rv *= av | ||
rv *= v | ||
} | ||
} | ||
case "diff": | ||
|
@@ -375,19 +381,30 @@ func AggCount(v []float64) float64 { | |
return float64(n) | ||
} | ||
|
||
// AggCount counts non-NaN points | ||
func AggDiff(v []float64) float64 { | ||
res := v[0] | ||
if len(v) == 1 { | ||
return res | ||
} | ||
for _, vv := range v[1:] { | ||
safeValues := make([]float64, 0) | ||
npazosmendez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for _, vv := range v { | ||
if !math.IsNaN(vv) { | ||
res -= vv | ||
safeValues = append(safeValues, vv) | ||
} | ||
} | ||
|
||
return res | ||
if len(safeValues) > 0 { | ||
res := safeValues[0] | ||
if len(safeValues) == 1 { | ||
return res | ||
} | ||
|
||
for _, vv := range safeValues[1:] { | ||
if !math.IsNaN(vv) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check really needed ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May be simplified with one-pass scan and boolean flags is all is NaN ? It's more simple and has better performance (no copy slice elements). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oop, nice catch! Yep, this check is redundant; I suspect I accidentally left the original check in when I added the new
|
||
res -= vv | ||
} | ||
} | ||
|
||
return res | ||
} else { | ||
return math.NaN() | ||
} | ||
} | ||
|
||
// MaxValue returns maximum from the list | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be add tests for this ?