blob: 0963e4f669648703529b38d506bcf80992976c72 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package server
import (
"strings"
"github.com/mimecast/dtail/internal/protocol"
)
func buildGroupKey(groupBy []string, fields map[string]string) string {
if len(groupBy) == 0 {
return ""
}
total := 0
for _, field := range groupBy {
total += len(fields[field])
}
total += (len(groupBy) - 1) * len(protocol.AggregateGroupKeyCombinator)
var sb strings.Builder
sb.Grow(total)
for i, field := range groupBy {
if i > 0 {
sb.WriteString(protocol.AggregateGroupKeyCombinator)
}
sb.WriteString(fields[field])
}
return sb.String()
}
|