aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2016-03-21 21:40:46 -0600
committerBen Johnson <benbjohnson@yahoo.com>2016-03-21 21:40:46 -0600
commit6204c540b50cb72aadf3a2506f9d9615344337ab (patch)
tree91fd2b1aeb48a339cd5b63fb85193a95871ce95d
parentMerge pull request #538 from benbjohnson/strict-mode-fix (diff)
parentfix rebalance bug (diff)
downloaddedo-6204c540b50cb72aadf3a2506f9d9615344337ab.tar.gz
dedo-6204c540b50cb72aadf3a2506f9d9615344337ab.tar.xz
Merge pull request #539 from benbjohnson/rebalance-fix
Fix rebalance bug
-rw-r--r--node.go37
1 files changed, 0 insertions, 37 deletions
diff --git a/node.go b/node.go
index c9fb21c..e9d64af 100644
--- a/node.go
+++ b/node.go
@@ -463,43 +463,6 @@ func (n *node) rebalance() {
target = n.prevSibling()
}
- // If target node has extra nodes then just move one over.
- if target.numChildren() > target.minKeys() {
- if useNextSibling {
- // Reparent and move node.
- if child, ok := n.bucket.nodes[target.inodes[0].pgid]; ok {
- child.parent.removeChild(child)
- child.parent = n
- child.parent.children = append(child.parent.children, child)
- }
- n.inodes = append(n.inodes, target.inodes[0])
- target.inodes = target.inodes[1:]
-
- // Update target key on parent.
- target.parent.put(target.key, target.inodes[0].key, nil, target.pgid, 0)
- target.key = target.inodes[0].key
- _assert(len(target.key) > 0, "rebalance(1): zero-length node key")
- } else {
- // Reparent and move node.
- if child, ok := n.bucket.nodes[target.inodes[len(target.inodes)-1].pgid]; ok {
- child.parent.removeChild(child)
- child.parent = n
- child.parent.children = append(child.parent.children, child)
- }
- n.inodes = append(n.inodes, inode{})
- copy(n.inodes[1:], n.inodes)
- n.inodes[0] = target.inodes[len(target.inodes)-1]
- target.inodes = target.inodes[:len(target.inodes)-1]
- }
-
- // Update parent key for node.
- n.parent.put(n.key, n.inodes[0].key, nil, n.pgid, 0)
- n.key = n.inodes[0].key
- _assert(len(n.key) > 0, "rebalance(2): zero-length node key")
-
- return
- }
-
// If both this node and the target node are too small then merge them.
if useNextSibling {
// Reparent all child nodes being moved.