Search in sources :

Example 36 with NodeRecord

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

the class NodeRecordCheckTest method shouldNotReportAnythingForNodeWithConsistentReferences.

@Test
public void shouldNotReportAnythingForNodeWithConsistentReferences() throws Exception {
    // given
    NodeRecord node = inUse(new NodeRecord(42, false, 7, 11));
    add(inUse(new RelationshipRecord(7, 42, 0, 0)));
    add(inUse(new PropertyRecord(11)));
    // when
    ConsistencyReport.NodeConsistencyReport report = check(node);
    // then
    verifyNoMoreInteractions(report);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 37 with NodeRecord

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

the class NodeRecordCheckTest method shouldReportOutOfOrderLabels.

@Test
public void shouldReportOutOfOrderLabels() throws Exception {
    // given
    final NodeRecord node = inUse(new NodeRecord(42, false, NONE, NONE));
    // We need to do this override so we can put the labels unsorted, since InlineNodeLabels always sorts on insert
    new InlineNodeLabels(node) {

        @Override
        public Collection<DynamicRecord> put(long[] labelIds, NodeStore nodeStore, DynamicRecordAllocator allocator) {
            return putSorted(node, labelIds, nodeStore, allocator);
        }
    }.put(new long[] { 3, 1, 2 }, null, null);
    LabelTokenRecord label1 = inUse(new LabelTokenRecord(1));
    LabelTokenRecord label2 = inUse(new LabelTokenRecord(2));
    LabelTokenRecord label3 = inUse(new LabelTokenRecord(3));
    add(label1);
    add(label2);
    add(label3);
    add(node);
    // when
    ConsistencyReport.NodeConsistencyReport report = check(node);
    // then
    verify(report).labelsOutOfOrder(3, 1);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) InlineNodeLabels(org.neo4j.kernel.impl.store.InlineNodeLabels) DynamicRecordAllocator(org.neo4j.kernel.impl.store.DynamicRecordAllocator) NodeStore(org.neo4j.kernel.impl.store.NodeStore) Collection(java.util.Collection) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 38 with NodeRecord

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

the class NodeRecordCheckTest method shouldDynamicLabelRecordsNotInUse.

@Test
public void shouldDynamicLabelRecordsNotInUse() throws Exception {
    // given
    long[] labelIds = createLabels(100);
    NodeRecord node = inUse(new NodeRecord(42, false, NONE, NONE));
    add(node);
    DynamicRecord labelsRecord1 = notInUse(array(new DynamicRecord(1)));
    DynamicRecord labelsRecord2 = notInUse(array(new DynamicRecord(2)));
    Collection<DynamicRecord> labelRecords = asList(labelsRecord1, labelsRecord2);
    DynamicArrayStore.allocateFromNumbers(new ArrayList<>(), labelIds, new NotUsedReusableRecordsAllocator(52, labelRecords));
    assertDynamicRecordChain(labelsRecord1, labelsRecord2);
    node.setLabelField(DynamicNodeLabels.dynamicPointer(labelRecords), labelRecords);
    addNodeDynamicLabels(labelsRecord1);
    addNodeDynamicLabels(labelsRecord2);
    // when
    ConsistencyReport.NodeConsistencyReport report = check(node);
    // then
    verify(report).dynamicLabelRecordNotInUse(labelsRecord1);
    verify(report).dynamicLabelRecordNotInUse(labelsRecord2);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 39 with NodeRecord

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

the class NodeRecordCheckTest method shouldReportLoopRelationshipNotFirstInTargetAndSourceChains.

@Test
public void shouldReportLoopRelationshipNotFirstInTargetAndSourceChains() throws Exception {
    // given
    NodeRecord node = inUse(new NodeRecord(42, false, 7, NONE));
    RelationshipRecord relationship = add(inUse(new RelationshipRecord(7, 42, 42, 0)));
    relationship.setFirstPrevRel(8);
    relationship.setFirstInFirstChain(false);
    relationship.setSecondPrevRel(8);
    relationship.setFirstInSecondChain(false);
    // when
    ConsistencyReport.NodeConsistencyReport report = check(node);
    // then
    verify(report).relationshipNotFirstInSourceChain(relationship);
    verify(report).relationshipNotFirstInTargetChain(relationship);
    verifyNoMoreInteractions(report);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 40 with NodeRecord

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

the class NodeRecordCheckTest method shouldReportDuplicateLabels.

@Test
public void shouldReportDuplicateLabels() throws Exception {
    // given
    NodeRecord node = inUse(new NodeRecord(42, false, NONE, NONE));
    new InlineNodeLabels(node).put(new long[] { 1, 2, 1 }, null, null);
    LabelTokenRecord label1 = inUse(new LabelTokenRecord(1));
    LabelTokenRecord label2 = inUse(new LabelTokenRecord(2));
    add(label1);
    add(label2);
    add(node);
    // when
    ConsistencyReport.NodeConsistencyReport report = check(node);
    // then
    verify(report).labelDuplicate(1);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) InlineNodeLabels(org.neo4j.kernel.impl.store.InlineNodeLabels) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Aggregations

NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)257 Test (org.junit.Test)190 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)62 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)51 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)38 Command (org.neo4j.kernel.impl.transaction.command.Command)29 RelationshipTypeTokenRecord (org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord)28 RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)27 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)26 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)23 NodeLabels (org.neo4j.kernel.impl.store.NodeLabels)23 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)22 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)22 TransactionDataBuilder (org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder)22 ArrayList (java.util.ArrayList)19 DynamicNodeLabels (org.neo4j.kernel.impl.store.DynamicNodeLabels)19 File (java.io.File)15 RecordAccessStub (org.neo4j.consistency.store.RecordAccessStub)13 NodeStore (org.neo4j.kernel.impl.store.NodeStore)11 ReusableRecordsAllocator (org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator)10