use of org.apache.commons.lang3.mutable.MutableLong in project neo4j by neo4j.
the class SeekCursorTest method shouldCatchupRootWhenRootNodeHasTooNewGeneration.
@Test
public void shouldCatchupRootWhenRootNodeHasTooNewGeneration() throws Exception {
// given
long id = cursor.getCurrentPageId();
long generation = node.generation(cursor);
MutableBoolean triggered = new MutableBoolean(false);
Supplier<Root> rootCatchup = () -> {
triggered.setTrue();
return new Root(id, generation);
};
// when
try (SeekCursor<MutableLong, MutableLong> seek = new SeekCursor<>(cursor, node, from, to, layout, stableGeneration, unstableGeneration, generationSupplier, rootCatchup, generation - 1)) {
// do nothing
}
// then
assertTrue(triggered.getValue());
}
use of org.apache.commons.lang3.mutable.MutableLong in project neo4j by neo4j.
the class SeekCursorTest method mustStartReadingFromCorrectLeafWhenRangeStartWithKeyEqualToPrimKey.
@Test
public void mustStartReadingFromCorrectLeafWhenRangeStartWithKeyEqualToPrimKey() throws Exception {
// given
for (int i = 0; i < maxKeyCount + 1; i++) {
insert(i);
}
MutableLong primKey = layout.newKey();
node.keyAt(cursor, primKey, 0);
long expectedNext = primKey.longValue();
long rightChild = GenerationSafePointerPair.pointer(node.childAt(cursor, 1, stableGeneration, unstableGeneration));
// when
try (SeekCursor<MutableLong, MutableLong> seek = seekCursor(expectedNext, maxKeyCount + 1)) {
assertEquals(rightChild, cursor.getCurrentPageId());
while (seek.next()) {
assertKeyAndValue(seek, expectedNext);
expectedNext++;
}
}
// then
assertEquals(maxKeyCount + 1, expectedNext);
}
use of org.apache.commons.lang3.mutable.MutableLong in project neo4j by neo4j.
the class TreeNodeTest method shouldRemoveKey.
private void shouldRemoveKey() throws Exception {
// GIVEN
MutableLong key = layout.newKey();
long firstKey = 10;
key.setValue(firstKey);
node.insertKeyAt(cursor, key, 0, 0);
long otherKey = 19;
key.setValue(otherKey);
node.insertKeyAt(cursor, key, 1, 1);
long thirdKey = 123;
key.setValue(thirdKey);
node.insertKeyAt(cursor, key, 2, 2);
// WHEN
node.removeKeyAt(cursor, 1, 3);
// THEN
assertEquals(firstKey, node.keyAt(cursor, key, 0).longValue());
assertEquals(thirdKey, node.keyAt(cursor, key, 1).longValue());
}
use of org.apache.commons.lang3.mutable.MutableLong in project neo4j by neo4j.
the class TreeNodeTest method shouldSetAndGetValue.
@Test
public void shouldSetAndGetValue() throws Exception {
// GIVEN
node.initializeLeaf(cursor, STABLE_GENERATION, UNSTABLE_GENERATION);
MutableLong value = layout.newKey();
// WHEN
long firstValue = 123456789;
value.setValue(firstValue);
node.insertValueAt(cursor, value, 0, 0);
long otherValue = 987654321;
value.setValue(otherValue);
node.insertValueAt(cursor, value, 1, 1);
// THEN
assertEquals(firstValue, node.valueAt(cursor, value, 0).longValue());
assertEquals(otherValue, node.valueAt(cursor, value, 1).longValue());
}
use of org.apache.commons.lang3.mutable.MutableLong in project neo4j by neo4j.
the class TreeNodeTest method shouldSetAndGetKey.
private void shouldSetAndGetKey() throws Exception {
// GIVEN
MutableLong key = layout.newKey();
// WHEN
long firstKey = 10;
key.setValue(firstKey);
node.insertKeyAt(cursor, key, 0, 0);
long otherKey = 19;
key.setValue(otherKey);
node.insertKeyAt(cursor, key, 1, 1);
// THEN
assertEquals(firstKey, node.keyAt(cursor, key, 0).longValue());
assertEquals(otherKey, node.keyAt(cursor, key, 1).longValue());
}
Aggregations