Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
harshil-goel committed Aug 13, 2024
1 parent 17f28fc commit 46fd680
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ func (it *Iterator) Next() {

// Set next item to current
it.item = it.data.pop()
for it.iitr.Valid() {
for it.iitr.Valid() && hasPrefix(it.iitr, it.opt.Prefix) {
if it.parseItem() {
// parseItem calls one extra next.
// This is used to deal with the complexity of reverse iteration.
Expand Down Expand Up @@ -725,6 +725,13 @@ func (it *Iterator) fill(item *Item) {
}
}

func hasPrefix(it y.Iterator, prefix []byte) bool {
if len(prefix) > 0 {
return bytes.HasPrefix(y.ParseKey(it.Key()), prefix)
}
return true
}

func (it *Iterator) prefetch() {
prefetchSize := 2
if it.opt.PrefetchValues && it.opt.PrefetchSize > 1 {
Expand All @@ -734,7 +741,7 @@ func (it *Iterator) prefetch() {
i := it.iitr
var count int
it.item = nil
for i.Valid() {
for i.Valid() && hasPrefix(i, it.opt.Prefix) {
if !it.parseItem() {
continue
}
Expand Down

0 comments on commit 46fd680

Please sign in to comment.