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

Method pageNode

bucket.go:933–955  ·  view source on GitHub ↗

pageNode returns the in-memory node, if it exists. Otherwise, returns the underlying page.

(id common.Pgid)

Source from the content-addressed store, hash-verified

931// pageNode returns the in-memory node, if it exists.
932// Otherwise, returns the underlying page.
933func (b *Bucket) pageNode(id common.Pgid) (*common.Page, *node) {
934 // Inline buckets have a fake page embedded in their value so treat them
935 // differently. We'll return the rootNode (if available) or the fake page.
936 if b.RootPage() == 0 {
937 if id != 0 {
938 panic(fmt.Sprintf("inline bucket non-zero page access(2): %d != 0", id))
939 }
940 if b.rootNode != nil {
941 return nil, b.rootNode
942 }
943 return b.page, nil
944 }
945
946 // Check the node cache for non-inline buckets.
947 if b.nodes != nil {
948 if n := b.nodes[id]; n != nil {
949 return nil, n
950 }
951 }
952
953 // Finally lookup the page from the transaction if no node is materialized.
954 return b.tx.page(id), nil
955}
956
957// BucketStats records statistics about resources used by a bucket.
958type BucketStats struct {

Callers 6

_forEachPageNodeMethod · 0.95
firstMethod · 0.80
LastMethod · 0.80
lastMethod · 0.80
searchMethod · 0.80

Calls 2

RootPageMethod · 0.80
pageMethod · 0.45

Tested by

no test coverage detected