gf2121 commented on a change in pull request #585: URL: https://github.com/apache/lucene/pull/585#discussion_r779279138
########## File path: lucene/facet/src/java/org/apache/lucene/facet/taxonomy/FastTaxonomyFacetCounts.java ########## @@ -71,17 +71,27 @@ public FastTaxonomyFacetCounts( private final void count(List<MatchingDocs> matchingDocs) throws IOException { for (MatchingDocs hits : matchingDocs) { - SortedNumericDocValues dv = hits.context.reader().getSortedNumericDocValues(indexFieldName); - if (dv == null) { + SortedNumericDocValues multiValued = + hits.context.reader().getSortedNumericDocValues(indexFieldName); + if (multiValued == null) { continue; } + NumericDocValues singleValued = DocValues.unwrapSingleton(multiValued); + + DocIdSetIterator valuesIt = singleValued != null ? singleValued : multiValued; DocIdSetIterator it = - ConjunctionUtils.intersectIterators(Arrays.asList(hits.bits.iterator(), dv)); + ConjunctionUtils.intersectIterators(Arrays.asList(hits.bits.iterator(), valuesIt)); - for (int doc = it.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = it.nextDoc()) { - for (int i = 0; i < dv.docValueCount(); i++) { - increment((int) dv.nextValue()); + if (singleValued != null) { + for (int doc = it.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = it.nextDoc()) { Review comment: Maybe simplify this a bit with `while(it.nextDoc() != DocIdSetIterator.NO_MORE_DOCS)` as `doc` is not used in the loop body? ########## File path: lucene/facet/src/java/org/apache/lucene/facet/taxonomy/FastTaxonomyFacetCounts.java ########## @@ -91,31 +101,36 @@ private final void count(List<MatchingDocs> matchingDocs) throws IOException { private final void countAll(IndexReader reader) throws IOException { for (LeafReaderContext context : reader.leaves()) { - SortedNumericDocValues dv = context.reader().getSortedNumericDocValues(indexFieldName); - if (dv == null) { + SortedNumericDocValues multiValued = Review comment: +1 ########## File path: lucene/facet/src/java/org/apache/lucene/facet/taxonomy/FastTaxonomyFacetCounts.java ########## @@ -71,17 +71,27 @@ public FastTaxonomyFacetCounts( private final void count(List<MatchingDocs> matchingDocs) throws IOException { for (MatchingDocs hits : matchingDocs) { - SortedNumericDocValues dv = hits.context.reader().getSortedNumericDocValues(indexFieldName); - if (dv == null) { + SortedNumericDocValues multiValued = + hits.context.reader().getSortedNumericDocValues(indexFieldName); + if (multiValued == null) { continue; } + NumericDocValues singleValued = DocValues.unwrapSingleton(multiValued); + + DocIdSetIterator valuesIt = singleValued != null ? singleValued : multiValued; DocIdSetIterator it = - ConjunctionUtils.intersectIterators(Arrays.asList(hits.bits.iterator(), dv)); + ConjunctionUtils.intersectIterators(Arrays.asList(hits.bits.iterator(), valuesIt)); - for (int doc = it.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = it.nextDoc()) { - for (int i = 0; i < dv.docValueCount(); i++) { - increment((int) dv.nextValue()); + if (singleValued != null) { + for (int doc = it.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = it.nextDoc()) { + increment((int) singleValued.longValue()); + } + } else { + for (int doc = it.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = it.nextDoc()) { Review comment: We can use `while(it.nextDoc() != DocIdSetIterator.NO_MORE_DOCS)` here too. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org