Exemplo n.º 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.storageengine.api.schema.IndexSample sampleIndex() throws org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException
        public override IndexSample SampleIndex()
        {
            NonUniqueIndexSampler sampler     = new DefaultNonUniqueIndexSampler(_indexSamplingConfig.sampleSizeLimit());
            IndexReader           indexReader = _indexSearcher.IndexReader;

            foreach (LeafReaderContext readerContext in indexReader.leaves())
            {
                try
                {
                    ISet <string> fieldNames = GetFieldNamesToSample(readerContext);
                    foreach (string fieldName in fieldNames)
                    {
                        Terms terms = readerContext.reader().terms(fieldName);
                        if (terms != null)
                        {
                            TermsEnum termsEnum = LuceneDocumentStructure.originalTerms(terms, fieldName);
                            BytesRef  termsRef;
                            while ((termsRef = termsEnum.next()) != null)
                            {
                                sampler.Include(termsRef.utf8ToString(), termsEnum.docFreq());
                                CheckCancellation();
                            }
                        }
                    }
                }
                catch (IOException e)
                {
                    throw new Exception(e);
                }
            }

            return(sampler.Result(indexReader.numDocs()));
        }