Skip to content

Commit 46fd680

Browse files
committed
temp
1 parent 17f28fc commit 46fd680

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

iterator.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ func (it *Iterator) Next() {
589589

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

728+
func hasPrefix(it y.Iterator, prefix []byte) bool {
729+
if len(prefix) > 0 {
730+
return bytes.HasPrefix(y.ParseKey(it.Key()), prefix)
731+
}
732+
return true
733+
}
734+
728735
func (it *Iterator) prefetch() {
729736
prefetchSize := 2
730737
if it.opt.PrefetchValues && it.opt.PrefetchSize > 1 {
@@ -734,7 +741,7 @@ func (it *Iterator) prefetch() {
734741
i := it.iitr
735742
var count int
736743
it.item = nil
737-
for i.Valid() {
744+
for i.Valid() && hasPrefix(i, it.opt.Prefix) {
738745
if !it.parseItem() {
739746
continue
740747
}

0 commit comments

Comments
 (0)