Search in sources :

Example 26 with StorageCommand

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

the class LogCommandSerializationV4_0Test method shouldReadPropertyKeyCommand.

@Test
void shouldReadPropertyKeyCommand() throws Exception {
    // Given
    InMemoryClosableChannel channel = new InMemoryClosableChannel();
    PropertyKeyTokenRecord before = new PropertyKeyTokenRecord(42);
    PropertyKeyTokenRecord after = before.copy();
    after.initialize(true, 13);
    after.setCreated();
    new Command.PropertyKeyTokenCommand(writer(), before, after).serialize(channel);
    // When
    CommandReader reader = createReader();
    StorageCommand command = reader.read(channel);
    assertTrue(command instanceof Command.PropertyKeyTokenCommand);
    Command.PropertyKeyTokenCommand propertyKeyTokenCommand = (Command.PropertyKeyTokenCommand) command;
    // Then
    assertBeforeAndAfterEquals(propertyKeyTokenCommand, 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) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test)

Example 27 with StorageCommand

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

the class LogCommandSerializationV4_0Test method readRelationshipCommandWithFixedReferenceFormat.

@Test
void readRelationshipCommandWithFixedReferenceFormat() 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.setUseFixedReferences(true);
    RelationshipRecord after = new RelationshipRecord(42);
    after.initialize(true, 0, 1, 8, 3, 4, 5, 6, 7, true, true);
    after.setUseFixedReferences(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);
    assertTrue(relationshipCommand.getBefore().isUseFixedReferences());
    assertTrue(relationshipCommand.getAfter().isUseFixedReferences());
}
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 28 with StorageCommand

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

the class LogCommandSerializationV4_0Test method readPropertyCommandWithFixedReferenceFormat.

@Test
void readPropertyCommandWithFixedReferenceFormat() throws IOException {
    InMemoryClosableChannel channel = new InMemoryClosableChannel();
    PropertyRecord before = new PropertyRecord(1);
    PropertyRecord after = new PropertyRecord(1);
    before.setUseFixedReferences(true);
    after.setUseFixedReferences(true);
    new Command.PropertyCommand(writer(), before, after).serialize(channel);
    CommandReader reader = createReader();
    StorageCommand command = reader.read(channel);
    assertTrue(command instanceof Command.PropertyCommand);
    Command.PropertyCommand propertyCommand = (Command.PropertyCommand) command;
    // Then
    assertBeforeAndAfterEquals(propertyCommand, before, after);
    assertTrue(propertyCommand.getBefore().isUseFixedReferences());
    assertTrue(propertyCommand.getAfter().isUseFixedReferences());
}
Also used : CommandReader(org.neo4j.storageengine.api.CommandReader) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) 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 29 with StorageCommand

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

the class LogCommandSerializationV4_0Test method readRelationshipCommandWithNonRequiredSecondaryUnit.

@Test
void readRelationshipCommandWithNonRequiredSecondaryUnit() 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(52);
    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 30 with StorageCommand

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

the class LogCommandSerializationV4_0Test method shouldReadRelationshipTypeCommand.

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