Search in sources :

Example 1 with IdController

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));
}
Also used : Label(org.neo4j.graphdb.Label) IdController(org.neo4j.kernel.impl.storageengine.impl.recordstorage.id.IdController) Test(org.junit.Test)

Example 2 with IdController

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();
    }
}
Also used : Transaction(org.neo4j.graphdb.Transaction) Node(org.neo4j.graphdb.Node) Relationship(org.neo4j.graphdb.Relationship) Label(org.neo4j.graphdb.Label) IdController(org.neo4j.kernel.impl.storageengine.impl.recordstorage.id.IdController) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 Label (org.neo4j.graphdb.Label)2 IdController (org.neo4j.kernel.impl.storageengine.impl.recordstorage.id.IdController)2 Node (org.neo4j.graphdb.Node)1 Relationship (org.neo4j.graphdb.Relationship)1 Transaction (org.neo4j.graphdb.Transaction)1