예제 #1
0
 public override IndexSampler CreateSampler()
 {
     return(@delegate.CreateSampler());
 }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ParameterizedTest @ValueSource(ints = {7, 11, 14, 20, 35, 58}) void partitionedIndexPopulation(int affectedNodes) throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void PartitionedIndexPopulation(int affectedNodes)
        {
            File rootFolder = new File(_testDir.directory("partitionIndex" + affectedNodes), "uniqueIndex" + affectedNodes);

            using (SchemaIndex uniqueIndex = LuceneSchemaIndexBuilder.create(_descriptor, Config.defaults()).withFileSystem(_fileSystem).withIndexRootFolder(rootFolder).build())
            {
                uniqueIndex.open();

                // index is empty and not yet exist
                assertEquals(0, uniqueIndex.allDocumentsReader().maxCount());
                assertFalse(uniqueIndex.exists());

                using (LuceneIndexAccessor indexAccessor = new LuceneIndexAccessor(uniqueIndex, _descriptor))
                {
                    GenerateUpdates(indexAccessor, affectedNodes);
                    indexAccessor.Force(Org.Neo4j.Io.pagecache.IOLimiter_Fields.Unlimited);

                    // now index is online and should contain updates data
                    assertTrue(uniqueIndex.Online);

                    using (IndexReader indexReader = indexAccessor.NewReader(), IndexSampler indexSampler = indexReader.CreateSampler())
                    {
                        long[] nodes = PrimitiveLongCollections.asArray(indexReader.Query(IndexQuery.exists(1)));
                        assertEquals(affectedNodes, nodes.Length);

                        IndexSample sample = indexSampler.SampleIndex();
                        assertEquals(affectedNodes, sample.IndexSize());
                        assertEquals(affectedNodes, sample.UniqueValues());
                        assertEquals(affectedNodes, sample.SampleSize());
                    }
                }
            }
        }
예제 #3
0
        public override void Run()
        {
            using (DurationLogger durationLogger = new DurationLogger(_log, "Sampling index " + _indexUserDescription))
            {
                try
                {
                    using (IndexReader reader = _indexProxy.newReader(), IndexSampler sampler = reader.CreateSampler())
                    {
                        IndexSample sample = sampler.SampleIndex();

                        // check again if the index is online before saving the counts in the store
                        if (_indexProxy.State == ONLINE)
                        {
                            _storeView.replaceIndexCounts(_indexId, sample.UniqueValues(), sample.SampleSize(), sample.IndexSize());
                            durationLogger.MarkAsFinished();
                            _log.debug(format("Sampled index %s with %d unique values in sample of avg size %d taken from " + "index containing %d entries", _indexUserDescription, sample.UniqueValues(), sample.SampleSize(), sample.IndexSize()));
                        }
                        else
                        {
                            durationLogger.MarkAsAborted("Index no longer ONLINE");
                        }
                    }
                }
                catch (IndexNotFoundKernelException)
                {
                    durationLogger.MarkAsAborted("Attempted to sample missing/already deleted index " + _indexUserDescription);
                }
            }
        }