private void handleBorrowLeft(TreeBlock parentBlock, TreeBlock leftSibbling) throws JasDBStorageException { //we can borrow from left TreeNode node = leftSibbling.getNodes().last(); //this block needs relinking IndexBlock danglingBlock = persister.loadBlock(node.getRight()); danglingBlock.setParentPointer(getPosition()); Key newKey = leftSibbling.getMax(); leftSibbling.removeNodeInternal(node); TreeNode newNode = new TreeNode(newKey, danglingBlock.getPosition(), treeNodes.first().getLeft()); treeNodes.put(newKey, newNode); parentBlock.updateBlockPointer(leftSibbling.getMax(), leftSibbling.getPosition(), getPosition()); }
private void handleBorrowRight(TreeBlock parentBlock, TreeBlock rightSibbling) throws JasDBStorageException { //we can borrow from right TreeNode rightFirstNode = rightSibbling.getNodes().first(); IndexBlock danglingBlock = persister.loadBlock(rightFirstNode.getLeft()); danglingBlock.setParentPointer(getPosition()); Key newKey = getMax(); rightSibbling.removeNodeInternal(rightFirstNode); TreeNode newNode = new TreeNode(newKey, treeNodes.last().getRight(), danglingBlock.getPosition()); treeNodes.put(newKey, newNode); Key parentKey = getMax(); parentBlock.updateBlockPointer(parentKey, getPosition(), rightSibbling.getPosition()); }