mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 00:13:30 +01:00
app/vmselect/promql: fix when the parameter of maxValue()
, minValue()
leading by NaN
. it will cause {top,bottom}k_{max,min}
return inappropriate result (#883)
This commit is contained in:
parent
8accbc14d8
commit
3127aa92b5
@ -740,12 +740,21 @@ func minValue(values []float64) float64 {
|
|||||||
if len(values) == 0 {
|
if len(values) == 0 {
|
||||||
return nan
|
return nan
|
||||||
}
|
}
|
||||||
min := values[0]
|
aNumberFounded := false
|
||||||
for _, v := range values[1:] {
|
var min float64
|
||||||
if v < min {
|
for _, v := range values {
|
||||||
|
if !math.IsNaN(v) && !aNumberFounded {
|
||||||
|
min = v
|
||||||
|
aNumberFounded = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if !math.IsNaN(v) && v < min {
|
||||||
min = v
|
min = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !aNumberFounded {
|
||||||
|
return nan
|
||||||
|
}
|
||||||
return min
|
return min
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -753,12 +762,21 @@ func maxValue(values []float64) float64 {
|
|||||||
if len(values) == 0 {
|
if len(values) == 0 {
|
||||||
return nan
|
return nan
|
||||||
}
|
}
|
||||||
max := values[0]
|
aNumberFounded := false
|
||||||
for _, v := range values[1:] {
|
var max float64
|
||||||
if v > max {
|
for _, v := range values {
|
||||||
|
if !math.IsNaN(v) && !aNumberFounded {
|
||||||
|
max = v
|
||||||
|
aNumberFounded = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if !math.IsNaN(v) && v > max {
|
||||||
max = v
|
max = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !aNumberFounded {
|
||||||
|
return nan
|
||||||
|
}
|
||||||
return max
|
return max
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user