Esempio n. 1
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.
            }
        }
        /// <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);
                            }
                        }
                    }
                }
            }
        }