Search in sources :

Example 1 with NodeCommand

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

the class BatchingTransactionAppenderTest method singleCreateNodeCommand.

private Collection<StorageCommand> singleCreateNodeCommand(long id) {
    Collection<StorageCommand> commands = new ArrayList<>();
    NodeRecord before = new NodeRecord(id);
    NodeRecord after = new NodeRecord(id);
    after.setInUse(true);
    commands.add(new NodeCommand(before, after));
    return commands;
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) StorageCommand(org.neo4j.storageengine.api.StorageCommand) ArrayList(java.util.ArrayList) NodeCommand(org.neo4j.kernel.impl.transaction.command.Command.NodeCommand)

Example 2 with NodeCommand

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

the class ApplyRecoveredTransactionsTest method shouldSetCorrectHighIdWhenApplyingExternalTransactions.

@Test
public void shouldSetCorrectHighIdWhenApplyingExternalTransactions() throws Exception {
    // WHEN recovering a transaction that creates some data
    long nodeId = neoStores.getNodeStore().nextId();
    long relationshipId = neoStores.getRelationshipStore().nextId();
    int type = 1;
    applyExternalTransaction(1, new NodeCommand(new NodeRecord(nodeId), inUse(created(new NodeRecord(nodeId)))), new RelationshipCommand(null, inUse(created(with(new RelationshipRecord(relationshipId), nodeId, nodeId, type)))));
    // and when, later on, recovering a transaction deleting some of those
    applyExternalTransaction(2, new NodeCommand(inUse(created(new NodeRecord(nodeId))), new NodeRecord(nodeId)), new RelationshipCommand(null, new RelationshipRecord(relationshipId)));
    // THEN that should be possible and the high ids should be correct, i.e. highest applied + 1
    assertEquals(nodeId + 1, neoStores.getNodeStore().getHighId());
    assertEquals(relationshipId + 1, neoStores.getRelationshipStore().getHighId());
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) RelationshipCommand(org.neo4j.kernel.impl.transaction.command.Command.RelationshipCommand) NodeCommand(org.neo4j.kernel.impl.transaction.command.Command.NodeCommand) Test(org.junit.Test)

Example 3 with NodeCommand

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

the class MadeUpServerImplementation method transaction.

private TransactionRepresentation transaction(long txId) {
    Collection<StorageCommand> commands = new ArrayList<>();
    NodeRecord node = new NodeRecord(txId);
    node.setInUse(true);
    commands.add(new NodeCommand(new NodeRecord(txId), node));
    PhysicalTransactionRepresentation transaction = new PhysicalTransactionRepresentation(commands);
    transaction.setHeader(new byte[0], 0, 0, 0, 0, 0, 0);
    return transaction;
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) StorageCommand(org.neo4j.storageengine.api.StorageCommand) ArrayList(java.util.ArrayList) NodeCommand(org.neo4j.kernel.impl.transaction.command.Command.NodeCommand) PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation)

Example 4 with NodeCommand

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

the class ProtocolTest method justOneNode.

private Collection<StorageCommand> justOneNode() {
    NodeRecord node = new NodeRecord(0);
    node.setInUse(true);
    return Arrays.<StorageCommand>asList(new NodeCommand(new NodeRecord(node.getId()), node));
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) StorageCommand(org.neo4j.storageengine.api.StorageCommand) NodeCommand(org.neo4j.kernel.impl.transaction.command.Command.NodeCommand)

Example 5 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)

Aggregations

NodeCommand (org.neo4j.kernel.impl.transaction.command.Command.NodeCommand)8 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)7 StorageCommand (org.neo4j.storageengine.api.StorageCommand)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 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 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)1 RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)1 PhysicalTransactionRepresentation (org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation)1