Search in sources :

Example 1 with ReusableRecordsAllocator

use of org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator in project neo4j by neo4j.

the class FullCheckIntegrationTest method serializeRule.

public static Collection<DynamicRecord> serializeRule(SchemaRule rule, Collection<DynamicRecord> records) {
    byte[] data = rule.serialize();
    ReusableRecordsAllocator dynamicRecordAllocator = new ReusableRecordsAllocator(data.length, records);
    Collection<DynamicRecord> result = new ArrayList<>();
    AbstractDynamicStore.allocateRecordsFromBytes(result, data, dynamicRecordAllocator);
    return result;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) ArrayList(java.util.ArrayList) ReusableRecordsAllocator(org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator)

Example 2 with ReusableRecordsAllocator

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

use of org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator in project neo4j by neo4j.

the class NodeDynamicLabelOrphanChainStartCheckTest method shouldReportMissingOwnerId.

@Test
public void shouldReportMissingOwnerId() throws Exception {
    // given
    DynamicRecord record = new DynamicRecord(0);
    inUse(record);
    allocateFromNumbers(new ArrayList<>(), new long[] {}, new ReusableRecordsAllocator(66, record));
    // when
    DynamicLabelConsistencyReport report = check(record);
    // then
    verify(report).orphanDynamicLabelRecord();
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) ReusableRecordsAllocator(org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator) DynamicLabelConsistencyReport(org.neo4j.consistency.report.ConsistencyReport.DynamicLabelConsistencyReport) Test(org.junit.Test)

Example 4 with ReusableRecordsAllocator

use of org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator in project neo4j by neo4j.

the class NodeDynamicLabelOrphanChainStartCheckTest method shouldReportOwningNodeRecordNotInUse.

@Test
public void shouldReportOwningNodeRecordNotInUse() throws Exception {
    // given
    NodeRecord nodeRecord = notInUse(new NodeRecord(12L, false, -1, -1));
    add(nodeRecord);
    DynamicRecord nodeDynamicLabelRecord = inUse(new DynamicRecord(0));
    allocateFromNumbers(new ArrayList<>(), new long[] { 12L }, new ReusableRecordsAllocator(66, nodeDynamicLabelRecord));
    // when
    DynamicLabelConsistencyReport report = check(nodeDynamicLabelRecord);
    // then
    verify(report).orphanDynamicLabelRecordDueToInvalidOwner(nodeRecord);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) ReusableRecordsAllocator(org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator) DynamicLabelConsistencyReport(org.neo4j.consistency.report.ConsistencyReport.DynamicLabelConsistencyReport) Test(org.junit.Test)

Example 5 with ReusableRecordsAllocator

use of org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator in project neo4j by neo4j.

the class NodeRecordCheckTest method shouldReportDuplicateDynamicLabels.

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

Aggregations

ReusableRecordsAllocator (org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator)16 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)16 Test (org.junit.Test)13 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)10 ArrayList (java.util.ArrayList)4 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)4 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)4 TransactionDataBuilder (org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder)4 Collection (java.util.Collection)3 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)3 DynamicLabelConsistencyReport (org.neo4j.consistency.report.ConsistencyReport.DynamicLabelConsistencyReport)3 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)3 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Applier (org.neo4j.consistency.checking.GraphStoreFixture.Applier)1 IdSequence (org.neo4j.kernel.impl.store.id.IdSequence)1 LabelTokenRecord (org.neo4j.kernel.impl.store.record.LabelTokenRecord)1