This commit is contained in:
Aliaksandr Valialkin 2024-04-29 02:18:48 +02:00
parent ccb4031e62
commit cb42a1a6fc
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB

View file

@ -737,6 +737,18 @@ func (sfup *statsFuncUniqProcessor) updateStatsForAllRows(timestamps []int64, co
// Count unique rows
keyBuf := sfup.keyBuf
for i := range timestamps {
seenKey := true
for _, c := range columns {
values := c.Values
if i == 0 || values[i-1] != values[i] {
seenKey = false
break
}
}
if seenKey {
continue
}
allEmptyValues := true
keyBuf = keyBuf[:0]
for _, c := range columns {
@ -763,11 +775,15 @@ func (sfup *statsFuncUniqProcessor) updateStatsForAllRows(timestamps []int64, co
if len(fields) == 1 {
// Fast path for a single column
if idx := getBlockColumnIndex(columns, fields[0]); idx >= 0 {
for _, v := range columns[idx].Values {
values := columns[idx].Values
for i, v := range values {
if v == "" {
// Do not count empty values
continue
}
if i > 0 && values[i-1] == v {
continue
}
if _, ok := m[v]; !ok {
vCopy := strings.Clone(v)
m[vCopy] = struct{}{}
@ -786,6 +802,16 @@ func (sfup *statsFuncUniqProcessor) updateStatsForAllRows(timestamps []int64, co
keyBuf := sfup.keyBuf
for i := range timestamps {
seenKey := true
for _, values := range columnValues {
if i == 0 || values[i-1] != values[i] {
seenKey = false
}
}
if seenKey {
continue
}
allEmptyValues := true
keyBuf = keyBuf[:0]
for _, values := range columnValues {