Search in sources :

Example 66 with RelationshipGroupRecord

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

the class PhysicalLogCommandReaderV3_0Test method shouldReadRelationshipGroupCommand.

@Test
public void shouldReadRelationshipGroupCommand() throws Throwable {
    // Given
    InMemoryClosableChannel channel = new InMemoryClosableChannel();
    RelationshipGroupRecord before = new RelationshipGroupRecord(42, 3);
    RelationshipGroupRecord after = new RelationshipGroupRecord(42, 3, 4, 5, 6, 7, 8, true);
    after.setCreated();
    new Command.RelationshipGroupCommand(before, after).serialize(channel);
    // When
    PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0();
    Command command = reader.read(channel);
    assertTrue(command instanceof Command.RelationshipGroupCommand);
    Command.RelationshipGroupCommand relationshipGroupCommand = (Command.RelationshipGroupCommand) command;
    // Then
    assertEquals(before, relationshipGroupCommand.getBefore());
    assertEquals(after, relationshipGroupCommand.getAfter());
}
Also used : RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) Test(org.junit.Test)

Example 67 with RelationshipGroupRecord

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

the class NeoStoreTransactionApplierTest method shouldApplyRelationshipGroupCommandToTheStore.

// RELATIONSHIP GROUP COMMAND
@Test
public void shouldApplyRelationshipGroupCommandToTheStore() throws Exception {
    // given
    final BatchTransactionApplier applier = newApplier(false);
    // when
    final RelationshipGroupRecord before = new RelationshipGroupRecord(42, 1);
    final RelationshipGroupRecord after = new RelationshipGroupRecord(42, 1, 2, 3, 4, 5, 6, true);
    final Command command = new Command.RelationshipGroupCommand(before, after);
    final boolean result = apply(applier, command::handle, transactionToApply);
    // then
    assertFalse(result);
    verify(relationshipGroupStore, times(1)).updateRecord(after);
}
Also used : RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) RelationshipTypeTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.RelationshipTypeTokenCommand) LabelTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.LabelTokenCommand) PropertyKeyTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.PropertyKeyTokenCommand) BatchTransactionApplier(org.neo4j.kernel.impl.api.BatchTransactionApplier) Test(org.junit.Test)

Example 68 with RelationshipGroupRecord

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

the class TransactionRecordStateTest method assertRelationshipGroupsInOrder.

private void assertRelationshipGroupsInOrder(NeoStores neoStores, long nodeId, int... types) {
    NodeStore nodeStore = neoStores.getNodeStore();
    NodeRecord node = nodeStore.getRecord(nodeId, nodeStore.newRecord(), NORMAL);
    assertTrue("Node should be dense, is " + node, node.isDense());
    long groupId = node.getNextRel();
    int cursor = 0;
    List<RelationshipGroupRecord> seen = new ArrayList<>();
    while (groupId != Record.NO_NEXT_RELATIONSHIP.intValue()) {
        RecordStore<RelationshipGroupRecord> relationshipGroupStore = neoStores.getRelationshipGroupStore();
        RelationshipGroupRecord group = relationshipGroupStore.getRecord(groupId, relationshipGroupStore.newRecord(), NORMAL);
        seen.add(group);
        assertEquals("Invalid type, seen groups so far " + seen, types[cursor++], group.getType());
        groupId = group.getNext();
    }
    assertEquals("Not enough relationship group records found in chain for " + node, types.length, cursor);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) NodeStore(org.neo4j.kernel.impl.store.NodeStore) RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) ArrayList(java.util.ArrayList)

Example 69 with RelationshipGroupRecord

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

the class TransactionRecordStateTest method getRelationshipGroup.

private static RecordProxy<Long, RelationshipGroupRecord, Integer> getRelationshipGroup(RecordChangeSet recordChangeSet, NodeRecord node, int type) {
    long groupId = node.getNextRel();
    long previousGroupId = Record.NO_NEXT_RELATIONSHIP.intValue();
    while (groupId != Record.NO_NEXT_RELATIONSHIP.intValue()) {
        RecordProxy<Long, RelationshipGroupRecord, Integer> change = recordChangeSet.getRelGroupRecords().getOrLoad(groupId, type);
        RelationshipGroupRecord record = change.forReadingData();
        // not persistent so not a "change"
        record.setPrev(previousGroupId);
        if (record.getType() == type) {
            return change;
        }
        previousGroupId = groupId;
        groupId = record.getNext();
    }
    return null;
}
Also used : RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) AtomicLong(java.util.concurrent.atomic.AtomicLong)

Example 70 with RelationshipGroupRecord

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

the class RelationshipGroupCommandV2_2Test method shouldSerializeCreatedRecord.

@Test
public void shouldSerializeCreatedRecord() throws Exception {
    // Given
    RelationshipGroupRecord before = new RelationshipGroupRecord(10, 12);
    before.setInUse(false);
    RelationshipGroupRecord after = new RelationshipGroupRecord(10, 12, 13, 14, 15, 16, 17, true);
    after.setCreated();
    // When
    assertSerializationWorksFor(new Command.RelationshipGroupCommand(before, after));
}
Also used : RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) Command(org.neo4j.kernel.impl.transaction.command.Command) Test(org.junit.Test)

Aggregations

RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)83 Test (org.junit.Test)42 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)24 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)11 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)11 TransactionDataBuilder (org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder)11 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)11 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)10 Command (org.neo4j.kernel.impl.transaction.command.Command)5 IOException (java.io.IOException)4 InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)4 File (java.io.File)3 Node (org.neo4j.graphdb.Node)3 Relationship (org.neo4j.graphdb.Relationship)3 Transaction (org.neo4j.graphdb.Transaction)3 RecordStorageEngine (org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine)3 NeoStores (org.neo4j.kernel.impl.store.NeoStores)3 RelationshipStore (org.neo4j.kernel.impl.store.RelationshipStore)3 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)3 RelationshipGroupCommand (org.neo4j.kernel.impl.transaction.command.Command.RelationshipGroupCommand)3