Search in sources :

Example 61 with StorageCommand

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

the class LogCommandSerializationV4_3D_3Test method shouldReadRelationshipGroupCommandIncludingExternalDegrees.

@Test
void shouldReadRelationshipGroupCommandIncludingExternalDegrees() throws Throwable {
    // Given
    InMemoryClosableChannel channel = new InMemoryClosableChannel();
    RelationshipGroupRecord before = new RelationshipGroupRecord(42).initialize(false, 3, NULL_REF, NULL_REF, NULL_REF, NULL_REF, NULL_REF);
    RelationshipGroupRecord after = new RelationshipGroupRecord(42).initialize(true, 3, 4, 5, 6, 7, 8);
    after.setHasExternalDegreesOut(random.nextBoolean());
    after.setHasExternalDegreesIn(random.nextBoolean());
    after.setHasExternalDegreesLoop(random.nextBoolean());
    after.setCreated();
    new Command.RelationshipGroupCommand(writer(), before, after).serialize(channel);
    // When
    CommandReader reader = createReader();
    StorageCommand command = reader.read(channel);
    assertTrue(command instanceof Command.RelationshipGroupCommand);
    Command.RelationshipGroupCommand relationshipGroupCommand = (Command.RelationshipGroupCommand) command;
    // Then
    assertBeforeAndAfterEquals(relationshipGroupCommand, before, after);
}
Also used : CommandReader(org.neo4j.storageengine.api.CommandReader) RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) StorageCommand(org.neo4j.storageengine.api.StorageCommand) StorageCommand(org.neo4j.storageengine.api.StorageCommand) Test(org.junit.jupiter.api.Test)

Example 62 with StorageCommand

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

the class LogCommandSerializationV4_0Test method nodeCommandWithFixedReferenceFormat.

@Test
void nodeCommandWithFixedReferenceFormat() throws Exception {
    // Given
    InMemoryClosableChannel channel = new InMemoryClosableChannel();
    NodeRecord before = new NodeRecord(42).initialize(true, 99, false, 33, 66);
    NodeRecord after = new NodeRecord(42).initialize(true, 99, false, 33, 66);
    before.setUseFixedReferences(true);
    after.setUseFixedReferences(true);
    new Command.NodeCommand(writer(), before, after).serialize(channel);
    // When
    CommandReader reader = createReader();
    StorageCommand command = reader.read(channel);
    assertTrue(command instanceof Command.NodeCommand);
    Command.NodeCommand nodeCommand = (Command.NodeCommand) command;
    // Then
    assertBeforeAndAfterEquals(nodeCommand, before, after);
    assertTrue(nodeCommand.getBefore().isUseFixedReferences());
    assertTrue(nodeCommand.getAfter().isUseFixedReferences());
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) 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) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test)

Example 63 with StorageCommand

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

the class LogCommandSerializationV4_0Test method readRelationshipGroupWithBiggerThanShortRelationshipType.

@Test
public void readRelationshipGroupWithBiggerThanShortRelationshipType() throws IOException {
    // Given
    InMemoryClosableChannel channel = new InMemoryClosableChannel();
    RelationshipGroupRecord before = new RelationshipGroupRecord(42).initialize(false, 3, NULL_REF, NULL_REF, NULL_REF, NULL_REF, NULL_REF);
    RelationshipGroupRecord after = new RelationshipGroupRecord(42).initialize(true, (1 << Short.SIZE) + 10, 4, 5, 6, 7, 8);
    after.setCreated();
    new Command.RelationshipGroupCommand(before, after).serialize(channel);
    // When
    CommandReader reader = createReader();
    StorageCommand command = reader.read(channel);
    assertTrue(command instanceof Command.RelationshipGroupCommand);
    Command.RelationshipGroupCommand relationshipGroupCommand = (Command.RelationshipGroupCommand) command;
    // Then
    assertBeforeAndAfterEquals(relationshipGroupCommand, before, after);
}
Also used : CommandReader(org.neo4j.storageengine.api.CommandReader) RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) StorageCommand(org.neo4j.storageengine.api.StorageCommand) StorageCommand(org.neo4j.storageengine.api.StorageCommand) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test)

Example 64 with StorageCommand

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

the class LogCommandSerializationV4_0Test method readRelationshipGroupCommandWithSecondaryUnit.

@Test
void readRelationshipGroupCommandWithSecondaryUnit() throws IOException {
    // Given
    InMemoryClosableChannel channel = new InMemoryClosableChannel();
    RelationshipGroupRecord before = new RelationshipGroupRecord(42).initialize(false, 3, NULL_REF, NULL_REF, NULL_REF, NULL_REF, NULL_REF);
    RelationshipGroupRecord after = new RelationshipGroupRecord(42).initialize(true, 3, 4, 5, 6, 7, 8);
    after.setSecondaryUnitIdOnCreate(17);
    after.setCreated();
    new Command.RelationshipGroupCommand(writer(), before, after).serialize(channel);
    // When
    CommandReader reader = createReader();
    StorageCommand command = reader.read(channel);
    assertTrue(command instanceof Command.RelationshipGroupCommand);
    Command.RelationshipGroupCommand relationshipGroupCommand = (Command.RelationshipGroupCommand) command;
    // Then
    assertBeforeAndAfterEquals(relationshipGroupCommand, before, after);
}
Also used : CommandReader(org.neo4j.storageengine.api.CommandReader) RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) StorageCommand(org.neo4j.storageengine.api.StorageCommand) StorageCommand(org.neo4j.storageengine.api.StorageCommand) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test)

Example 65 with StorageCommand

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

the class LogCommandSerializationV4_0Test method shouldReadInternalLabelCommand.

@Test
void shouldReadInternalLabelCommand() throws Exception {
    // Given
    InMemoryClosableChannel channel = new InMemoryClosableChannel();
    LabelTokenRecord before = new LabelTokenRecord(42);
    LabelTokenRecord after = before.copy();
    after.initialize(true, 13);
    after.setCreated();
    after.setInternal(true);
    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)

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