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

Method last

cursor.go:190–211  ·  view source on GitHub ↗

last moves the cursor to the last leaf element under the last page in the stack.

()

Source from the content-addressed store, hash-verified

188
189// last moves the cursor to the last leaf element under the last page in the stack.
190func (c *Cursor) last() {
191 for {
192 // Exit when we hit a leaf page.
193 ref := &c.stack[len(c.stack)-1]
194 if ref.isLeaf() {
195 break
196 }
197
198 // Keep adding pages pointing to the last element in the stack.
199 var pgId common.Pgid
200 if ref.node != nil {
201 pgId = ref.node.inodes[ref.index].Pgid()
202 } else {
203 pgId = ref.page.BranchPageElement(uint16(ref.index)).Pgid()
204 }
205 p, n := c.bucket.pageNode(pgId)
206
207 var nextRef = elemRef{page: p, node: n}
208 nextRef.index = nextRef.count() - 1
209 c.stack = append(c.stack, nextRef)
210 }
211}
212
213// next moves to the next leaf element and returns the key and value.
214// If the cursor is at the last leaf element then it stays there and returns nil.

Callers 2

LastMethod · 0.95
prevMethod · 0.95

Calls 5

isLeafMethod · 0.80
BranchPageElementMethod · 0.80
pageNodeMethod · 0.80
countMethod · 0.80
PgidMethod · 0.45

Tested by

no test coverage detected