Search in sources :

Example 6 with NodeCommand

use of org.neo4j.kernel.impl.transaction.command.Command.NodeCommand in project neo4j by neo4j.

the class IndexBatchTransactionApplierTest method node.

private NodeCommand node(long nodeId) {
    NodeRecord after = new NodeRecord(nodeId, true, false, NO_NEXT_RELATIONSHIP.intValue(), NO_NEXT_PROPERTY.intValue(), 0);
    NodeLabelsField.parseLabelsField(after).add(1, null, null);
    return new NodeCommand(new NodeRecord(nodeId), after);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) NodeCommand(org.neo4j.kernel.impl.transaction.command.Command.NodeCommand)

Example 7 with NodeCommand

use of org.neo4j.kernel.impl.transaction.command.Command.NodeCommand in project neo4j by neo4j.

the class Commands method createNode.

public static NodeCommand createNode(long id, long... dynamicLabelRecordIds) {
    NodeRecord record = new NodeRecord(id);
    record.setInUse(true);
    record.setCreated();
    if (dynamicLabelRecordIds.length > 0) {
        Collection<DynamicRecord> dynamicRecords = dynamicRecords(dynamicLabelRecordIds);
        record.setLabelField(DynamicNodeLabels.dynamicPointer(dynamicRecords), dynamicRecords);
    }
    return new NodeCommand(new NodeRecord(id), record);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) NodeCommand(org.neo4j.kernel.impl.transaction.command.Command.NodeCommand)

Example 8 with NodeCommand

use of org.neo4j.kernel.impl.transaction.command.Command.NodeCommand in project neo4j by neo4j.

the class HighIdTransactionApplierTest method shouldTrackSecondaryUnitIdsAsWell.

@Test
public void shouldTrackSecondaryUnitIdsAsWell() throws Exception {
    // GIVEN
    NeoStores neoStores = neoStoresRule.open();
    HighIdTransactionApplier tracker = new HighIdTransactionApplier(neoStores);
    NodeRecord node = new NodeRecord(5).initialize(true, 123, true, 456, 0);
    node.setSecondaryUnitId(6);
    node.setRequiresSecondaryUnit(true);
    RelationshipRecord relationship = new RelationshipRecord(10).initialize(true, 1, 2, 3, 4, 5, 6, 7, 8, true, true);
    relationship.setSecondaryUnitId(12);
    relationship.setRequiresSecondaryUnit(true);
    RelationshipGroupRecord relationshipGroup = new RelationshipGroupRecord(8).initialize(true, 0, 1, 2, 3, 4, 5);
    relationshipGroup.setSecondaryUnitId(20);
    relationshipGroup.setRequiresSecondaryUnit(true);
    // WHEN
    tracker.visitNodeCommand(new NodeCommand(new NodeRecord(node.getId()), node));
    tracker.visitRelationshipCommand(new RelationshipCommand(new RelationshipRecord(relationship.getId()), relationship));
    tracker.visitRelationshipGroupCommand(new RelationshipGroupCommand(new RelationshipGroupRecord(relationshipGroup.getId()), relationshipGroup));
    tracker.close();
    // THEN
    assertEquals(node.getSecondaryUnitId() + 1, neoStores.getNodeStore().getHighId());
    assertEquals(relationship.getSecondaryUnitId() + 1, neoStores.getRelationshipStore().getHighId());
    assertEquals(relationshipGroup.getSecondaryUnitId() + 1, neoStores.getRelationshipGroupStore().getHighId());
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) NeoStores(org.neo4j.kernel.impl.store.NeoStores) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) RelationshipGroupCommand(org.neo4j.kernel.impl.transaction.command.Command.RelationshipGroupCommand) RelationshipCommand(org.neo4j.kernel.impl.transaction.command.Command.RelationshipCommand) NodeCommand(org.neo4j.kernel.impl.transaction.command.Command.NodeCommand) Test(org.junit.Test)

Example 9 with NodeCommand

use of org.neo4j.kernel.impl.transaction.command.Command.NodeCommand in project neo4j by neo4j.

the class TransactionRecordStateTest method shouldPrepareRelevantRecords.

@Test
public void shouldPrepareRelevantRecords() throws Exception {
    // GIVEN
    PrepareTrackingRecordFormats format = new PrepareTrackingRecordFormats(Standard.LATEST_RECORD_FORMATS);
    NeoStores neoStores = neoStoresRule.open(format, GraphDatabaseSettings.dense_node_threshold.name(), "1");
    // WHEN
    TransactionRecordState state = newTransactionRecordState(neoStores);
    state.nodeCreate(0);
    state.relCreate(0, 0, 0, 0);
    state.relCreate(1, 0, 0, 0);
    state.relCreate(2, 0, 0, 0);
    List<StorageCommand> commands = new ArrayList<>();
    state.extractCommands(commands);
    // THEN
    int nodes = 0, rels = 0, groups = 0;
    for (StorageCommand command : commands) {
        if (command instanceof NodeCommand) {
            assertTrue(format.node().prepared(((NodeCommand) command).getAfter()));
            nodes++;
        } else if (command instanceof RelationshipCommand) {
            assertTrue(format.relationship().prepared(((RelationshipCommand) command).getAfter()));
            rels++;
        } else if (command instanceof RelationshipGroupCommand) {
            assertTrue(format.relationshipGroup().prepared(((RelationshipGroupCommand) command).getAfter()));
            groups++;
        }
    }
    assertEquals(1, nodes);
    assertEquals(3, rels);
    assertEquals(1, groups);
}
Also used : NeoStores(org.neo4j.kernel.impl.store.NeoStores) StorageCommand(org.neo4j.storageengine.api.StorageCommand) ArrayList(java.util.ArrayList) RelationshipGroupCommand(org.neo4j.kernel.impl.transaction.command.Command.RelationshipGroupCommand) RelationshipCommand(org.neo4j.kernel.impl.transaction.command.Command.RelationshipCommand) NodeCommand(org.neo4j.kernel.impl.transaction.command.Command.NodeCommand) Test(org.junit.Test)

Aggregations

NodeCommand (org.neo4j.kernel.impl.transaction.command.Command.NodeCommand)9 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)7 StorageCommand (org.neo4j.storageengine.api.StorageCommand)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 RelationshipCommand (org.neo4j.kernel.impl.transaction.command.Command.RelationshipCommand)3 NeoStores (org.neo4j.kernel.impl.store.NeoStores)2 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)2 RelationshipGroupCommand (org.neo4j.kernel.impl.transaction.command.Command.RelationshipGroupCommand)2 IOException (java.io.IOException)1 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Collectors.toList (java.util.stream.Collectors.toList)1 Assert.assertNotNull (org.junit.Assert.assertNotNull)1 Label (org.neo4j.graphdb.Label)1 Transaction (org.neo4j.graphdb.Transaction)1 Iterators.singleOrNull (org.neo4j.helpers.collection.Iterators.singleOrNull)1 TransactionCommitProcess (org.neo4j.kernel.impl.api.TransactionCommitProcess)1 TransactionToApply (org.neo4j.kernel.impl.api.TransactionToApply)1