MCPcopy
hub / github.com/etcd-io/bbolt / first

Method first

cursor.go:44–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42}
43
44func (c *Cursor) first() (key []byte, value []byte, flags uint32) {
45 c.stack = c.stack[:0]
46 p, n := c.bucket.pageNode(c.bucket.RootPage())
47 c.stack = append(c.stack, elemRef{page: p, node: n, index: 0})
48 c.goToFirstElementOnTheStack()
49
50 // If we land on an empty page then move to the next value.
51 // https://github.com/boltdb/bolt/issues/450
52 if c.stack[len(c.stack)-1].count() == 0 {
53 c.next()
54 }
55
56 k, v, flags := c.keyValue()
57 if (flags & uint32(common.BucketLeafFlag)) != 0 {
58 return k, nil, flags
59 }
60 return k, v, flags
61}
62
63// Last moves the cursor to the last item in the bucket and returns its key and value.
64// If the bucket is empty then a nil key and value are returned.

Callers 4

FirstMethod · 0.95
prevMethod · 0.95
recursivelyInspectMethod · 0.80
ForEachBucketMethod · 0.80

Calls 6

nextMethod · 0.95
keyValueMethod · 0.95
pageNodeMethod · 0.80
RootPageMethod · 0.80
countMethod · 0.80

Tested by

no test coverage detected