Search in sources :

Example 41 with RelationshipRecord

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

the class RelationshipRecordFormatTest method useFixedReferenceFormatWhenRecordCanFitInRecordSizeRecord.

@Test
public void useFixedReferenceFormatWhenRecordCanFitInRecordSizeRecord() throws IOException {
    RelationshipRecord source = new RelationshipRecord(1);
    RelationshipRecord target = new RelationshipRecord(1);
    source.initialize(true, randomFixedReference(), randomFixedReference(), randomFixedReference(), randomShortType(), randomFixedReference(), randomFixedReference(), randomFixedReference(), randomFixedReference(), true, true);
    writeReadRecord(source, target, RelationshipRecordFormat.FIXED_FORMAT_RECORD_SIZE);
    assertTrue("Record should use fixed reference if can fit in format record.", target.isUseFixedReferences());
    verifySameReferences(source, target);
}
Also used : RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) Test(org.junit.Test)

Example 42 with RelationshipRecord

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

the class RelationshipRecordFormatTest method useVariableLengthFormatWhenTypeIsTooBig.

@Test
public void useVariableLengthFormatWhenTypeIsTooBig() throws IOException {
    RelationshipRecord source = new RelationshipRecord(1);
    RelationshipRecord target = new RelationshipRecord(1);
    source.initialize(true, randomFixedReference(), randomFixedReference(), randomFixedReference(), 1 << 16, randomFixedReference(), randomFixedReference(), randomFixedReference(), randomFixedReference(), true, true);
    writeReadRecord(source, target);
    assertFalse("Record should use variable length format.", target.isUseFixedReferences());
    verifySameReferences(source, target);
}
Also used : RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) Test(org.junit.Test)

Example 43 with RelationshipRecord

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

the class PhysicalLogCommandReaderV3_0Test method readRelationshipCommandWithSecondaryUnit.

@Test
public void readRelationshipCommandWithSecondaryUnit() throws IOException {
    InMemoryClosableChannel channel = new InMemoryClosableChannel();
    RelationshipRecord before = new RelationshipRecord(42, true, 1, 2, 3, 4, 5, 6, 7, true, true);
    before.setRequiresSecondaryUnit(true);
    before.setSecondaryUnitId(47);
    RelationshipRecord after = new RelationshipRecord(42, true, 1, 8, 3, 4, 5, 6, 7, true, true);
    new Command.RelationshipCommand(before, after).serialize(channel);
    PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0();
    Command command = reader.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.Test)

Example 44 with RelationshipRecord

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

the class NeoStoreTransactionApplierTest method shouldApplyRelationshipCommandToTheStoreAndInvalidateTheCache.

@Test
public void shouldApplyRelationshipCommandToTheStoreAndInvalidateTheCache() throws Exception {
    // given
    final BatchTransactionApplier applier = newApplier(false);
    final RelationshipRecord before = new RelationshipRecord(12);
    final RelationshipRecord record = new RelationshipRecord(12, 3, 4, 5);
    record.setInUse(false);
    final Command command = new Command.RelationshipCommand(before, record);
    // when
    boolean result = apply(applier, command::handle, transactionToApply);
    // then
    assertFalse(result);
    verify(relationshipStore, times(1)).updateRecord(record);
}
Also used : 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) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) BatchTransactionApplier(org.neo4j.kernel.impl.api.BatchTransactionApplier) Test(org.junit.Test)

Example 45 with RelationshipRecord

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

the class BatchInserterImpl method setRelationshipProperties.

@Override
public void setRelationshipProperties(long rel, Map<String, Object> properties) {
    RelationshipRecord record = recordAccess.getRelRecords().getOrLoad(rel, null).forChangingData();
    if (record.getNextProp() != Record.NO_NEXT_PROPERTY.intValue()) {
        propertyDeletor.deletePropertyChain(record, recordAccess.getPropertyRecords());
    }
    record.setNextProp(propertyCreator.createPropertyChain(record, propertiesIterator(properties), recordAccess.getPropertyRecords()));
    flushStrategy.flush();
}
Also used : RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord)

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