LUCENE-10346: Specially treat SingletonSortedNumericDocValues in FastTaxonomyFacetCounts#countAll() (#574)

This commit is contained in:
gf2121 2022-01-03 21:44:05 +08:00 committed by Adrien Grand
parent da3992b16f
commit 01f5e7bb7b
2 changed files with 15 additions and 0 deletions

View File

@ -106,6 +106,8 @@ Optimizations
asked to -- typically never. This fixes a performance regression since 7.3 LUCENE-8099 when some
older boosting queries were replaced with this. (David Smiley)
* LUCENE-10346: Optimize facet counting for single-valued TaxonomyFacetCounts. (Guo Feng)
Bug Fixes
---------------------

View File

@ -23,8 +23,10 @@ import org.apache.lucene.facet.FacetUtils;
import org.apache.lucene.facet.FacetsCollector;
import org.apache.lucene.facet.FacetsCollector.MatchingDocs;
import org.apache.lucene.facet.FacetsConfig;
import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.NumericDocValues;
import org.apache.lucene.index.SortedNumericDocValues;
import org.apache.lucene.search.ConjunctionUtils;
import org.apache.lucene.search.DocIdSetIterator;
@ -98,6 +100,17 @@ public class FastTaxonomyFacetCounts extends IntTaxonomyFacets {
Bits liveDocs = context.reader().getLiveDocs();
NumericDocValues ndv = DocValues.unwrapSingleton(dv);
if (ndv != null) {
for (int doc = ndv.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = ndv.nextDoc()) {
if (liveDocs != null && liveDocs.get(doc) == false) {
continue;
}
increment((int) ndv.longValue());
}
continue;
}
for (int doc = dv.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = dv.nextDoc()) {
if (liveDocs != null && liveDocs.get(doc) == false) {
continue;