Search in sources :

Example 21 with RelationshipGroupRecord

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

the class RelationshipGroupRecordFormatTest method readWriteFixedReferencesRecord.

@Test
public void readWriteFixedReferencesRecord() throws Exception {
    RelationshipGroupRecord source = new RelationshipGroupRecord(1);
    RelationshipGroupRecord target = new RelationshipGroupRecord(1);
    source.initialize(true, randomType(), randomFixedReference(), randomFixedReference(), randomFixedReference(), randomFixedReference(), randomFixedReference());
    writeReadRecord(source, target);
    assertTrue("Record should use fixed reference format.", target.isUseFixedReferences());
    verifySame(source, target);
}
Also used : RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) Test(org.junit.Test)

Example 22 with RelationshipGroupRecord

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

the class RelationshipGroupRecordFormatTest method useFixedReferenceFormatWhenOneOfTheReferencesIsMissing.

@Test
public void useFixedReferenceFormatWhenOneOfTheReferencesIsMissing() throws IOException {
    RelationshipGroupRecord source = new RelationshipGroupRecord(1);
    RelationshipGroupRecord target = new RelationshipGroupRecord(1);
    verifyRecordsWithPoisonedReference(source, target, NULL);
}
Also used : RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) Test(org.junit.Test)

Example 23 with RelationshipGroupRecord

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

the class RelationshipGroupRecordFormatTest method useVariableLengthFormatWhenRecordSizeIsTooSmall.

@Test
public void useVariableLengthFormatWhenRecordSizeIsTooSmall() throws IOException {
    RelationshipGroupRecord source = new RelationshipGroupRecord(1);
    RelationshipGroupRecord target = new RelationshipGroupRecord(1);
    source.initialize(true, randomType(), randomFixedReference(), randomFixedReference(), randomFixedReference(), randomFixedReference(), randomFixedReference());
    writeReadRecord(source, target, RelationshipGroupRecordFormat.FIXED_FORMAT_RECORD_SIZE - 1);
    assertFalse("Record should use variable length reference if format record is too small.", target.isUseFixedReferences());
    verifySame(source, target);
}
Also used : RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) Test(org.junit.Test)

Example 24 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 25 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)

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