mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-31 15:06:26 +00:00
wip
This commit is contained in:
parent
86942cb46c
commit
0dd32f5144
1 changed files with 22 additions and 2 deletions
|
@ -2,7 +2,6 @@ package logstorage
|
|||
|
||||
import (
|
||||
"slices"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unsafe"
|
||||
|
@ -188,7 +187,7 @@ func (sup *statsUniqValuesProcessor) finalizeStats() string {
|
|||
for k := range sup.m {
|
||||
items = append(items, k)
|
||||
}
|
||||
sort.Strings(items)
|
||||
slices.SortFunc(items, compareValues)
|
||||
|
||||
// Marshal items into JSON array.
|
||||
|
||||
|
@ -212,6 +211,27 @@ func (sup *statsUniqValuesProcessor) finalizeStats() string {
|
|||
return bytesutil.ToUnsafeString(b)
|
||||
}
|
||||
|
||||
func compareValues(a, b string) int {
|
||||
fA, okA := tryParseFloat64(a)
|
||||
fB, okB := tryParseFloat64(b)
|
||||
if okA && okB {
|
||||
if fA == fB {
|
||||
return 0
|
||||
}
|
||||
if fA < fB {
|
||||
return -1
|
||||
}
|
||||
return 1
|
||||
}
|
||||
if okA {
|
||||
return -1
|
||||
}
|
||||
if okB {
|
||||
return 1
|
||||
}
|
||||
return strings.Compare(a, b)
|
||||
}
|
||||
|
||||
func parseStatsUniqValues(lex *lexer) (*statsUniqValues, error) {
|
||||
fields, err := parseFieldNamesForStatsFunc(lex, "uniq_values")
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue