Search in sources :

Example 61 with RelationshipRecord

use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.

the class HighIdTransactionApplierTest method shouldTrackSecondaryUnitIdsAsWell.

@Test
void shouldTrackSecondaryUnitIdsAsWell() throws Exception {
    // GIVEN
    HighIdTransactionApplier tracker = new HighIdTransactionApplier(neoStores);
    NodeRecord node = new NodeRecord(5).initialize(true, 123, true, 456, 0);
    node.setSecondaryUnitIdOnLoad(6);
    RelationshipRecord relationship = new RelationshipRecord(10).initialize(true, 1, 2, 3, 4, 5, 6, 7, 8, true, true);
    relationship.setSecondaryUnitIdOnLoad(12);
    RelationshipGroupRecord relationshipGroup = new RelationshipGroupRecord(8).initialize(true, 0, 1, 2, 3, 4, 5);
    relationshipGroup.setSecondaryUnitIdOnLoad(20);
    // 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) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) RelationshipGroupCommand(org.neo4j.internal.recordstorage.Command.RelationshipGroupCommand) RelationshipCommand(org.neo4j.internal.recordstorage.Command.RelationshipCommand) NodeCommand(org.neo4j.internal.recordstorage.Command.NodeCommand) Test(org.junit.jupiter.api.Test)

Example 62 with RelationshipRecord

use of org.neo4j.kernel.impl.store.record.RelationshipRecord 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 63 with RelationshipRecord

use of org.neo4j.kernel.impl.store.record.RelationshipRecord 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 64 with RelationshipRecord

use of org.neo4j.kernel.impl.store.record.RelationshipRecord 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 65 with RelationshipRecord

use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.

the class LogCommandSerializationV4_0Test method shouldReadRelationshipCommand.

@Test
void shouldReadRelationshipCommand() throws Throwable {
    // Given
    InMemoryClosableChannel channel = new InMemoryClosableChannel();
    RelationshipRecord before = new RelationshipRecord(42);
    before.setLinks(-1, -1, -1);
    RelationshipRecord after = new RelationshipRecord(42);
    after.initialize(true, 0, 1, 2, 3, 4, 5, 6, 7, true, true);
    after.setCreated();
    new Command.RelationshipCommand(writer(), before, after).serialize(channel);
    // When
    CommandReader reader = createReader();
    StorageCommand command = reader.read(channel);
    assertTrue(command instanceof Command.RelationshipCommand);
    Command.RelationshipCommand relationshipCommand = (Command.RelationshipCommand) command;
    // Then
    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)

Aggregations

RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)207 Test (org.junit.Test)73 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)69 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)43 Test (org.junit.jupiter.api.Test)34 RelationshipTypeTokenRecord (org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord)30 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)19 RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)19 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 RelationshipStore (org.neo4j.kernel.impl.store.RelationshipStore)14 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)12 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)12 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)12 TransactionDataBuilder (org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder)11 InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)11 RecordAccessStub (org.neo4j.consistency.store.RecordAccessStub)9 InputRelationship (org.neo4j.unsafe.impl.batchimport.input.InputRelationship)8 RepeatedTest (org.junit.jupiter.api.RepeatedTest)7 IOException (java.io.IOException)6 CursorContext (org.neo4j.io.pagecache.context.CursorContext)6