Skip to content

Commit

Permalink
Review changes
Browse files Browse the repository at this point in the history
Signed-off-by: Danny Kopping <danny.kopping@grafana.com>
  • Loading branch information
Danny Kopping committed Jan 5, 2021
1 parent 165980b commit 198640e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
6 changes: 3 additions & 3 deletions pkg/logql/log/dedup_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import (
)

type LineDedupFilter struct {
labels map[string]interface{}
labels map[string]struct{}
inverted bool
hashLookup map[uint64]struct{}
}

func NewLineDedupFilter(labelFilters []string, inverted bool) *LineDedupFilter {
// create a map of labelFilters for O(1) lookups instead of O(n)
var filterMap = make(map[string]interface{})
var filterMap = make(map[string]struct{})
for _, group := range labelFilters {
filterMap[group] = nil
filterMap[group] = struct{}{}
}

return &LineDedupFilter{
Expand Down
2 changes: 0 additions & 2 deletions pkg/logql/log/dedup_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ func Test_Deduplication(t *testing.T) {

for _, entry := range entries {
b := NewBaseLabelsBuilder().ForLabels(*entry.lbs, entry.lbs.Hash())
b.Reset()

if line, ok := d.Process(entry.line, b); ok {
outLines = append(outLines, line)
Expand All @@ -142,7 +141,6 @@ func Benchmark_Deduplication(b *testing.B) {
}

lbs := NewBaseLabelsBuilder().ForLabels(l, l.Hash())
lbs.Reset()

line := randomLine(10)

Expand Down
12 changes: 6 additions & 6 deletions pkg/logql/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -747,20 +747,20 @@ func TestParse(t *testing.T) {
},
{
// missing "by" clause
in: `{foo="bar"} dedup (label)`,
in: `{foo="bar"} | dedup (label)`,
err: ParseError{
msg: "syntax error: unexpected dedup",
msg: "syntax error: unexpected (, expecting by or without",
line: 1,
col: 13,
col: 21,
},
},
{
// misspelling of "dedup"
in: `{foo="bar"} dedupe by (label)`,
in: `{foo="bar"} | dedupe by (label)`,
err: ParseError{
msg: "syntax error: unexpected IDENTIFIER",
msg: "syntax error: unexpected by",
line: 1,
col: 13,
col: 22,
},
},
{
Expand Down

0 comments on commit 198640e

Please sign in to comment.