Search in sources :

Example 1 with RelationshipRecord

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

the class RecordDistributorTest method shouldDistributeRelationshipRecordsByNodeId.

@Test
public void shouldDistributeRelationshipRecordsByNodeId() throws Exception {
    // GIVEN
    QueueDistributor<RelationshipRecord> distributor = new RelationshipNodesQueueDistributor(5, 100);
    RecordConsumer<RelationshipRecord> consumer = mock(RecordConsumer.class);
    // WHEN/THEN
    RelationshipRecord relationship = relationship(0, 0, 1);
    distributor.distribute(relationship, consumer);
    verify(consumer, times(1)).accept(relationship, 0);
    relationship = relationship(1, 0, 7);
    distributor.distribute(relationship, consumer);
    verify(consumer, times(1)).accept(relationship, 0);
    verify(consumer, times(1)).accept(relationship, 1);
    relationship = relationship(3, 26, 11);
    distributor.distribute(relationship, consumer);
    verify(consumer, times(1)).accept(relationship, 5);
    verify(consumer, times(1)).accept(relationship, 2);
}
Also used : RelationshipNodesQueueDistributor(org.neo4j.consistency.checking.full.QueueDistribution.RelationshipNodesQueueDistributor) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) Test(org.junit.Test)

Example 2 with RelationshipRecord

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

the class RecordDistributorTest method relationship.

private RelationshipRecord relationship(long id, long startNodeId, long endNodeId) {
    RelationshipRecord record = new RelationshipRecord(id);
    record.setInUse(true);
    record.setFirstNode(startNodeId);
    record.setSecondNode(endNodeId);
    return record;
}
Also used : RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord)

Example 3 with RelationshipRecord

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

the class OwningNodeRelationshipChainTest method shouldFindBothChainsThatTheRelationshipRecordShouldBelongTo.

@Test
public void shouldFindBothChainsThatTheRelationshipRecordShouldBelongTo() throws Exception {
    // given
    long node1 = 101, node1Rel = 1001;
    long node2 = 201, node2Rel = 2001;
    long sharedRel = 1000;
    int relType = 0;
    RecordSet<RelationshipRecord> node1RelChain = RecordSet.asSet(new RelationshipRecord(node1Rel, node1, node1 - 1, relType), new RelationshipRecord(sharedRel, node1, node2, relType), new RelationshipRecord(node1Rel + 1, node1 + 1, node1, relType));
    RecordSet<RelationshipRecord> node2RelChain = RecordSet.asSet(new RelationshipRecord(node2Rel, node2 - 1, node2, relType), new RelationshipRecord(sharedRel, node1, node2, relType), new RelationshipRecord(node2Rel + 1, node2, node2 + 1, relType));
    @SuppressWarnings("unchecked") RecordStore<NodeRecord> recordStore = mock(RecordStore.class);
    when(recordStore.getRecord(eq(node1), any(NodeRecord.class), any(RecordLoad.class))).thenAnswer(new ReadNodeAnswer(false, node1Rel, NO_NEXT_PROPERTY.intValue()));
    when(recordStore.getRecord(eq(node2), any(NodeRecord.class), any(RecordLoad.class))).thenAnswer(new ReadNodeAnswer(false, node2Rel, NO_NEXT_PROPERTY.intValue()));
    when(recordStore.newRecord()).thenReturn(new NodeRecord(-1));
    RelationshipChainExplorer relationshipChainExplorer = mock(RelationshipChainExplorer.class);
    when(relationshipChainExplorer.followChainFromNode(node1, node1Rel)).thenReturn(node1RelChain);
    when(relationshipChainExplorer.followChainFromNode(node2, node2Rel)).thenReturn(node2RelChain);
    OwningNodeRelationshipChain owningChainFinder = new OwningNodeRelationshipChain(relationshipChainExplorer, recordStore);
    // when
    RecordSet<RelationshipRecord> recordsInChains = owningChainFinder.findRelationshipChainsThatThisRecordShouldBelongTo(new RelationshipRecord(sharedRel, node1, node2, relType));
    // then
    assertThat(recordsInChains, containsAllRecords(node1RelChain));
    assertThat(recordsInChains, containsAllRecords(node2RelChain));
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) RecordLoad(org.neo4j.kernel.impl.store.record.RecordLoad) ReadNodeAnswer(org.neo4j.kernel.impl.store.RecordStoreUtil.ReadNodeAnswer) Test(org.junit.Test)

Example 4 with RelationshipRecord

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

the class OwnerCheckTest method shouldReportRelationshipWithReferenceToTheGraphGlobalChain.

@Test
public void shouldReportRelationshipWithReferenceToTheGraphGlobalChain() throws Exception {
    // given
    OwnerCheck decorator = new OwnerCheck(true);
    RecordCheck<RelationshipRecord, ConsistencyReport.RelationshipConsistencyReport> relationshipChecker = decorator.decorateRelationshipChecker(dummyRelationshipChecker());
    RecordCheck<NeoStoreRecord, ConsistencyReport.NeoStoreConsistencyReport> neoStoreCheck = decorator.decorateNeoStoreChecker(dummyNeoStoreCheck());
    RecordAccessStub records = new RecordAccessStub();
    NeoStoreRecord master = records.add(new NeoStoreRecord());
    master.setNextProp(7);
    RelationshipRecord relationship = records.add(inUse(new RelationshipRecord(1, 0, 1, 0)));
    relationship.setNextProp(7);
    // when
    ConsistencyReport.NeoStoreConsistencyReport masterReport = check(ConsistencyReport.NeoStoreConsistencyReport.class, neoStoreCheck, master, records);
    ConsistencyReport.RelationshipConsistencyReport relationshipReport = check(ConsistencyReport.RelationshipConsistencyReport.class, relationshipChecker, relationship, records);
    // then
    verifyZeroInteractions(masterReport);
    verify(relationshipReport).multipleOwners(master);
}
Also used : NeoStoreRecord(org.neo4j.kernel.impl.store.record.NeoStoreRecord) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) RecordAccessStub(org.neo4j.consistency.store.RecordAccessStub) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 5 with RelationshipRecord

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

the class OwnerCheckTest method shouldReportNodeWithSamePropertyChainAsRelationship.

@Test
public void shouldReportNodeWithSamePropertyChainAsRelationship() throws Exception {
    // given
    OwnerCheck decorator = new OwnerCheck(true);
    RecordCheck<NodeRecord, ConsistencyReport.NodeConsistencyReport> nodeChecker = decorator.decorateNodeChecker(dummyNodeCheck());
    RecordCheck<RelationshipRecord, ConsistencyReport.RelationshipConsistencyReport> relationshipChecker = decorator.decorateRelationshipChecker(dummyRelationshipChecker());
    RecordAccessStub records = new RecordAccessStub();
    NodeRecord node = records.add(inUse(new NodeRecord(1, false, NONE, 7)));
    RelationshipRecord relationship = records.add(inUse(new RelationshipRecord(1, 0, 1, 0)));
    relationship.setNextProp(node.getNextProp());
    // when
    ConsistencyReport.RelationshipConsistencyReport relationshipReport = check(ConsistencyReport.RelationshipConsistencyReport.class, relationshipChecker, relationship, records);
    ConsistencyReport.NodeConsistencyReport nodeReport = check(ConsistencyReport.NodeConsistencyReport.class, nodeChecker, node, records);
    // then
    verifyZeroInteractions(relationshipReport);
    verify(nodeReport).multipleOwners(relationship);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) RecordAccessStub(org.neo4j.consistency.store.RecordAccessStub) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

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