File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -589,7 +589,7 @@ func (it *Iterator) Next() {
589
589
590
590
// Set next item to current
591
591
it .item = it .data .pop ()
592
- for it .iitr .Valid () {
592
+ for it .iitr .Valid () && hasPrefix ( it . iitr , it . opt . Prefix ) {
593
593
if it .parseItem () {
594
594
// parseItem calls one extra next.
595
595
// This is used to deal with the complexity of reverse iteration.
@@ -725,6 +725,13 @@ func (it *Iterator) fill(item *Item) {
725
725
}
726
726
}
727
727
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
+
728
735
func (it * Iterator ) prefetch () {
729
736
prefetchSize := 2
730
737
if it .opt .PrefetchValues && it .opt .PrefetchSize > 1 {
@@ -734,7 +741,7 @@ func (it *Iterator) prefetch() {
734
741
i := it .iitr
735
742
var count int
736
743
it .item = nil
737
- for i .Valid () {
744
+ for i .Valid () && hasPrefix ( i , it . opt . Prefix ) {
738
745
if ! it .parseItem () {
739
746
continue
740
747
}
You can’t perform that action at this time.
0 commit comments