Example #1
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;
                    }
                }
            }
        }
Example #2
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();
             }
         }
     }
 }
Example #3
0
        public override void Process(NodeRecord nodeRecord)
        {
            _reporter.forNode(nodeRecord, _nodeIndexCheck);
            Org.Neo4j.Consistency.checking.cache.CacheAccess_Client client = _cacheAccess.client();
            using (MandatoryProperties.Check <NodeRecord, ConsistencyReport_NodeConsistencyReport> mandatoryCheck = _mandatoryProperties.apply(nodeRecord))
            {
                IEnumerable <PropertyRecord> properties = client.PropertiesFromCache;

                // We do this null-check here because even if nodeIndexCheck should provide the properties for us,
                // or an empty list at least, it may fail in one way or another and exception be caught by
                // broad exception handler in reporter. The caught exception will produce an ERROR so it will not
                // go by unnoticed.
                if (properties != null)
                {
                    foreach (PropertyRecord property in properties)
                    {
                        _reporter.forProperty(property, _propertyCheck);
                        mandatoryCheck.Receive(ChainCheck.keys(property));
                    }
                }
            }
        }