Search in sources :

Example 66 with RelationshipRecord

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

the class ApplyRecoveredTransactionsTest method shouldSetCorrectHighIdWhenApplyingExternalTransactions.

@Test
void shouldSetCorrectHighIdWhenApplyingExternalTransactions() throws Exception {
    // WHEN recovering a transaction that creates some data
    long nodeId = neoStores.getNodeStore().nextId(NULL);
    long relationshipId = neoStores.getRelationshipStore().nextId(NULL);
    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.internal.recordstorage.Command.RelationshipCommand) NodeCommand(org.neo4j.internal.recordstorage.Command.NodeCommand) Test(org.junit.jupiter.api.Test)

Example 67 with RelationshipRecord

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

the class Commands method createRelationship.

public static RelationshipCommand createRelationship(long id, long startNode, long endNode, int type) {
    RelationshipRecord before = new RelationshipRecord(id);
    before.setInUse(false);
    RelationshipRecord after = new RelationshipRecord(id);
    after.setLinks(startNode, endNode, type);
    after.setInUse(true);
    after.setCreated();
    return new RelationshipCommand(before, after);
}
Also used : RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) RelationshipCommand(org.neo4j.internal.recordstorage.Command.RelationshipCommand)

Example 68 with RelationshipRecord

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

the class LogCommandSerializationV3_0_10Test 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);
    Command command = INSTANCE.read(channel);
    assertTrue(command instanceof Command.RelationshipCommand);
    Command.RelationshipCommand relationshipCommand = (Command.RelationshipCommand) command;
    assertEquals(before, relationshipCommand.getBefore());
    verifySecondaryUnit(before, relationshipCommand.getBefore());
    assertEquals(after, relationshipCommand.getAfter());
}
Also used : InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) Test(org.junit.jupiter.api.Test)

Example 69 with RelationshipRecord

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

the class LogCommandSerializationV3_0_10Test 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);
    Command command = INSTANCE.read(channel);
    assertTrue(command instanceof Command.RelationshipCommand);
    Command.RelationshipCommand relationshipCommand = (Command.RelationshipCommand) command;
    assertEquals(before, relationshipCommand.getBefore());
    verifySecondaryUnit(before, relationshipCommand.getBefore());
    assertEquals(after, relationshipCommand.getAfter());
}
Also used : InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) Test(org.junit.jupiter.api.Test)

Example 70 with RelationshipRecord

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

the class LogCommandSerializationV3_0_10Test 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);
    new Command.RelationshipCommand(writer(), before, after).serialize(channel);
    // When
    Command command = INSTANCE.read(channel);
    assertTrue(command instanceof Command.RelationshipCommand);
    Command.RelationshipCommand relationshipCommand = (Command.RelationshipCommand) command;
    // Then
    assertEquals(before, relationshipCommand.getBefore());
    assertEquals(after, relationshipCommand.getAfter());
}
Also used : InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) 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