Fix termination behavior

Boundary must be (a, b] to conform to NodeIterator behavior (stop _at_
next valid key rather than before)
This commit is contained in:
Roy Crihfield 2020-09-06 02:31:03 -05:00
parent 321f5fe368
commit 3715d87161

View File

@ -34,11 +34,13 @@ func (it *PrefixBoundIterator) Next(descend bool) bool {
if it.endKey == nil { if it.endKey == nil {
return it.current.Next(descend) return it.current.Next(descend)
} }
cmp := bytes.Compare(it.current.Path(), it.endKey) // stop before endKey if !it.current.Next(descend) {
if cmp >= 0 {
return false return false
} }
return it.current.Next(descend) p := it.current.Path(); if len(p) >= 4 { p = p[:4] }
// stop if underlying iterator went past endKey
cmp := bytes.Compare(it.current.Path(), it.endKey)
return cmp <= 0
} }
func (it *PrefixBoundIterator) Error() error { func (it *PrefixBoundIterator) Error() error {