use of org.neo4j.kernel.impl.storageengine.impl.recordstorage.id.IdController in project neo4j by neo4j.
the class IdReuseTest method sequentialOperationRelationshipIdReuse.
@Test
public void sequentialOperationRelationshipIdReuse() {
Label marker = Label.label("marker");
long relationship1 = createRelationship(marker);
long relationship2 = createRelationship(marker);
long relationship3 = createRelationship(marker);
assertEquals("Ids should be sequential", relationship1 + 1, relationship2);
assertEquals("Ids should be sequential", relationship2 + 1, relationship3);
final IdController idMaintenanceController = getIdMaintenanceController();
deleteRelationshipByLabelAndRelationshipType(marker);
idMaintenanceController.maintenance();
assertEquals("Relationships have reused id", relationship1, createRelationship(marker));
assertEquals("Relationships have reused id", relationship2, createRelationship(marker));
assertEquals("Relationships have reused id", relationship3, createRelationship(marker));
}
use of org.neo4j.kernel.impl.storageengine.impl.recordstorage.id.IdController in project neo4j by neo4j.
the class IdReuseTest method relationshipIdReusableOnlyAfterTransactionFinish.
@Test
public void relationshipIdReusableOnlyAfterTransactionFinish() {
Label testLabel = Label.label("testLabel");
long relationshipId = createRelationship(testLabel);
final IdController idMaintenanceController = getIdMaintenanceController();
try (Transaction transaction = dbRule.beginTx();
ResourceIterator<Node> nodes = dbRule.findNodes(testLabel)) {
List<Node> nodeList = Iterators.asList(nodes);
for (Node node : nodeList) {
Iterable<Relationship> relationships = node.getRelationships(TestRelationshipType.MARKER);
for (Relationship relationship : relationships) {
relationship.delete();
}
}
idMaintenanceController.maintenance();
Node node1 = dbRule.createNode(testLabel);
Node node2 = dbRule.createNode(testLabel);
Relationship relationshipTo = node1.createRelationshipTo(node2, TestRelationshipType.MARKER);
assertNotEquals("Relatioships should have different ids.", relationshipId, relationshipTo.getId());
transaction.success();
}
}
Aggregations