//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void applyConcurrentChangesToPopulatedIndex() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ApplyConcurrentChangesToPopulatedIndex()
        {
            IList <EntityUpdates> updates = new List <EntityUpdates>(2);

            updates.Add(EntityUpdates.forEntity(_color2.Id, false).withTokens(Id(COLOR_LABEL)).changed(_propertyId, Values.of("green"), Values.of("pink")).build());
            updates.Add(EntityUpdates.forEntity(_car2.Id, false).withTokens(Id(CAR_LABEL)).changed(_propertyId, Values.of("Ford"), Values.of("SAAB")).build());

            LaunchCustomIndexPopulation(_labelsNameIdMap, _propertyId, new UpdateGenerator(this, updates));
            WaitAndActivateIndexes(_labelsNameIdMap, _propertyId);

            using (Transaction ignored = EmbeddedDatabase.beginTx())
            {
                int?colorLabelId = _labelsNameIdMap[COLOR_LABEL];
                int?carLabelId   = _labelsNameIdMap[CAR_LABEL];
                using (IndexReader indexReader = GetIndexReader(_propertyId, colorLabelId))
                {
                    assertEquals(format("Should be deleted by concurrent change. Reader is: %s, ", indexReader), 0, indexReader.CountIndexedNodes(_color2.Id, new int[] { _propertyId }, Values.of("green")));
                }
                using (IndexReader indexReader = GetIndexReader(_propertyId, colorLabelId))
                {
                    assertEquals("Should be updated by concurrent change.", 1, indexReader.CountIndexedNodes(_color2.Id, new int[] { _propertyId }, Values.of("pink")));
                }

                using (IndexReader indexReader = GetIndexReader(_propertyId, carLabelId))
                {
                    assertEquals("Should be added by concurrent change.", 1, indexReader.CountIndexedNodes(_car2.Id, new int[] { _propertyId }, Values.of("SAAB")));
                }
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void applyConcurrentAddsToPopulatedIndex() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ApplyConcurrentAddsToPopulatedIndex()
        {
            IList <EntityUpdates> updates = new List <EntityUpdates>(2);

            updates.Add(EntityUpdates.forEntity(_otherNodes[0].Id, false).withTokens(Id(COUNTRY_LABEL)).added(_propertyId, Values.of("Denmark")).build());
            updates.Add(EntityUpdates.forEntity(_otherNodes[1].Id, false).withTokens(Id(CAR_LABEL)).added(_propertyId, Values.of("BMW")).build());

            LaunchCustomIndexPopulation(_labelsNameIdMap, _propertyId, new UpdateGenerator(this, updates));
            WaitAndActivateIndexes(_labelsNameIdMap, _propertyId);

            using (Transaction ignored = EmbeddedDatabase.beginTx())
            {
                int?countryLabelId = _labelsNameIdMap[COUNTRY_LABEL];
                int?carLabelId     = _labelsNameIdMap[CAR_LABEL];
                using (IndexReader indexReader = GetIndexReader(_propertyId, countryLabelId))
                {
                    assertEquals("Should be added by concurrent add.", 1, indexReader.CountIndexedNodes(_otherNodes[0].Id, new int[] { _propertyId }, Values.of("Denmark")));
                }

                using (IndexReader indexReader = GetIndexReader(_propertyId, carLabelId))
                {
                    assertEquals("Should be added by concurrent add.", 1, indexReader.CountIndexedNodes(_otherNodes[1].Id, new int[] { _propertyId }, Values.of("BMW")));
                }
            }
        }
Example #3
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.
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void applyConcurrentDeletesToPopulatedIndex() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ApplyConcurrentDeletesToPopulatedIndex()
        {
            IList <EntityUpdates> updates = new List <EntityUpdates>(2);

            updates.Add(EntityUpdates.forEntity(_country1.Id, false).withTokens(Id(COUNTRY_LABEL)).removed(_propertyId, Values.of("Sweden")).build());
            updates.Add(EntityUpdates.forEntity(_color2.Id, false).withTokens(Id(COLOR_LABEL)).removed(_propertyId, Values.of("green")).build());

            LaunchCustomIndexPopulation(_labelsNameIdMap, _propertyId, new UpdateGenerator(this, updates));
            WaitAndActivateIndexes(_labelsNameIdMap, _propertyId);

            using (Transaction ignored = EmbeddedDatabase.beginTx())
            {
                int?countryLabelId = _labelsNameIdMap[COUNTRY_LABEL];
                int?colorLabelId   = _labelsNameIdMap[COLOR_LABEL];
                using (IndexReader indexReader = GetIndexReader(_propertyId, countryLabelId))
                {
                    assertEquals("Should be removed by concurrent remove.", 0, indexReader.CountIndexedNodes(0, new int[] { _propertyId }, Values.of("Sweden")));
                }

                using (IndexReader indexReader = GetIndexReader(_propertyId, colorLabelId))
                {
                    assertEquals("Should be removed by concurrent remove.", 0, indexReader.CountIndexedNodes(3, new int[] { _propertyId }, Values.of("green")));
                }
            }
        }
        /// <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);
                            }
                        }
                    }
                }
            }
        }