mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 00:13:30 +01:00
app/vmselect/promql: move common condition to dropStaleNaNs in order to improve code maintainability
This commit is contained in:
parent
db34c40aec
commit
38065bec7b
@ -786,10 +786,7 @@ func getRollupMemoryLimiter() *memoryLimiter {
|
||||
func evalRollupWithIncrementalAggregate(name string, iafc *incrementalAggrFuncContext, rss *netstorage.Results, rcs []*rollupConfig,
|
||||
preFunc func(values []float64, timestamps []int64), sharedTimestamps []int64, removeMetricGroup bool) ([]*timeseries, error) {
|
||||
err := rss.RunParallel(func(rs *netstorage.Result, workerID uint) error {
|
||||
if name != "default_rollup" {
|
||||
// Remove Prometheus staleness marks, so non-default rollup functions don't hit NaN values.
|
||||
rs.Values, rs.Timestamps = dropStaleNaNs(rs.Values, rs.Timestamps)
|
||||
}
|
||||
rs.Values, rs.Timestamps = dropStaleNaNs(name, rs.Values, rs.Timestamps)
|
||||
preFunc(rs.Values, rs.Timestamps)
|
||||
ts := getTimeseries()
|
||||
defer putTimeseries(ts)
|
||||
@ -823,10 +820,7 @@ func evalRollupNoIncrementalAggregate(name string, rss *netstorage.Results, rcs
|
||||
tss := make([]*timeseries, 0, rss.Len()*len(rcs))
|
||||
var tssLock sync.Mutex
|
||||
err := rss.RunParallel(func(rs *netstorage.Result, workerID uint) error {
|
||||
if name != "default_rollup" {
|
||||
// Remove Prometheus staleness marks, so non-default rollup functions don't hit NaN values.
|
||||
rs.Values, rs.Timestamps = dropStaleNaNs(rs.Values, rs.Timestamps)
|
||||
}
|
||||
rs.Values, rs.Timestamps = dropStaleNaNs(name, rs.Values, rs.Timestamps)
|
||||
preFunc(rs.Values, rs.Timestamps)
|
||||
for _, rc := range rcs {
|
||||
if tsm := newTimeseriesMap(name, sharedTimestamps, &rs.MetricName); tsm != nil {
|
||||
@ -925,7 +919,13 @@ func toTagFilter(dst *storage.TagFilter, src *metricsql.LabelFilter) {
|
||||
dst.IsNegative = src.IsNegative
|
||||
}
|
||||
|
||||
func dropStaleNaNs(values []float64, timestamps []int64) ([]float64, []int64) {
|
||||
func dropStaleNaNs(name string, values []float64, timestamps []int64) ([]float64, []int64) {
|
||||
if name == "default_rollup" {
|
||||
// Do not drop Prometheus staleness marks (aka stale NaNs) for default_rollup() function,
|
||||
// since it uses them for Prometheus-style staleness detection.
|
||||
return values, timestamps
|
||||
}
|
||||
// Remove Prometheus staleness marks, so non-default rollup functions don't hit NaN values.
|
||||
hasStaleSamples := false
|
||||
for _, v := range values {
|
||||
if decimal.IsStaleNaN(v) {
|
||||
|
Loading…
Reference in New Issue
Block a user