use of org.neo4j.kernel.impl.api.index.sampling.DefaultNonUniqueIndexSampler in project neo4j by neo4j.
the class NonUniqueLuceneIndexSampler method performSampling.
@Override
protected IndexSample performSampling() throws IndexNotFoundKernelException {
NonUniqueIndexSampler sampler = new DefaultNonUniqueIndexSampler(indexSamplingConfig.sampleSizeLimit());
IndexReader indexReader = indexSearcher.getIndexReader();
for (LeafReaderContext readerContext : indexReader.leaves()) {
try {
Set<String> fieldNames = getFieldNamesToSample(readerContext);
for (String fieldName : 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 RuntimeException(e);
}
}
return sampler.result(indexReader.numDocs());
}
Aggregations