MCPcopy Index your code
hub / github.com/nutsdb/nutsdb / NewIterator

Function NewIterator

iterator.go:38–61  ·  view source on GitHub ↗

Returns a new iterator. The Release method must be called when finished with the iterator.

(tx *Tx, bucket string, options IteratorOptions)

Source from the content-addressed store, hash-verified

36// Returns a new iterator.
37// The Release method must be called when finished with the iterator.
38func NewIterator(tx *Tx, bucket string, options IteratorOptions) *Iterator {
39 b, err := tx.db.bucketMgr.GetBucket(DataStructureBTree, bucket)
40 if err != nil {
41 return nil
42 }
43 iterator := &Iterator{
44 tx: tx,
45 options: options,
46 iter: tx.db.Index.BTree.GetWithDefault(b.Id).Iter(),
47 }
48
49 // Initialize position and cache the first item
50 if options.Reverse {
51 iterator.valid = iterator.iter.Last()
52 } else {
53 iterator.valid = iterator.iter.First()
54 }
55
56 if iterator.valid {
57 iterator.currentItem = iterator.iter.Item()
58 }
59
60 return iterator
61}
62
63func (it *Iterator) Rewind() bool {
64 if it.options.Reverse {

Callers 15

forwardIterationFunction · 0.92
reverseIterativeFunction · 0.92
BenchmarkIterator_NextFunction · 0.85
BenchmarkIterator_PrevFunction · 0.85
BenchmarkIterator_SeekFunction · 0.85
BenchmarkIterator_RewindFunction · 0.85

Calls 5

GetBucketMethod · 0.80
IterMethod · 0.80
ItemMethod · 0.80
FirstMethod · 0.65
GetWithDefaultMethod · 0.45