aboutsummaryrefslogtreecommitdiff
path: root/transaction.go
diff options
context:
space:
mode:
Diffstat (limited to 'transaction.go')
-rw-r--r--transaction.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/transaction.go b/transaction.go
index 90f388b..d680e24 100644
--- a/transaction.go
+++ b/transaction.go
@@ -12,6 +12,7 @@ type Transaction struct {
rwtransaction *RWTransaction
meta *meta
buckets *buckets
+ nodes map[pgid]*node
pages map[pgid]*page
}
@@ -95,6 +96,23 @@ func (t *Transaction) page(id pgid) *page {
return t.db.page(id)
}
+// node returns a reference to the in-memory node for a given page, if it exists.
+func (t *Transaction) node(id pgid) *node {
+ if t.nodes == nil {
+ return nil
+ }
+ return t.nodes[id]
+}
+
+// pageNode returns the in-memory node, if it exists.
+// Otherwise returns the underlying page.
+func (t *Transaction) pageNode(id pgid) (*page, *node) {
+ if n := t.node(id); n != nil {
+ return nil, n
+ }
+ return t.page(id), nil
+}
+
// forEachPage iterates over every page within a given page and executes a function.
func (t *Transaction) forEachPage(pgid pgid, depth int, fn func(*page, int)) {
p := t.page(pgid)