diff options
Diffstat (limited to 'node.go')
-rw-r--r-- | node.go | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -8,6 +8,7 @@ import ( // node represents an in-memory, deserialized page. type node struct { + transaction *RWTransaction isLeaf bool key []byte depth int @@ -43,6 +44,12 @@ func (n *node) root() *node { return n.parent.root() } +// childAt returns the child node at a given index. +func (n *node) childAt(index uint16) *node { + __assert__(!n.isLeaf, "invalid childAt(%d) on a leaf node", index) + return n.transaction.node(n.inodes[index].pgid, n) +} + // put inserts a key/value. func (n *node) put(oldKey, newKey, value []byte, pgid pgid) { // Find insertion index. @@ -160,7 +167,7 @@ func (n *node) split(pageSize int) []*node { if len(current.inodes) >= minKeysPerPage && i < len(inodes)-minKeysPerPage && size+elemSize > threshold { size = pageHeaderSize nodes = append(nodes, current) - current = &node{isLeaf: n.isLeaf} + current = &node{transaction: n.transaction, isLeaf: n.isLeaf} } size += elemSize |