in environment/src/main/java/jetbrains/exodus/tree/btree/BottomPage.java [99:139]
protected void reclaim(final ByteIterable keyIterable, @NotNull final BTreeReclaimTraverser context) {
final BasePage node = context.currentNode;
if (node.isBottom()) {
if (node.getDataAddress() == getDataAddress()) {
doReclaim(context);
return;
} else if (node.size > 0 && node.getMinKey().compareKeyTo(keyIterable) == 0) {
// TODO: if root is empty just use other code in tree reclaim instead, omitting "node.size > 0" check
// we are already in desired bottom page, but address in not the same
return;
}
}
// go up
if (context.canMoveUp()) {
while (true) {
context.popAndMutate();
context.moveRight();
final int index = context.getNextSibling(keyIterable);
if (index < 0) {
if (!context.canMoveUp()) {
context.moveTo(Math.max(-index - 2, 0));
break;
}
} else {
context.pushChild(index); // node is always internal
break;
}
}
}
// go down
while (context.canMoveDown()) {
int index = context.getNextSibling(keyIterable);
if (index < 0) {
index = Math.max(-index - 2, 0);
}
context.pushChild(index);
}
if (context.currentNode.getDataAddress() == getDataAddress()) {
doReclaim(context);
}
}