/// <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);
                            }
                        }
                    }
                }
            }
        }
示例#2
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: public System.Func<org.neo4j.kernel.impl.store.record.NodeRecord,Check<org.neo4j.kernel.impl.store.record.NodeRecord,org.neo4j.consistency.report.ConsistencyReport_NodeConsistencyReport>> forNodes(final org.neo4j.consistency.report.ConsistencyReporter reporter)
        public virtual System.Func <NodeRecord, Check <NodeRecord, Org.Neo4j.Consistency.report.ConsistencyReport_NodeConsistencyReport> > ForNodes(ConsistencyReporter reporter)
        {
            return(node =>
            {
                MutableIntSet keys = null;
                foreach (long labelId in NodeLabelReader.GetListOfLabels(node, _storeAccess.NodeDynamicLabelStore))
                {
                    // labelId _is_ actually an int. A technical detail in the store format has these come in a long[]
                    int[] propertyKeys = _nodes.get(safeCastLongToInt(labelId));
                    if (propertyKeys != null)
                    {
                        if (keys == null)
                        {
                            keys = new IntHashSet(16);
                        }
                        foreach (int key in propertyKeys)
                        {
                            keys.add(key);
                        }
                    }
                }
                return keys != null ? new RealCheck <Org.Neo4j.Kernel.impl.store.record.NodeRecord, Check <Org.Neo4j.Kernel.impl.store.record.NodeRecord, Org.Neo4j.Consistency.report.ConsistencyReport_NodeConsistencyReport> >(node, typeof(ConsistencyReport.NodeConsistencyReport), reporter, RecordType.Node, keys) : MandatoryProperties.NoCheck();
            });
        }
示例#3
0
            public override void Check(RelationshipRecord record, CheckerEngine <RelationshipRecord, ConsistencyReport_RelationshipConsistencyReport> engine, RecordAccess records)
            {
                if (CountUpdateCondition.test(record))
                {
                    if (record.InUse())
                    {
                        Org.Neo4j.Consistency.checking.cache.CacheAccess_Client cacheAccess = records.CacheAccess().client();
                        ISet <long> firstNodeLabels;
                        ISet <long> secondNodeLabels;
                        long        firstLabelsField = cacheAccess.GetFromCache(record.FirstNode, SLOT_LABEL_FIELD);
                        if (NodeLabelsField.fieldPointsToDynamicRecordOfLabels(firstLabelsField))
                        {
                            firstNodeLabels = LabelsFor(NodeStore, engine, records, record.FirstNode);
                        }
                        else
                        {
                            firstNodeLabels = NodeLabelReader.GetListOfLabels(firstLabelsField);
                        }
                        long secondLabelsField = cacheAccess.GetFromCache(record.SecondNode, SLOT_LABEL_FIELD);
                        if (NodeLabelsField.fieldPointsToDynamicRecordOfLabels(secondLabelsField))
                        {
                            secondNodeLabels = LabelsFor(NodeStore, engine, records, record.SecondNode);
                        }
                        else
                        {
                            secondNodeLabels = NodeLabelReader.GetListOfLabels(secondLabelsField);
                        }
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int type = record.getType();
                        int type = record.Type;
                        lock ( Counts )
                        {
                            Counts.addToValue(relationshipKey(WILDCARD, WILDCARD, WILDCARD), 1);
                            Counts.addToValue(relationshipKey(WILDCARD, type, WILDCARD), 1);
                            if (firstNodeLabels != null)
                            {
                                foreach (long firstLabel in firstNodeLabels)
                                {
                                    Counts.addToValue(relationshipKey(( int )firstLabel, WILDCARD, WILDCARD), 1);
                                    Counts.addToValue(relationshipKey(( int )firstLabel, type, WILDCARD), 1);
                                }
                            }
                            if (secondNodeLabels != null)
                            {
                                foreach (long secondLabel in secondNodeLabels)
                                {
                                    Counts.addToValue(relationshipKey(WILDCARD, WILDCARD, ( int )secondLabel), 1);
                                    Counts.addToValue(relationshipKey(WILDCARD, type, ( int )secondLabel), 1);
                                }
                            }
                            if (COMPUTE_DOUBLE_SIDED_RELATIONSHIP_COUNTS)
                            {
                                foreach (long firstLabel in firstNodeLabels)
                                {
                                    foreach (long secondLabel in secondNodeLabels)
                                    {
                                        Counts.addToValue(relationshipKey(( int )firstLabel, WILDCARD, ( int )secondLabel), 1);
                                        Counts.addToValue(relationshipKey(( int )firstLabel, type, ( int )secondLabel), 1);
                                    }
                                }
                            }
                        }
                    }
                }
                Inner.check(record, engine, records);
            }