Search in sources :

Example 1 with NodeRecord

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

the class StoreProcessorTaskTest method singlePassShouldOnlyProcessTheStoreOnce.

@Test
public void singlePassShouldOnlyProcessTheStoreOnce() throws Exception {
    // given
    StoreProcessor singlePassProcessor = mock(StoreProcessor.class);
    when(singlePassProcessor.getStage()).thenReturn(Stage.SEQUENTIAL_FORWARD);
    NodeStore store = mock(NodeStore.class);
    when(store.getStorageFileName()).thenReturn(new File("node-store"));
    StoreProcessorTask<NodeRecord> task = new StoreProcessorTask<>("nodes", Statistics.NONE, 1, store, null, "nodes", ProgressMonitorFactory.NONE.multipleParts("check"), CacheAccess.EMPTY, singlePassProcessor, QueueDistribution.ROUND_ROBIN);
    // when
    task.run();
    // then
    verify(singlePassProcessor).applyFiltered(same(store), any(ProgressListener.class));
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) NodeStore(org.neo4j.kernel.impl.store.NodeStore) ProgressListener(org.neo4j.helpers.progress.ProgressListener) File(java.io.File) Test(org.junit.Test)

Example 2 with NodeRecord

use of org.neo4j.kernel.impl.store.record.NodeRecord 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 3 with NodeRecord

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

the class FullCheckIntegrationTest method shouldReportOrphanedNodeDynamicLabelAsNodeInconsistency.

@Test
public void shouldReportOrphanedNodeDynamicLabelAsNodeInconsistency() throws Exception {
    // given
    fixture.apply(new GraphStoreFixture.Transaction() {

        @Override
        protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
            tx.nodeLabel(42, "Label");
            NodeRecord nodeRecord = new NodeRecord(next.node(), false, -1, -1);
            DynamicRecord record = inUse(new DynamicRecord(next.nodeLabel()));
            Collection<DynamicRecord> newRecords = new ArrayList<>();
            allocateFromNumbers(newRecords, prependNodeId(next.node(), new long[] { 42L }), new ReusableRecordsAllocator(60, record));
            nodeRecord.setLabelField(dynamicPointer(newRecords), newRecords);
            tx.create(nodeRecord);
        }
    });
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    on(stats).verify(RecordType.NODE_DYNAMIC_LABEL, 1).andThatsAllFolks();
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) TransactionDataBuilder(org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder) IdGenerator(org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator) Collection(java.util.Collection) GraphStoreFixture(org.neo4j.consistency.checking.GraphStoreFixture) ReusableRecordsAllocator(org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) Test(org.junit.Test)

Example 4 with NodeRecord

use of org.neo4j.kernel.impl.store.record.NodeRecord 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)

Example 5 with NodeRecord

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

the class NodeInUseWithCorrectLabelsCheckTest method shouldReportNodeNotInUse.

@Test
public void shouldReportNodeNotInUse() throws Exception {
    // given
    int nodeId = 42;
    ConsistencyReport.LabelScanConsistencyReport report = mock(ConsistencyReport.LabelScanConsistencyReport.class);
    NodeRecord node = notInUse(new NodeRecord(nodeId, false, 0, 0));
    // when
    checker(new long[] {}, true).checkReference(null, node, engineFor(report), null);
    // then
    verify(report).nodeNotInUse(node);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Aggregations

NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)391 Test (org.junit.Test)154 Test (org.junit.jupiter.api.Test)108 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)73 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)63 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)58 NodeLabels (org.neo4j.kernel.impl.store.NodeLabels)46 RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)42 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)40 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)40 DynamicNodeLabels (org.neo4j.kernel.impl.store.DynamicNodeLabels)38 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)32 ArrayList (java.util.ArrayList)30 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)30 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)30 TransactionDataBuilder (org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder)30 RelationshipTypeTokenRecord (org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord)30 NodeStore (org.neo4j.kernel.impl.store.NodeStore)28 Command (org.neo4j.kernel.impl.transaction.command.Command)27 PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)17