Search in sources :

Example 1 with CheckerEngine

use of org.neo4j.consistency.checking.CheckerEngine in project neo4j by neo4j.

the class OwnerCheck method decoratePropertyChecker.

@Override
public RecordCheck<PropertyRecord, ConsistencyReport.PropertyConsistencyReport> decoratePropertyChecker(final RecordCheck<PropertyRecord, ConsistencyReport.PropertyConsistencyReport> checker) {
    if (owners == null && dynamics == null) {
        return checker;
    }
    return new RecordCheck<PropertyRecord, ConsistencyReport.PropertyConsistencyReport>() {

        @Override
        public void check(PropertyRecord record, CheckerEngine<PropertyRecord, ConsistencyReport.PropertyConsistencyReport> engine, RecordAccess records) {
            if (record.inUse()) {
                if (owners != null && Record.NO_PREVIOUS_PROPERTY.is(record.getPrevProp())) {
                    // this record is first in a chain
                    PropertyOwner.UnknownOwner owner = new PropertyOwner.UnknownOwner();
                    engine.comparativeCheck(owner, ORPHAN_CHECKER);
                    if (null == owners.putIfAbsent(record.getId(), owner)) {
                        owner.markInCustody();
                    }
                }
                if (dynamics != null) {
                    for (PropertyBlock block : record) {
                        RecordType type = recordType(block.forceGetType());
                        if (type != null) {
                            ConcurrentMap<Long, DynamicOwner> dynamicOwners = dynamics.get(type);
                            if (dynamicOwners != null) {
                                long id = block.getSingleValueLong();
                                DynamicOwner.Property owner = new DynamicOwner.Property(type, record);
                                DynamicOwner prev = dynamicOwners.put(id, owner);
                                if (prev != null) {
                                    engine.comparativeCheck(prev.record(records), owner);
                                }
                            }
                        }
                    }
                }
            }
            checker.check(record, engine, records);
        }
    };
}
Also used : RecordAccess(org.neo4j.consistency.store.RecordAccess) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) RelationshipGroupConsistencyReport(org.neo4j.consistency.report.ConsistencyReport.RelationshipGroupConsistencyReport) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) RecordType(org.neo4j.consistency.RecordType) OwningRecordCheck(org.neo4j.consistency.checking.OwningRecordCheck) RecordCheck(org.neo4j.consistency.checking.RecordCheck) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) CheckerEngine(org.neo4j.consistency.checking.CheckerEngine)

Example 2 with CheckerEngine

use of org.neo4j.consistency.checking.CheckerEngine in project neo4j by neo4j.

the class NodeLabelReader method getListOfLabels.

public static <RECORD extends AbstractBaseRecord, REPORT extends ConsistencyReport> Set<Long> getListOfLabels(NodeRecord nodeRecord, RecordAccess records, CheckerEngine<RECORD, REPORT> engine) {
    final Set<Long> labels = new HashSet<>();
    NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(nodeRecord);
    if (nodeLabels instanceof DynamicNodeLabels) {
        DynamicNodeLabels dynamicNodeLabels = (DynamicNodeLabels) nodeLabels;
        long firstRecordId = dynamicNodeLabels.getFirstDynamicRecordId();
        RecordReference<DynamicRecord> firstRecordReference = records.nodeLabels(firstRecordId);
        engine.comparativeCheck(firstRecordReference, new LabelChainWalker<>(new LabelChainWalker.Validator<RECORD, REPORT>() {

            @Override
            public void onRecordNotInUse(DynamicRecord dynamicRecord, CheckerEngine<RECORD, REPORT> engine) {
            }

            @Override
            public void onRecordChainCycle(DynamicRecord record, CheckerEngine<RECORD, REPORT> engine) {
            }

            @Override
            public void onWellFormedChain(long[] labelIds, CheckerEngine<RECORD, REPORT> engine, RecordAccess records) {
                copyToSet(labelIds, labels);
            }
        }));
    } else {
        copyToSet(nodeLabels.get(null), labels);
    }
    return labels;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) RecordAccess(org.neo4j.consistency.store.RecordAccess) DynamicNodeLabels(org.neo4j.kernel.impl.store.DynamicNodeLabels) CheckerEngine(org.neo4j.consistency.checking.CheckerEngine) DynamicNodeLabels(org.neo4j.kernel.impl.store.DynamicNodeLabels) InlineNodeLabels(org.neo4j.kernel.impl.store.InlineNodeLabels) NodeLabels(org.neo4j.kernel.impl.store.NodeLabels) HashSet(java.util.HashSet)

Aggregations

CheckerEngine (org.neo4j.consistency.checking.CheckerEngine)2 RecordAccess (org.neo4j.consistency.store.RecordAccess)2 HashSet (java.util.HashSet)1 RecordType (org.neo4j.consistency.RecordType)1 OwningRecordCheck (org.neo4j.consistency.checking.OwningRecordCheck)1 RecordCheck (org.neo4j.consistency.checking.RecordCheck)1 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)1 RelationshipGroupConsistencyReport (org.neo4j.consistency.report.ConsistencyReport.RelationshipGroupConsistencyReport)1 DynamicNodeLabels (org.neo4j.kernel.impl.store.DynamicNodeLabels)1 InlineNodeLabels (org.neo4j.kernel.impl.store.InlineNodeLabels)1 NodeLabels (org.neo4j.kernel.impl.store.NodeLabels)1 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)1 PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)1 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)1