pageNode returns the in-memory node, if it exists. Otherwise, returns the underlying page.
(id common.Pgid)
| 931 | // pageNode returns the in-memory node, if it exists. |
| 932 | // Otherwise, returns the underlying page. |
| 933 | func (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. |
| 958 | type BucketStats struct { |
no test coverage detected