Search in sources :

Example 96 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 97 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 98 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 99 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 100 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)155 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)40 Test (org.junit.jupiter.api.Test)31 Test (org.junit.Test)27 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)20 InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)16 StorageCommand (org.neo4j.storageengine.api.StorageCommand)9 CommandReader (org.neo4j.storageengine.api.CommandReader)8 RepeatedTest (org.junit.jupiter.api.RepeatedTest)7 NodeStore (org.neo4j.kernel.impl.store.NodeStore)7 RelationshipGroupStore (org.neo4j.kernel.impl.store.RelationshipGroupStore)7 ArrayList (java.util.ArrayList)6 CursorContext (org.neo4j.io.pagecache.context.CursorContext)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 RelationshipStore (org.neo4j.kernel.impl.store.RelationshipStore)5 CachedStoreCursors (org.neo4j.kernel.impl.store.cursor.CachedStoreCursors)5 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)5 Command (org.neo4j.kernel.impl.transaction.command.Command)5 IOException (java.io.IOException)4 NeoStores (org.neo4j.kernel.impl.store.NeoStores)4