Skip to content

Commit

Permalink
fix binary search usage in postingsOffset
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Kabischev <[email protected]>
  • Loading branch information
mkabischev committed Apr 6, 2020
1 parent 7b9d72d commit 38918f7
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions pkg/block/indexheader/binary_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,14 +685,10 @@ func (r BinaryReader) postingsOffset(name string, values ...string) ([]index.Ran
value := values[valueIndex]

i := sort.Search(len(e.offsets), func(i int) bool { return e.offsets[i].value >= value })
if i == len(e.offsets) {
// We're past the end.
if i == len(e.offsets) || e.offsets[i].value != value {
break
}
if i > 0 && e.offsets[i].value != value {
// Need to look from previous entry.
i--
}

// Don't Crc32 the entire postings offset table, this is very slow
// so hope any issues were caught at startup.
d := encoding.NewDecbufAt(r.b, int(r.toc.PostingsOffsetTable), nil)
Expand Down

0 comments on commit 38918f7

Please sign in to comment.