MCPcopy
hub / github.com/dgraph-io/badger / NewKeyIterator

Method NewKeyIterator

iterator.go:492–500  ·  view source on GitHub ↗

NewKeyIterator is just like NewIterator, but allows the user to iterate over all versions of a single key. Internally, it sets the Prefix option in provided opt, and uses that prefix to additionally run bloom filter lookups before picking tables from the LSM tree.

(key []byte, opt IteratorOptions)

Source from the content-addressed store, hash-verified

490// single key. Internally, it sets the Prefix option in provided opt, and uses that prefix to
491// additionally run bloom filter lookups before picking tables from the LSM tree.
492func (txn *Txn) NewKeyIterator(key []byte, opt IteratorOptions) *Iterator {
493 if len(opt.Prefix) > 0 {
494 panic("opt.Prefix should be nil for NewKeyIterator.")
495 }
496 opt.Prefix = key // This key must be without the timestamp.
497 opt.prefixIsKey = true
498 opt.AllVersions = true
499 return txn.NewIterator(opt)
500}
501
502func (it *Iterator) newItem() *Item {
503 item := it.waste.pop()

Callers 4

TestIteratePrefixFunction · 0.80
iterateAndMergeMethod · 0.80
TestGetMergeOperatorFunction · 0.80
lookupFunction · 0.80

Calls 1

NewIteratorMethod · 0.95

Tested by 2

TestIteratePrefixFunction · 0.64
TestGetMergeOperatorFunction · 0.64