feat(monitor): remove precision of float when using max or min function (#20430)

This commit is contained in:
Zexi Li
2024-06-01 20:40:53 +08:00
committed by GitHub
parent 8aec56d79f
commit d1c28f0783
+14 -4
View File
@@ -47,6 +47,14 @@ func (s *queryReducer) GetType() string {
return s.Type
}
func getRoundFloat(point monitor.TimePoint) float64 {
pv := point.Value()
if pv < 1 {
return pv
}
return math.Trunc(pv)
}
func (s *queryReducer) Reduce(series *monitor.TimeSeries) (*float64, []string) {
if len(series.Points) == 0 {
return nil, nil
@@ -80,8 +88,9 @@ func (s *queryReducer) Reduce(series *monitor.TimeSeries) (*float64, []string) {
for _, point := range series.Points {
if point.IsValid() {
allNull = false
if value > point.Value() {
value = point.Value()
pv := getRoundFloat(point)
if value > pv {
value = pv
}
}
}
@@ -90,8 +99,9 @@ func (s *queryReducer) Reduce(series *monitor.TimeSeries) (*float64, []string) {
for _, point := range series.Points {
if point.IsValid() {
allNull = false
if value < point.Value() {
value = point.Value()
pv := getRoundFloat(point)
if value < pv {
value = pv
}
}
}