Skip to content

Commit

Permalink
Allow all version of keys in key only iteration
Browse files Browse the repository at this point in the history
The key only iterator is supposed to iterate over all versions of a
given key. The current implementation didn't enable all version of the
same key by default and the user had to manually do it. This commit sets
the all versions flag to true by default.
  • Loading branch information
Ibrahim Jarif committed Jul 30, 2019
1 parent d8e1fcf commit 054aa70
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ func (txn *Txn) NewKeyIterator(key []byte, opt IteratorOptions) *Iterator {
}
opt.Prefix = key // This key must be without the timestamp.
opt.prefixIsKey = true
opt.AllVersions = true
return txn.NewIterator(opt)
}

Expand All @@ -459,6 +460,9 @@ func (it *Iterator) Valid() bool {
if it.item == nil {
return false
}
if it.opt.prefixIsKey {
return bytes.Equal(it.item.key, it.opt.Prefix)
}
return bytes.HasPrefix(it.item.key, it.opt.Prefix)
}

Expand Down

0 comments on commit 054aa70

Please sign in to comment.