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

Method node

cursor.go:390–409  ·  view source on GitHub ↗

node returns the node that the cursor is currently positioned on.

()

Source from the content-addressed store, hash-verified

388
389// node returns the node that the cursor is currently positioned on.
390func (c *Cursor) node() *node {
391 common.Assert(len(c.stack) > 0, "accessing a node with a zero-length cursor stack")
392
393 // If the top of the stack is a leaf node then just return it.
394 if ref := &c.stack[len(c.stack)-1]; ref.node != nil && ref.isLeaf() {
395 return ref.node
396 }
397
398 // Start from root and traverse down the hierarchy.
399 var n = c.stack[0].node
400 if n == nil {
401 n = c.bucket.node(c.stack[0].page.Id(), nil)
402 }
403 for _, ref := range c.stack[:len(c.stack)-1] {
404 common.Assert(!n.isLeaf, "expected branch node")
405 n = n.childAt(ref.index)
406 }
407 common.Assert(n.isLeaf, "expected leaf node")
408 return n
409}
410
411// elemRef represents a reference to an element on a given page/node.
412type elemRef struct {

Callers 1

DeleteMethod · 0.95

Calls 4

AssertFunction · 0.92
isLeafMethod · 0.80
IdMethod · 0.80
childAtMethod · 0.80

Tested by

no test coverage detected