mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-02-19 15:30:17 +00:00
BUGFIX: properly calculate histogram_quantile with the same value and different string le (#3225)
Co-authored-by: 647(siki.liu) <siki.liu@huolala.cn>
This commit is contained in:
parent
ae64be4f2c
commit
3195aa44fd
1 changed files with 32 additions and 0 deletions
|
@ -936,6 +936,7 @@ func transformHistogramQuantile(tfa *transformFuncArg) ([]*timeseries, error) {
|
||||||
}
|
}
|
||||||
rvs := make([]*timeseries, 0, len(m))
|
rvs := make([]*timeseries, 0, len(m))
|
||||||
for _, xss := range m {
|
for _, xss := range m {
|
||||||
|
xss = mergeSameLE(xss)
|
||||||
sort.Slice(xss, func(i, j int) bool {
|
sort.Slice(xss, func(i, j int) bool {
|
||||||
return xss[i].le < xss[j].le
|
return xss[i].le < xss[j].le
|
||||||
})
|
})
|
||||||
|
@ -1028,6 +1029,37 @@ func fixBrokenBuckets(i int, xss []leTimeseries) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func mergeSameLE(xss []leTimeseries) []leTimeseries {
|
||||||
|
hit := false
|
||||||
|
m := make(map[float64]leTimeseries)
|
||||||
|
for _, xs := range xss {
|
||||||
|
i, ok := m[xs.le]
|
||||||
|
if ok {
|
||||||
|
ts := ×eries{}
|
||||||
|
ts.CopyFromShallowTimestamps(i.ts)
|
||||||
|
for k := range ts.Values {
|
||||||
|
ts.Values[k] += xs.ts.Values[k]
|
||||||
|
}
|
||||||
|
m[xs.le] = leTimeseries{
|
||||||
|
le: xs.le,
|
||||||
|
ts: ts,
|
||||||
|
}
|
||||||
|
hit = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
m[xs.le] = xs
|
||||||
|
}
|
||||||
|
if (!hit) {
|
||||||
|
return xss
|
||||||
|
}
|
||||||
|
|
||||||
|
r := make([]leTimeseries, 0, len(m))
|
||||||
|
for _, v := range m {
|
||||||
|
r = append(r, v)
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
func transformHour(t time.Time) int {
|
func transformHour(t time.Time) int {
|
||||||
return t.Hour()
|
return t.Hour()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue