Skip to content

Commit

Permalink
Remove stale code
Browse files Browse the repository at this point in the history
Signed-off-by: Arve Knudsen <[email protected]>
  • Loading branch information
aknuds1 committed Sep 11, 2023
1 parent cbd8123 commit 2393ebd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 133 deletions.
133 changes: 0 additions & 133 deletions tsdb/index/labelvalues.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package index

import (
"container/heap"
"reflect"
"sort"

Expand Down Expand Up @@ -371,138 +370,6 @@ func (*ListLabelValues) Warnings() storage.Warnings {
return nil
}

func newMergedPostingsWithLabelValues(postings []PostingsWithLabelValues) *mergedPostingsWithLabelValues {
if len(postings) == 0 {
return &mergedPostingsWithLabelValues{}
}

h := make(postingsWithLabelValuesHeap, 0, len(postings))
for _, p := range postings {
switch {
case p.Next():
h = append(h, p)
case p.Err() != nil:
return &mergedPostingsWithLabelValues{err: p.Err()}
}
}

return &mergedPostingsWithLabelValues{h: h}
}

// mergedPostingsWithLabelValues is an iterator that merges PostingsWithLabelValues iterators, based on their
// respective series references.
type mergedPostingsWithLabelValues struct {
h postingsWithLabelValuesHeap
err error
initialized bool
cur storage.SeriesRef
curVal string
}

func (it *mergedPostingsWithLabelValues) Next() bool {
if it.h.Len() == 0 || it.err != nil {
return false
}

if !it.initialized {
heap.Init(&it.h)
it.cur = it.h[0].At()
it.curVal = it.h[0].ValueAt()
it.initialized = true
return true
}

for {
cur := it.h[0]
if !cur.Next() {
heap.Pop(&it.h)
if cur.Err() != nil {
it.err = cur.Err()
return false
}
if it.h.Len() == 0 {
return false
}
} else {
// Value of top of heap has changed, re-heapify.
heap.Fix(&it.h, 0)
}

sr := it.h[0].At()
val := it.h[0].ValueAt()
if sr != it.cur && val != it.curVal {
it.cur = sr
it.curVal = val
return true
}
}
}

// Seek advances the iterator until the current series reference is >= id, or the iterator is exhausted.
func (it *mergedPostingsWithLabelValues) Seek(id storage.SeriesRef) bool {
if it.h.Len() == 0 || it.err != nil {
return false
}
if !it.initialized && !it.Next() {
return false
}

for it.cur < id {
cur := it.h[0]
if !cur.Seek(id) {
heap.Pop(&it.h)
if cur.Err() != nil {
it.err = cur.Err()
return false
}
if it.h.Len() == 0 {
return false
}
} else {
// Value of top of heap has changed, re-heapify.
heap.Fix(&it.h, 0)
}

it.cur = it.h[0].At()
it.curVal = it.h[0].ValueAt()
}
return true
}

func (it mergedPostingsWithLabelValues) At() storage.SeriesRef {
return it.cur
}

func (it mergedPostingsWithLabelValues) ValueAt() string {
return it.curVal
}

func (it mergedPostingsWithLabelValues) Err() error {
return it.err
}

func (mergedPostingsWithLabelValues) Warnings() storage.Warnings {
return nil
}

type postingsWithLabelValuesHeap []PostingsWithLabelValues

func (h postingsWithLabelValuesHeap) Len() int { return len(h) }
func (h postingsWithLabelValuesHeap) Less(i, j int) bool { return h[i].At() < h[j].At() }
func (h *postingsWithLabelValuesHeap) Swap(i, j int) { (*h)[i], (*h)[j] = (*h)[j], (*h)[i] }

func (h *postingsWithLabelValuesHeap) Push(x interface{}) {
*h = append(*h, x.(PostingsWithLabelValues))
}

func (h *postingsWithLabelValuesHeap) Pop() interface{} {
old := *h
n := len(old)
x := old[n-1]
*h = old[0 : n-1]
return x
}

func (p *MemPostings) LabelValuesIntersectingPostings(name string, postings Postings) storage.LabelValues {
p.mtx.RLock()
defer p.mtx.RUnlock()
Expand Down
2 changes: 2 additions & 0 deletions tsdb/labelvalues.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func labelValuesForMatchersStream(r IndexReader, name string, matchers []*labels
return r.LabelValuesIntersectingPostings(name, pit)
}

/*
// newIntersectLabelValues returns an iterator over label values stemming from the intersection of the Postings
// iterators in its, minus the ones in notIts.
func newIntersectLabelValues(its, notIts []index.Postings) storage.LabelValues {
Expand Down Expand Up @@ -201,3 +202,4 @@ func (it *intersectPostingsWithLabel) Err() error {
func (*intersectPostingsWithLabel) Warnings() storage.Warnings {
return nil
}
*/

0 comments on commit 2393ebd

Please sign in to comment.