use of org.neo4j.index.internal.gbptree.TreeNode.Type.INTERNAL in project neo4j by neo4j.
the class SeekCursorTestBase method shouldCatchupRootWhenNodeHasTooNewGenerationWhileTraversingLeaves.
@Test
void shouldCatchupRootWhenNodeHasTooNewGenerationWhileTraversingLeaves() throws Exception {
// given
MutableBoolean triggered = new MutableBoolean(false);
// We don't care
long oldRightChild = 666;
// a newer right leaf
long rightChild = cursor.getCurrentPageId();
node.initializeLeaf(cursor, stableGeneration, unstableGeneration);
cursor.next();
RootCatchup rootCatchup = fromId -> {
// Use right child as new start over root to terminate test
cursor.next(rightChild);
triggered.setTrue();
return new Root(cursor.getCurrentPageId(), TreeNode.generation(cursor));
};
// a left leaf
long leftChild = cursor.getCurrentPageId();
node.initializeLeaf(cursor, stableGeneration - 1, unstableGeneration - 1);
// with an old pointer to right sibling
TreeNode.setRightSibling(cursor, rightChild, stableGeneration - 1, unstableGeneration - 1);
cursor.next();
// a root
node.initializeInternal(cursor, stableGeneration - 1, unstableGeneration - 1);
long keyInRoot = 10L;
node.insertKeyAndRightChildAt(cursor, key(keyInRoot), oldRightChild, 0, 0, stableGeneration, unstableGeneration, NULL);
TreeNode.setKeyCount(cursor, 1);
// with old pointer to child (simulating reuse of internal node)
node.setChildAt(cursor, leftChild, 0, stableGeneration, unstableGeneration);
// when
KEY from = key(1L);
KEY to = key(20L);
try (SeekCursor<KEY, VALUE> seek = new SeekCursor<>(cursor, node, from, to, layout, stableGeneration - 1, unstableGeneration - 1, generationSupplier, rootCatchup, unstableGeneration, exceptionDecorator, 1, LEAF_LEVEL, SeekCursor.NO_MONITOR, NULL)) {
while (seek.next()) {
seek.key();
}
}
// then
assertTrue(triggered.getValue());
}
Aggregations