app/vmselect: return NaN instead of 0 for empty value sets (#1660)

The change affects `count/stddev/stdvar_over_time` funcs and makes
them to return NaN instead of zero when there is no datapoints
in a time window.
This is needed for improving compatibility with Prometheus.

Signed-off-by: hagen1778 <roman@victoriametrics.com>
This commit is contained in:
Roman Khavronenko 2021-09-29 00:37:04 +03:00 committed by Aliaksandr Valialkin
parent c8ac8f44b2
commit 72468c9d75
No known key found for this signature in database
GPG Key ID: A72BEC6CD3D0DED1

View File

@ -1352,11 +1352,8 @@ func rollupCount(rfa *rollupFuncArg) float64 {
// before calling rollup funcs. // before calling rollup funcs.
values := rfa.values values := rfa.values
if len(values) == 0 { if len(values) == 0 {
if math.IsNaN(rfa.prevValue) {
return nan return nan
} }
return 0
}
return float64(len(values)) return float64(len(values))
} }
@ -1372,11 +1369,8 @@ func rollupStdvar(rfa *rollupFuncArg) float64 {
// before calling rollup funcs. // before calling rollup funcs.
values := rfa.values values := rfa.values
if len(values) == 0 { if len(values) == 0 {
if math.IsNaN(rfa.prevValue) {
return nan return nan
} }
return 0
}
if len(values) == 1 { if len(values) == 1 {
// Fast path. // Fast path.
return values[0] return values[0]