use of org.eclipse.collections.impl.block.procedure.checked.primitive.CheckedLongProcedure in project neo4j by neo4j.
the class ParallelRelationshipCursorTransactionStateTestBase method scanShouldNotSeeDeletedRelationships.
@Test
void scanShouldNotSeeDeletedRelationships() throws Exception {
int size = 100;
MutableLongSet created = LongSets.mutable.empty();
MutableLongSet deleted = LongSets.mutable.empty();
try (KernelTransaction tx = beginTransaction()) {
Write write = tx.dataWrite();
int type = tx.tokenWrite().relationshipTypeGetOrCreateForName("R");
for (int i = 0; i < size; i++) {
created.add(write.relationshipCreate(write.nodeCreate(), type, write.nodeCreate()));
deleted.add(write.relationshipCreate(write.nodeCreate(), type, write.nodeCreate()));
}
tx.commit();
}
try (KernelTransaction tx = beginTransaction()) {
deleted.each(new CheckedLongProcedure() {
@Override
public void safeValue(long item) throws Exception {
tx.dataWrite().relationshipDelete(item);
}
});
try (RelationshipScanCursor cursor = tx.cursors().allocateRelationshipScanCursor(NULL)) {
Scan<RelationshipScanCursor> scan = tx.dataRead().allRelationshipsScan();
MutableLongSet seen = LongSets.mutable.empty();
while (scan.reserveBatch(cursor, 17)) {
while (cursor.next()) {
long relationshipId = cursor.relationshipReference();
assertTrue(seen.add(relationshipId));
assertTrue(created.remove(relationshipId));
}
}
assertTrue(created.isEmpty());
}
}
}
use of org.eclipse.collections.impl.block.procedure.checked.primitive.CheckedLongProcedure in project neo4j by neo4j.
the class ParallelNodeCursorTransactionStateTestBase method scanShouldNotSeeDeletedNode.
@Test
void scanShouldNotSeeDeletedNode() throws Exception {
int size = 100;
MutableLongSet created = LongSets.mutable.empty();
MutableLongSet deleted = LongSets.mutable.empty();
try (KernelTransaction tx = beginTransaction()) {
Write write = tx.dataWrite();
for (int i = 0; i < size; i++) {
created.add(write.nodeCreate());
deleted.add(write.nodeCreate());
}
tx.commit();
}
try (KernelTransaction tx = beginTransaction()) {
deleted.each(new CheckedLongProcedure() {
@Override
public void safeValue(long item) throws Exception {
tx.dataWrite().nodeDelete(item);
}
});
try (NodeCursor cursor = tx.cursors().allocateNodeCursor(NULL)) {
Scan<NodeCursor> scan = tx.dataRead().allNodesScan();
MutableLongSet seen = LongSets.mutable.empty();
while (scan.reserveBatch(cursor, 17)) {
while (cursor.next()) {
long nodeId = cursor.nodeReference();
assertTrue(seen.add(nodeId));
assertTrue(created.remove(nodeId));
}
}
assertTrue(created.isEmpty());
}
}
}
Aggregations