mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-31 15:06:26 +00:00
wip
This commit is contained in:
parent
b4fd20f17a
commit
a4b2806330
2 changed files with 11 additions and 2 deletions
|
@ -369,11 +369,15 @@ func (sup *statsCountUniqProcessor) mergeState(sfp statsProcessor) {
|
||||||
|
|
||||||
func (sup *statsCountUniqProcessor) finalizeStats() string {
|
func (sup *statsCountUniqProcessor) finalizeStats() string {
|
||||||
n := uint64(len(sup.m))
|
n := uint64(len(sup.m))
|
||||||
|
if limit := sup.su.limit; limit > 0 && n > limit {
|
||||||
|
n = limit
|
||||||
|
}
|
||||||
return strconv.FormatUint(n, 10)
|
return strconv.FormatUint(n, 10)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sup *statsCountUniqProcessor) limitReached() bool {
|
func (sup *statsCountUniqProcessor) limitReached() bool {
|
||||||
return sup.su.limit > 0 && uint64(len(sup.m)) >= sup.su.limit
|
limit := sup.su.limit
|
||||||
|
return limit > 0 && uint64(len(sup.m)) >= limit
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseStatsCountUniq(lex *lexer) (*statsCountUniq, error) {
|
func parseStatsCountUniq(lex *lexer) (*statsCountUniq, error) {
|
||||||
|
|
|
@ -209,6 +209,10 @@ func (sup *statsUniqValuesProcessor) finalizeStats() string {
|
||||||
}
|
}
|
||||||
slices.SortFunc(items, compareValues)
|
slices.SortFunc(items, compareValues)
|
||||||
|
|
||||||
|
if limit := sup.su.limit; limit > 0 && uint64(len(items)) > limit {
|
||||||
|
items = items[:limit]
|
||||||
|
}
|
||||||
|
|
||||||
// Marshal items into JSON array.
|
// Marshal items into JSON array.
|
||||||
|
|
||||||
// Pre-allocate buffer for serialized items.
|
// Pre-allocate buffer for serialized items.
|
||||||
|
@ -232,7 +236,8 @@ func (sup *statsUniqValuesProcessor) finalizeStats() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sup *statsUniqValuesProcessor) limitReached() bool {
|
func (sup *statsUniqValuesProcessor) limitReached() bool {
|
||||||
return sup.su.limit > 0 && uint64(len(sup.m)) >= sup.su.limit
|
limit := sup.su.limit
|
||||||
|
return limit > 0 && uint64(len(sup.m)) >= limit
|
||||||
}
|
}
|
||||||
|
|
||||||
func compareValues(a, b string) int {
|
func compareValues(a, b string) int {
|
||||||
|
|
Loading…
Reference in a new issue