mirror of https://github.com/hak5/bolt.git
commit
40adaef94e
6
node.go
6
node.go
|
@ -9,9 +9,9 @@ import (
|
||||||
// node represents an in-memory, deserialized page.
|
// node represents an in-memory, deserialized page.
|
||||||
type node struct {
|
type node struct {
|
||||||
bucket *Bucket
|
bucket *Bucket
|
||||||
dirty bool
|
|
||||||
isLeaf bool
|
isLeaf bool
|
||||||
unbalanced bool
|
unbalanced bool
|
||||||
|
spilled bool
|
||||||
key []byte
|
key []byte
|
||||||
pgid pgid
|
pgid pgid
|
||||||
parent *node
|
parent *node
|
||||||
|
@ -313,6 +313,9 @@ func (n *node) splitIndex(threshold int) (index, sz int) {
|
||||||
// Returns an error if dirty pages cannot be allocated.
|
// Returns an error if dirty pages cannot be allocated.
|
||||||
func (n *node) spill() error {
|
func (n *node) spill() error {
|
||||||
var tx = n.bucket.tx
|
var tx = n.bucket.tx
|
||||||
|
if n.spilled {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Spill child nodes first. Child nodes can materialize sibling nodes in
|
// Spill child nodes first. Child nodes can materialize sibling nodes in
|
||||||
// the case of split-merge so we cannot use a range loop. We have to check
|
// the case of split-merge so we cannot use a range loop. We have to check
|
||||||
|
@ -346,6 +349,7 @@ func (n *node) spill() error {
|
||||||
_assert(p.id < tx.meta.pgid, "pgid (%d) above high water mark (%d)", p.id, tx.meta.pgid)
|
_assert(p.id < tx.meta.pgid, "pgid (%d) above high water mark (%d)", p.id, tx.meta.pgid)
|
||||||
node.pgid = p.id
|
node.pgid = p.id
|
||||||
node.write(p)
|
node.write(p)
|
||||||
|
node.spilled = true
|
||||||
|
|
||||||
// Insert into parent inodes.
|
// Insert into parent inodes.
|
||||||
if node.parent != nil {
|
if node.parent != nil {
|
||||||
|
|
Loading…
Reference in New Issue