Search in sources :

Example 21 with StorageCommand

use of org.neo4j.storageengine.api.StorageCommand in project neo4j by neo4j.

the class CommitProcessTracingIT method tracePageCacheAccessOnCommandCreation.

@Test
void tracePageCacheAccessOnCommandCreation() throws KernelException {
    long sourceId;
    try (Transaction transaction = database.beginTx()) {
        sourceId = transaction.createNode(Label.label("a")).getId();
        transaction.commit();
    }
    var pageCacheTracer = new DefaultPageCacheTracer();
    try (var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("tracePageCacheAccessOnCommandCreation"));
        var reader = storageEngine.newReader()) {
        assertZeroCursor(cursorContext);
        try (CommandCreationContext context = storageEngine.newCommandCreationContext(INSTANCE)) {
            context.initialize(cursorContext);
            List<StorageCommand> commands = new ArrayList<>();
            var txState = new TxState();
            txState.nodeDoAddLabel(1, sourceId);
            storageEngine.createCommands(commands, txState, reader, context, IGNORE, LockTracer.NONE, 0, NO_DECORATION, cursorContext, INSTANCE);
        }
        assertCursor(cursorContext, 2);
    }
}
Also used : CommandCreationContext(org.neo4j.storageengine.api.CommandCreationContext) Transaction(org.neo4j.graphdb.Transaction) TxState(org.neo4j.kernel.impl.api.state.TxState) StorageCommand(org.neo4j.storageengine.api.StorageCommand) ArrayList(java.util.ArrayList) CursorContext(org.neo4j.io.pagecache.context.CursorContext) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) Test(org.junit.jupiter.api.Test)

Example 22 with StorageCommand

use of org.neo4j.storageengine.api.StorageCommand in project neo4j by neo4j.

the class PhysicalLogCommandReadersTest method assertCanReadRelGroup.

private static void assertCanReadRelGroup(CommandReader reader) throws IOException {
    StorageCommand command = reader.read(channelWithRelGroupRecord());
    assertValidRelGroupCommand(command);
}
Also used : StorageCommand(org.neo4j.storageengine.api.StorageCommand)

Example 23 with StorageCommand

use of org.neo4j.storageengine.api.StorageCommand in project neo4j by neo4j.

the class LogCommandSerializationV4_0Test method readRelationshipCommandWithSecondaryUnit.

@Test
void readRelationshipCommandWithSecondaryUnit() throws IOException {
    InMemoryClosableChannel channel = new InMemoryClosableChannel();
    RelationshipRecord before = new RelationshipRecord(42);
    before.initialize(true, 0, 1, 2, 3, 4, 5, 6, 7, true, true);
    before.setSecondaryUnitIdOnLoad(47);
    RelationshipRecord after = new RelationshipRecord(42);
    after.initialize(true, 0, 1, 8, 3, 4, 5, 6, 7, true, true);
    new Command.RelationshipCommand(writer(), before, after).serialize(channel);
    CommandReader reader = createReader();
    StorageCommand command = reader.read(channel);
    assertTrue(command instanceof Command.RelationshipCommand);
    Command.RelationshipCommand relationshipCommand = (Command.RelationshipCommand) command;
    assertBeforeAndAfterEquals(relationshipCommand, before, after);
}
Also used : CommandReader(org.neo4j.storageengine.api.CommandReader) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) StorageCommand(org.neo4j.storageengine.api.StorageCommand) StorageCommand(org.neo4j.storageengine.api.StorageCommand) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test)

Example 24 with StorageCommand

use of org.neo4j.storageengine.api.StorageCommand in project neo4j by neo4j.

the class LogCommandSerializationV4_0Test method shouldReadLabelCommand.

@Test
void shouldReadLabelCommand() throws Exception {
    // Given
    InMemoryClosableChannel channel = new InMemoryClosableChannel();
    LabelTokenRecord before = new LabelTokenRecord(42);
    LabelTokenRecord after = before.copy();
    after.initialize(true, 13);
    after.setCreated();
    new Command.LabelTokenCommand(writer(), before, after).serialize(channel);
    // When
    CommandReader reader = createReader();
    StorageCommand command = reader.read(channel);
    assertTrue(command instanceof Command.LabelTokenCommand);
    Command.LabelTokenCommand labelTokenCommand = (Command.LabelTokenCommand) command;
    // Then
    assertBeforeAndAfterEquals(labelTokenCommand, before, after);
}
Also used : CommandReader(org.neo4j.storageengine.api.CommandReader) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) StorageCommand(org.neo4j.storageengine.api.StorageCommand) StorageCommand(org.neo4j.storageengine.api.StorageCommand) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test)

Example 25 with StorageCommand

use of org.neo4j.storageengine.api.StorageCommand in project neo4j by neo4j.

the class LogCommandSerializationV4_0Test method shouldReadInternalRelationshipTypeLabelCommand.

@Test
void shouldReadInternalRelationshipTypeLabelCommand() throws Exception {
    // Given
    InMemoryClosableChannel channel = new InMemoryClosableChannel();
    RelationshipTypeTokenRecord before = new RelationshipTypeTokenRecord(42);
    RelationshipTypeTokenRecord after = before.copy();
    after.initialize(true, 13);
    after.setCreated();
    after.setInternal(true);
    new Command.RelationshipTypeTokenCommand(writer(), before, after).serialize(channel);
    // When
    CommandReader reader = createReader();
    StorageCommand command = reader.read(channel);
    assertTrue(command instanceof Command.RelationshipTypeTokenCommand);
    Command.RelationshipTypeTokenCommand relationshipTypeTokenCommand = (Command.RelationshipTypeTokenCommand) command;
    // Then
    assertBeforeAndAfterEquals(relationshipTypeTokenCommand, before, after);
}
Also used : CommandReader(org.neo4j.storageengine.api.CommandReader) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) StorageCommand(org.neo4j.storageengine.api.StorageCommand) StorageCommand(org.neo4j.storageengine.api.StorageCommand) RelationshipTypeTokenRecord(org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test)

Aggregations

StorageCommand (org.neo4j.storageengine.api.StorageCommand)77 ArrayList (java.util.ArrayList)39 Test (org.junit.jupiter.api.Test)34 CommandReader (org.neo4j.storageengine.api.CommandReader)23 InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)22 RepeatedTest (org.junit.jupiter.api.RepeatedTest)19 PhysicalTransactionRepresentation (org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation)14 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)10 Test (org.junit.Test)10 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)9 RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)9 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)8 Command (org.neo4j.kernel.impl.transaction.command.Command)7 NodeCommand (org.neo4j.kernel.impl.transaction.command.Command.NodeCommand)7 LogEntryCommand (org.neo4j.kernel.impl.transaction.log.entry.LogEntryCommand)7 SchemaRuleCommand (org.neo4j.internal.recordstorage.Command.SchemaRuleCommand)6 NeoStores (org.neo4j.kernel.impl.store.NeoStores)6 IOException (java.io.IOException)5 PropertyCommand (org.neo4j.internal.recordstorage.Command.PropertyCommand)5 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)5