diff --git a/cmd/logcli/main.go b/cmd/logcli/main.go index f190aeb6cf..23004a6078 100644 --- a/cmd/logcli/main.go +++ b/cmd/logcli/main.go @@ -55,7 +55,7 @@ func main() { } url := fmt.Sprintf("%s?query=%s&limit=%d&start=%d&end=%d&direction=%s®exp=%s", addr, url.QueryEscape(query), *limit, start.Unix(), end.Unix(), directionStr, url.QueryEscape(regexp)) - fmt.Println(url) + //fmt.Println(url) req, err := http.NewRequest("GET", url, nil) if err != nil { diff --git a/pkg/querier/iterator.go b/pkg/querier/iterator.go index 4bc7493f9b..f9406fe22a 100644 --- a/pkg/querier/iterator.go +++ b/pkg/querier/iterator.go @@ -56,9 +56,9 @@ func (i *streamIterator) Close() error { type iteratorHeap []EntryIterator -func (h iteratorHeap) Len() int { return len(h) } -func (h iteratorHeap) Swap(i, j int) { h[i], h[j] = h[j], h[i] } - +func (h iteratorHeap) Len() int { return len(h) } +func (h iteratorHeap) Swap(i, j int) { h[i], h[j] = h[j], h[i] } +func (h iteratorHeap) Peek() EntryIterator { return h[0] } func (h *iteratorHeap) Push(x interface{}) { *h = append(*h, x.(EntryIterator)) } @@ -89,7 +89,10 @@ func (h iteratorMaxHeap) Less(i, j int) bool { // heapIterator iterates over a heap of iterators. type heapIterator struct { - heap heap.Interface + heap interface { + heap.Interface + Peek() EntryIterator + } curr EntryIterator errs []error } @@ -140,6 +143,16 @@ func (i *heapIterator) Next() bool { } i.curr = heap.Pop(i.heap).(EntryIterator) + + // keep popping entries off if they match, to dedupe + for i.heap.Len() > 0 { + curr := i.curr.Entry() + next := i.heap.Peek().Entry() + if !curr.Equal(next) { + break + } + } + return true }