Beispiel #1
0
 public override void Check(DynamicRecord record, CheckerEngine <DynamicRecord, Org.Neo4j.Consistency.report.ConsistencyReport_DynamicConsistencyReport> engine, RecordAccess records)
 {
     if (!record.InUse())
     {
         return;
     }
     if (record.Length == 0)
     {
         engine.Report().emptyBlock();
     }
     else if (record.Length < 0)
     {
         engine.Report().invalidLength();
     }
     if (!Record.NO_NEXT_BLOCK.@is(record.NextBlock))
     {
         if (record.NextBlock == record.Id)
         {
             engine.Report().selfReferentialNext();
         }
         else
         {
             engine.ComparativeCheck(_dereference.lookup(records, record.NextBlock), this);
         }
         if (record.Length < _blockSize)
         {
             engine.Report().recordNotFullReferencesNext();
         }
     }
 }
Beispiel #2
0
        public override void Check(DynamicRecord record, CheckerEngine <DynamicRecord, Org.Neo4j.Consistency.report.ConsistencyReport_SchemaConsistencyReport> engine, RecordAccess records)
        {
            if (record.InUse() && record.StartRecord)
            {
                // parse schema rule
                SchemaRule rule;
                try
                {
                    rule = RuleAccess.loadSingleSchemaRule(record.Id);
                }
                catch (MalformedSchemaRuleException)
                {
                    engine.Report().malformedSchemaRule();
                    return;
                }

                if (rule is StoreIndexDescriptor)
                {
                    _strategy.checkIndexRule(( StoreIndexDescriptor )rule, record, records, engine);
                }
                else if (rule is ConstraintRule)
                {
                    _strategy.checkConstraintRule(( ConstraintRule )rule, record, records, engine);
                }
                else
                {
                    engine.Report().unsupportedSchemaRuleKind(null);
                }
            }
        }
Beispiel #3
0
 public override void CheckReference(RECORD record, NodeRecord nodeRecord, CheckerEngine <RECORD, REPORT> engine, RecordAccess records)
 {
     if (nodeRecord.InUse())
     {
         NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(nodeRecord);
         if (nodeLabels is DynamicNodeLabels)
         {
             DynamicNodeLabels dynamicNodeLabels = ( DynamicNodeLabels )nodeLabels;
             long firstRecordId = dynamicNodeLabels.FirstDynamicRecordId;
             RecordReference <DynamicRecord>   firstRecordReference      = records.NodeLabels(firstRecordId);
             ExpectedNodeLabelsChecker         expectedNodeLabelsChecker = new ExpectedNodeLabelsChecker(this, nodeRecord);
             LabelChainWalker <RECORD, REPORT> checker = new LabelChainWalker <RECORD, REPORT>(expectedNodeLabelsChecker);
             engine.ComparativeCheck(firstRecordReference, checker);
             nodeRecord.DynamicLabelRecords;                              // I think this is empty in production
         }
         else
         {
             long[] storeLabels = nodeLabels.Get(null);
             REPORT report      = engine.Report();
             ValidateLabelIds(nodeRecord, storeLabels, report);
         }
     }
     else if (_indexLabels.Length != 0)
     {
         engine.Report().nodeNotInUse(nodeRecord);
     }
 }
        private void CheckProperty(NodeRecord record, CheckerEngine <NodeRecord, Org.Neo4j.Consistency.report.ConsistencyReport_NodeConsistencyReport> engine, ICollection <PropertyRecord> props)
        {
            if (!Record.NO_NEXT_PROPERTY.@is(record.NextProp))
            {
                PropertyRecord firstProp = props.GetEnumerator().next();
                if (!Record.NO_PREVIOUS_PROPERTY.@is(firstProp.PrevProp))
                {
                    engine.Report().propertyNotFirstInChain(firstProp);
                }

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.set.primitive.MutableIntSet keys = new org.eclipse.collections.impl.set.mutable.primitive.IntHashSet();
                MutableIntSet keys = new IntHashSet();
                foreach (PropertyRecord property in props)
                {
                    if (!property.InUse())
                    {
                        engine.Report().propertyNotInUse(property);
                    }
                    else
                    {
                        foreach (int key in ChainCheck.keys(property))
                        {
                            if (!keys.add(key))
                            {
                                engine.Report().propertyKeyNotUniqueInChain();
                            }
                        }
                    }
                }
            }
        }
Beispiel #5
0
        public override void Check(RelationshipRecord record, CheckerEngine <RelationshipRecord, Org.Neo4j.Consistency.report.ConsistencyReport_RelationshipConsistencyReport> engine, RecordAccess records)
        {
            try
            {
                IntObjectMap <PropertyBlock> propertyMap = null;
                foreach (StoreIndexDescriptor index in _relationshipIndexes)
                {
                    SchemaDescriptor schema = index.Schema();
                    if (ArrayUtils.contains(Schema.EntityTokenIds, record.Type))
                    {
                        if (propertyMap == null)
                        {
                            ICollection <PropertyRecord> propertyRecs = _propertyReader.getPropertyRecordChain(record.NextProp);
                            propertyMap = properties(_propertyReader.propertyBlocks(propertyRecs));
                        }

                        if (entityIntersectsSchema(propertyMap, schema))
                        {
                            Value[] values = getPropertyValues(_propertyReader, propertyMap, Schema.PropertyIds);
                            using (IndexReader reader = _indexes.accessorFor(index).newReader())
                            {
                                long entityId = record.Id;
                                long count    = reader.CountIndexedNodes(entityId, Schema.PropertyIds, values);
                                ReportIncorrectIndexCount(values, engine, index, count);
                            }
                        }
                    }
                }
            }
            catch (PropertyReader.CircularPropertyRecordChainException)
            {
                // The property chain contains a circular reference and is therefore not sane.
                // Skip it, since this inconsistency has been reported by PropertyChain checker already.
            }
        }
Beispiel #6
0
 public void checkConsistency(NodeRecord node, CheckerEngine <NodeRecord, ConsistencyReport_NodeConsistencyReport> engine, RecordAccess records)
 {
     if (!Record.NO_NEXT_RELATIONSHIP.@is(node.NextRel))
     {
         engine.comparativeCheck(records.relationshipGroup(node.NextRel), this);
     }
 }
Beispiel #7
0
        internal static void DispatchChangeReference(CheckerEngine engine, ComparativeRecordChecker checker, AbstractBaseRecord oldReferenced, AbstractBaseRecord newReferenced, RecordAccess records)
        {
            ReportInvocationHandler handler = ( ReportInvocationHandler )engine;

            handler.checkDiffReference(engine, checker, oldReferenced, newReferenced, records);
            handler.updateSummary();
        }
Beispiel #8
0
        private void CheckForDuplicates(SchemaRule rule, DynamicRecord record, CheckerEngine <DynamicRecord, Org.Neo4j.Consistency.report.ConsistencyReport_SchemaConsistencyReport> engine)
        {
            DynamicRecord previousContentRecord = _verifiedRulesWithRecords[rule] = record.Clone();

            if (previousContentRecord != null)
            {
                engine.Report().duplicateRuleContent(previousContentRecord);
            }
        }
 private void ReportIncorrectIndexCount(Value[] propertyValues, CheckerEngine <NodeRecord, Org.Neo4j.Consistency.report.ConsistencyReport_NodeConsistencyReport> engine, StoreIndexDescriptor indexRule, long count)
 {
     if (count == 0)
     {
         engine.Report().notIndexed(indexRule, Values.asObjects(propertyValues));
     }
     else if (count != 1)
     {
         engine.Report().indexedMultipleTimes(indexRule, Values.asObjects(propertyValues), count);
     }
 }
Beispiel #10
0
            public override void check(CountsEntry record, CheckerEngine <CountsEntry, Org.Neo4j.Consistency.report.ConsistencyReport_CountsConsistencyReport> engine, RecordAccess records)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long expectedCount = relationshipCounts.get(record.getCountsKey());
                long expectedCount = outerInstance.relationshipCounts.get(record.CountsKey);

                if (expectedCount != record.Count)
                {
                    engine.Report().inconsistentRelationshipCount(expectedCount);
                }
            }
 public virtual void Skip()
 {
     lock (this)
     {
         if (_engine != null)
         {
             ConsistencyReporter.DispatchSkip(_engine);
             _engine = null;
         }
     }
 }
Beispiel #12
0
            public override void check(CountsEntry record, CheckerEngine <CountsEntry, Org.Neo4j.Consistency.report.ConsistencyReport_CountsConsistencyReport> engine, RecordAccess records)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int expectedCount = nodeCounts.size();
                int expectedCount = outerInstance.nodeCounts.size();

                if (record.Count != expectedCount)
                {
                    engine.Report().inconsistentNumberOfNodeKeys(expectedCount);
                }
            }
Beispiel #13
0
 public override void Check(RECORD record, CheckerEngine <RECORD, REPORT> engine, RecordAccess records)
 {
     if (!record.inUse())
     {
         return;
     }
     if (!Record.NO_NEXT_BLOCK.@is(record.NameId))
     {
         engine.ComparativeCheck(Name(records, record.NameId), this);
     }
 }
Beispiel #14
0
 public override void Check(RelationshipGroupRecord record, CheckerEngine <RelationshipGroupRecord, ConsistencyReport_RelationshipGroupConsistencyReport> engine, RecordAccess records)
 {
     if (!record.InUse())
     {
         return;
     }
     foreach (RecordField <RelationshipGroupRecord, ConsistencyReport_RelationshipGroupConsistencyReport> field in _fields)
     {
         field.CheckConsistency(record, engine, records);
     }
 }
Beispiel #15
0
 public override void Check(RECORD record, CheckerEngine <RECORD, REPORT> engine, RecordAccess records)
 {
     if (!record.inUse())
     {
         return;
     }
     foreach (RecordField <RECORD, REPORT> field in _fields)
     {
         field.CheckConsistency(record, engine, records);
     }
 }
Beispiel #16
0
 private void ReportIncorrectIndexCount(Value[] values, CheckerEngine <RelationshipRecord, Org.Neo4j.Consistency.report.ConsistencyReport_RelationshipConsistencyReport> engine, StoreIndexDescriptor index, long count)
 {
     if (count == 0)
     {
         engine.Report().notIndexed(index, Values.asObjects(values));
     }
     else if (count != 1)
     {
         engine.Report().indexedMultipleTimes(index, Values.asObjects(values), count);
     }
 }
Beispiel #17
0
        public override void Check(LabelScanDocument record, CheckerEngine <LabelScanDocument, Org.Neo4j.Consistency.report.ConsistencyReport_LabelScanConsistencyReport> engine, RecordAccess records)
        {
            NodeLabelRange range = record.NodeLabelRange;

            foreach (long nodeId in range.Nodes())
            {
                long[] labels = record.NodeLabelRange.labels(nodeId);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: engine.comparativeCheck(records.node(nodeId), new org.neo4j.consistency.checking.full.NodeInUseWithCorrectLabelsCheck<>(labels, COMPLETE_ALL_TOKENS, true));
                engine.ComparativeCheck(records.Node(nodeId), new NodeInUseWithCorrectLabelsCheck <RECORD, ?, REPORT>(labels, COMPLETE_ALL_TOKENS, true));
            }
        }
Beispiel #18
0
 public override void CheckReference(RECORD record, PropertyRecord property, CheckerEngine <RECORD, REPORT> engine, RecordAccess records)
 {
     foreach (int key in Keys(property))
     {
         if (!_keys.add(key))
         {
             engine.Report().propertyKeyNotUniqueInChain();
         }
     }
     if (!Record.NO_NEXT_PROPERTY.@is(property.NextProp))
     {
         engine.ComparativeCheck(records.Property(property.NextProp), this);
     }
 }
Beispiel #19
0
 public override void CheckReference(RECORD record, DynamicRecord name, CheckerEngine <RECORD, REPORT> engine, RecordAccess records)
 {
     if (!name.InUse())
     {
         NameNotInUse(engine.Report(), name);
     }
     else
     {
         if (name.Length <= 0)
         {
             EmptyName(engine.Report(), name);
         }
     }
 }
Beispiel #20
0
 public override void Check(PropertyRecord record, CheckerEngine <PropertyRecord, Org.Neo4j.Consistency.report.ConsistencyReport_PropertyConsistencyReport> engine, RecordAccess records)
 {
     if (!record.InUse())
     {
         return;
     }
     foreach (PropertyField field in PropertyField.values())
     {
         field.checkConsistency(record, engine, records);
     }
     foreach (PropertyBlock block in record)
     {
         CheckDataBlock(block, engine, records);
     }
 }
Beispiel #21
0
 public override void CheckReference(RECORD record, PropertyRecord property, CheckerEngine <RECORD, REPORT> engine, RecordAccess records)
 {
     if (!property.InUse())
     {
         engine.Report().propertyNotInUse(property);
     }
     else
     {
         if (!Record.NO_PREVIOUS_PROPERTY.@is(property.PrevProp))
         {
             engine.Report().propertyNotFirstInChain(property);
         }
         (new ChainCheck <RECORD, REPORT>()).CheckReference(record, property, engine, records);
     }
 }
 public override void Check(NodeRecord record, CheckerEngine <NodeRecord, Org.Neo4j.Consistency.report.ConsistencyReport_NodeConsistencyReport> engine, RecordAccess records)
 {
     try
     {
         ICollection <PropertyRecord> properties = _propertyReader.getPropertyRecordChain(record.NextProp);
         _cacheAccess.client().putPropertiesToCache(properties);
         if (_indexes != null)
         {
             MatchIndexesToNode(record, engine, records, properties);
         }
         CheckProperty(record, engine, properties);
     }
     catch (PropertyReader.CircularPropertyRecordChainException e)
     {
         engine.Report().propertyChainContainsCircularReference(e.PropertyRecordClosingTheCircle());
     }
 }
		 public override void Check( DynamicRecord record, CheckerEngine<DynamicRecord, ConsistencyReport_DynamicLabelConsistencyReport> engine, RecordAccess records )
		 {
			  if ( record.InUse() && record.StartRecord )
			  {
					long? ownerId = readOwnerFromDynamicLabelsRecord( record );
					if ( null == ownerId )
					{
						 // no owner but in use indicates a broken record
						 engine.Report().orphanDynamicLabelRecord();
					}
					else
					{
						 // look at owning node record to verify consistency
						 engine.ComparativeCheck( records.Node( ownerId.Value ), _validNodeRecord );
					}
			  }
		 }
 private CheckerEngine Engine()
 {
     lock (this)
     {
         if (_engine == null)
         {
             throw new System.InvalidOperationException("Reference has already been checked.");
         }
         try
         {
             return(_engine);
         }
         finally
         {
             _engine = null;
         }
     }
 }
Beispiel #25
0
        public override void CheckConsistency(RECORD record, CheckerEngine <RECORD, REPORT> engine, RecordAccess records)
        {
            if (!Record.NO_NEXT_PROPERTY.@is(record.NextProp))
            {
                // Check the whole chain here instead of scattered during multiple checks.
                // This type of check obviously favors chains with good locality, performance-wise.
                IEnumerator <PropertyRecord> props = records.RawPropertyChain(record.NextProp);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                PropertyRecord firstProp = props.next();
                if (!Record.NO_PREVIOUS_PROPERTY.@is(firstProp.PrevProp))
                {
                    engine.Report().propertyNotFirstInChain(firstProp);
                }

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.set.primitive.MutableIntSet keys = new org.eclipse.collections.impl.set.mutable.primitive.IntHashSet();
                MutableIntSet keys = new IntHashSet();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.set.primitive.MutableLongSet propertyRecordIds = new org.eclipse.collections.impl.set.mutable.primitive.LongHashSet(8);
                MutableLongSet propertyRecordIds = new LongHashSet(8);
                propertyRecordIds.add(firstProp.Id);
                using (MandatoryProperties.Check <RECORD, REPORT> mandatory = _mandatoryProperties.apply(record))
                {
                    CheckChainItem(firstProp, engine, keys, mandatory);

                    // Check the whole chain here. We also take the opportunity to check mandatory property constraints.
                    PropertyRecord prop = firstProp;
                    while (props.MoveNext())
                    {
                        PropertyRecord nextProp = props.Current;
                        if (!propertyRecordIds.add(nextProp.Id))
                        {
                            engine.Report().propertyChainContainsCircularReference(prop);
                            break;
                        }
                        CheckChainItem(nextProp, engine, keys, mandatory);
                        prop = nextProp;
                    }
                }
            }
        }
Beispiel #26
0
        public static void CheckDataBlock(PropertyBlock block, CheckerEngine <PropertyRecord, Org.Neo4j.Consistency.report.ConsistencyReport_PropertyConsistencyReport> engine, RecordAccess records)
        {
            if (block.KeyIndexId < 0)
            {
                engine.Report().invalidPropertyKey(block);
            }
            else
            {
                engine.ComparativeCheck(records.PropertyKey(block.KeyIndexId), PropertyKey(block));
            }
            PropertyType type = block.ForceGetType();

            if (type == null)
            {
                engine.Report().invalidPropertyType(block);
            }
            else
            {
                switch (type.innerEnumValue)
                {
                case PropertyType.InnerEnum.STRING:
                    engine.ComparativeCheck(records.String(block.SingleValueLong), DynamicReference.String(block));
                    break;

                case PropertyType.InnerEnum.ARRAY:
                    engine.ComparativeCheck(records.Array(block.SingleValueLong), DynamicReference.Array(block));
                    break;

                default:
                    try
                    {
                        type.value(block, null);
                    }
                    catch (Exception)
                    {
                        engine.Report().invalidPropertyValue(block);
                    }
                    break;
                }
            }
        }
Beispiel #27
0
 private void CheckChainItem(PropertyRecord property, CheckerEngine <RECORD, REPORT> engine, MutableIntSet keys, MandatoryProperties.Check <RECORD, REPORT> mandatory)
 {
     if (!property.InUse())
     {
         engine.Report().propertyNotInUse(property);
     }
     else
     {
         int[] keysInRecord = ChainCheck.Keys(property);
         if (mandatory != null)
         {
             mandatory.Receive(keysInRecord);
         }
         foreach (int key in keysInRecord)
         {
             if (!keys.add(key))
             {
                 engine.Report().propertyKeyNotUniqueInChain();
             }
         }
     }
 }
Beispiel #28
0
        public override void Check(IndexEntry record, CheckerEngine <IndexEntry, Org.Neo4j.Consistency.report.ConsistencyReport_IndexConsistencyReport> engine, RecordAccess records)
        {
            long id = record.Id;

            switch (_entityType.innerEnumValue)
            {
            case EntityType.InnerEnum.NODE:
                engine.ComparativeCheck(records.Node(id), _nodeChecker);
                break;

            case EntityType.InnerEnum.RELATIONSHIP:
                if (_indexRule.canSupportUniqueConstraint())
                {
                    engine.Report().relationshipConstraintIndex();
                }
                engine.ComparativeCheck(records.Relationship(id), _relationshipChecker);
                break;

            default:
                throw new System.InvalidOperationException("Don't know how to check index entry of entity type " + _entityType);
            }
        }
Beispiel #29
0
            public override void Check(NodeRecord record, CheckerEngine <NodeRecord, ConsistencyReport_NodeConsistencyReport> engine, RecordAccess records)
            {
                if (CountUpdateCondition.test(record))
                {
                    if (record.InUse())
                    {
                        Org.Neo4j.Consistency.checking.cache.CacheAccess_Client client = records.CacheAccess().client();
                        client.PutToCacheSingle(record.Id, SLOT_IN_USE, 1);
                        client.PutToCacheSingle(record.Id, SLOT_LABEL_FIELD, record.LabelField);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.Set<long> labels = labelsFor(nodeStore, engine, records, record.getId());
                        ISet <long> labels = LabelsFor(NodeStore, engine, records, record.Id);
                        lock ( Counts )
                        {
                            Counts.addToValue(nodeKey(WILDCARD), 1);
                            foreach (long label in labels)
                            {
                                Counts.addToValue(nodeKey(( int )label), 1);
                            }
                        }
                    }
                }
                Inner.check(record, engine, records);
            }
        /// <summary>
        /// Matches indexes to a node.
        /// </summary>
        private void MatchIndexesToNode(NodeRecord record, CheckerEngine <NodeRecord, Org.Neo4j.Consistency.report.ConsistencyReport_NodeConsistencyReport> engine, RecordAccess records, ICollection <PropertyRecord> propertyRecs)
        {
            long[] labels = NodeLabelReader.GetListOfLabels(record, records, engine).Select(long?.longValue).ToArray();
            IntObjectMap <PropertyBlock> nodePropertyMap = null;

            foreach (StoreIndexDescriptor indexRule in _indexes.onlineRules())
            {
                SchemaDescriptor schema = indexRule.Schema();
                if (Schema.entityType() == EntityType.NODE && Schema.isAffected(labels))
                {
                    if (nodePropertyMap == null)
                    {
                        nodePropertyMap = Properties(_propertyReader.propertyBlocks(propertyRecs));
                    }

                    if (EntityIntersectsSchema(nodePropertyMap, schema))
                    {
                        Value[] values = GetPropertyValues(_propertyReader, nodePropertyMap, Schema.PropertyIds);
                        using (IndexReader reader = _indexes.accessorFor(indexRule).newReader())
                        {
                            long nodeId = record.Id;

                            if (indexRule.CanSupportUniqueConstraint())
                            {
                                VerifyNodeCorrectlyIndexedUniquely(nodeId, values, engine, indexRule, reader);
                            }
                            else
                            {
                                long count = reader.CountIndexedNodes(nodeId, Schema.PropertyIds, values);
                                ReportIncorrectIndexCount(values, engine, indexRule, count);
                            }
                        }
                    }
                }
            }
        }