Search in sources :

Example 11 with RelationshipGroupRecord

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

the class PhysicalLogCommandReaderV3_0Test method readRelationshipGroupCommandWithNonRequiredSecondaryUnit.

@Test
public void readRelationshipGroupCommandWithNonRequiredSecondaryUnit() throws IOException {
    // Given
    InMemoryClosableChannel channel = new InMemoryClosableChannel();
    RelationshipGroupRecord before = new RelationshipGroupRecord(42, 3);
    RelationshipGroupRecord after = new RelationshipGroupRecord(42, 3, 4, 5, 6, 7, 8, true);
    after.setRequiresSecondaryUnit(false);
    after.setSecondaryUnitId(17);
    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());
    verifySecondaryUnit(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 12 with RelationshipGroupRecord

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

the class PhysicalLogCommandReadersTest method assertValidRelGroupCommand.

private static void assertValidRelGroupCommand(StorageCommand command) {
    assertThat(command, instanceOf(RelationshipGroupCommand.class));
    RelationshipGroupCommand relGroupCommand = (RelationshipGroupCommand) command;
    RelationshipGroupRecord record = relGroupCommand.getAfter();
    assertEquals(ID, record.getId());
    if (IN_USE_FLAG == Record.IN_USE.byteValue()) {
        assertTrue(record.inUse());
    } else if (IN_USE_FLAG == Record.NOT_IN_USE.byteValue()) {
        assertFalse(record.inUse());
    } else {
        throw new IllegalStateException("Illegal inUse flag: " + IN_USE_FLAG);
    }
    assertEquals(TYPE_AS_INT, record.getType());
    assertEquals(NEXT, record.getNext());
    assertEquals(FIRST_OUT, record.getFirstOut());
    assertEquals(FIRST_IN, record.getFirstIn());
    assertEquals(FIRST_LOOP, record.getNext());
    assertEquals(OWNING_NODE, record.getOwningNode());
}
Also used : RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) RelationshipGroupCommand(org.neo4j.kernel.impl.transaction.command.Command.RelationshipGroupCommand)

Example 13 with RelationshipGroupRecord

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

the class PhysicalLogCommandReaderV3_0Test method readRelationshipGroupCommandWithSecondaryUnit.

@Test
public void readRelationshipGroupCommandWithSecondaryUnit() throws IOException {
    // Given
    InMemoryClosableChannel channel = new InMemoryClosableChannel();
    RelationshipGroupRecord before = new RelationshipGroupRecord(42, 3);
    RelationshipGroupRecord after = new RelationshipGroupRecord(42, 3, 4, 5, 6, 7, 8, true);
    after.setRequiresSecondaryUnit(true);
    after.setSecondaryUnitId(17);
    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());
    verifySecondaryUnit(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 14 with RelationshipGroupRecord

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

the class NeoStoreTransactionApplierTest method shouldApplyRelationshipGroupCommandToTheStoreInRecovery.

@Test
public void shouldApplyRelationshipGroupCommandToTheStoreInRecovery() throws Exception {
    // given
    final BatchTransactionApplier applier = newApplier(true);
    // 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);
    boolean result = apply(applier, command::handle, transactionToApply);
    // then
    assertFalse(result);
    verify(relationshipGroupStore, times(1)).setHighestPossibleIdInUse(after.getId());
    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 15 with RelationshipGroupRecord

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

the class RelationshipGroupRecordFormatTest method shouldReadUnsignedRelationshipTypeId.

@Test
public void shouldReadUnsignedRelationshipTypeId() throws Exception {
    // GIVEN
    try (PageCursor cursor = new StubPageCursor(1, recordSize * 10)) {
        int offset = 10;
        cursor.next();
        RelationshipGroupRecord group = new RelationshipGroupRecord(2).initialize(true, Short.MAX_VALUE + offset, 1, 2, 3, 4, 5);
        cursor.setOffset(offset);
        format.write(group, cursor, recordSize);
        // WHEN
        RelationshipGroupRecord read = new RelationshipGroupRecord(group.getId());
        cursor.setOffset(offset);
        format.read(read, cursor, NORMAL, recordSize);
        // THEN
        assertEquals(group, read);
    }
}
Also used : RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) StubPageCursor(org.neo4j.io.pagecache.StubPageCursor) PageCursor(org.neo4j.io.pagecache.PageCursor) StubPageCursor(org.neo4j.io.pagecache.StubPageCursor) 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