LUCENE-10603: Change iteration methodology for SSDV ordinals in the faceting module (#954)

This commit is contained in:
Greg Miller 2022-06-17 10:37:24 -07:00 committed by GitHub
parent b180a8a97e
commit 6ba759df86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 48 deletions

View File

@ -86,6 +86,9 @@ Improvements
* LUCENE-10585: Facet module code cleanup (copy/paste scrubbing, simplification and some very minor
optimization tweaks). (Greg Miller)
* LUCENE-10603: Update SortedSetDocValues iteration within faceting implementations to use
SortedSetDocValues#docValueCount(). (Greg Miller)
Optimizations
---------------------
* LUCENE-8519: MultiDocValues.getNormValues should not call getMergedFieldInfos (Rushabh Shah)

View File

@ -374,15 +374,14 @@ public class StringValueFacetCounts extends Facets {
}
} else {
for (int doc = it.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = it.nextDoc()) {
int term = (int) multiValues.nextOrd();
boolean countedDocInTotal = false;
while (term != SortedSetDocValues.NO_MORE_ORDS) {
for (int i = 0; i < multiValues.docValueCount(); i++) {
int term = (int) multiValues.nextOrd();
increment(term);
if (countedDocInTotal == false) {
totalDocCount++;
countedDocInTotal = true;
}
term = (int) multiValues.nextOrd();
}
}
}
@ -402,15 +401,14 @@ public class StringValueFacetCounts extends Facets {
}
} else {
for (int doc = it.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = it.nextDoc()) {
int term = (int) multiValues.nextOrd();
boolean countedDocInTotal = false;
while (term != SortedSetDocValues.NO_MORE_ORDS) {
for (int i = 0; i < multiValues.docValueCount(); i++) {
int term = (int) multiValues.nextOrd();
increment((int) ordMap.get(term));
if (countedDocInTotal == false) {
totalDocCount++;
countedDocInTotal = true;
}
term = (int) multiValues.nextOrd();
}
}
}
@ -427,15 +425,14 @@ public class StringValueFacetCounts extends Facets {
}
} else {
for (int doc = it.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = it.nextDoc()) {
int term = (int) multiValues.nextOrd();
boolean countedDocInTotal = false;
while (term != SortedSetDocValues.NO_MORE_ORDS) {
for (int i = 0; i < multiValues.docValueCount(); i++) {
int term = (int) multiValues.nextOrd();
segCounts[term]++;
if (countedDocInTotal == false) {
totalDocCount++;
countedDocInTotal = true;
}
term = (int) multiValues.nextOrd();
}
}
}
@ -474,9 +471,8 @@ public class StringValueFacetCounts extends Facets {
doc != DocIdSetIterator.NO_MORE_DOCS;
doc = multiValues.nextDoc()) {
boolean countedDocInTotal = false;
for (int term = (int) multiValues.nextOrd();
term != SortedSetDocValues.NO_MORE_ORDS;
term = (int) multiValues.nextOrd()) {
for (int i = 0; i < multiValues.docValueCount(); i++) {
int term = (int) multiValues.nextOrd();
increment(term);
if (countedDocInTotal == false) {
totalDocCount++;
@ -509,9 +505,8 @@ public class StringValueFacetCounts extends Facets {
doc != DocIdSetIterator.NO_MORE_DOCS;
doc = multiValues.nextDoc()) {
boolean countedDocInTotal = false;
for (int term = (int) multiValues.nextOrd();
term != SortedSetDocValues.NO_MORE_ORDS;
term = (int) multiValues.nextOrd()) {
for (int i = 0; i < multiValues.docValueCount(); i++) {
int term = (int) multiValues.nextOrd();
segCounts[term]++;
if (countedDocInTotal == false) {
totalDocCount++;

View File

@ -157,9 +157,8 @@ public class ConcurrentSortedSetDocValuesFacetCounts extends AbstractSortedSetDo
for (int doc = multiValues.nextDoc();
doc != DocIdSetIterator.NO_MORE_DOCS;
doc = multiValues.nextDoc()) {
for (int term = (int) multiValues.nextOrd();
term != SortedSetDocValues.NO_MORE_ORDS;
term = (int) multiValues.nextOrd()) {
for (int i = 0; i < multiValues.docValueCount(); i++) {
int term = (int) multiValues.nextOrd();
counts.incrementAndGet((int) ordMap.get(term));
}
}
@ -167,9 +166,8 @@ public class ConcurrentSortedSetDocValuesFacetCounts extends AbstractSortedSetDo
for (int doc = it.nextDoc();
doc != DocIdSetIterator.NO_MORE_DOCS;
doc = it.nextDoc()) {
for (int term = (int) multiValues.nextOrd();
term != SortedSetDocValues.NO_MORE_ORDS;
term = (int) multiValues.nextOrd()) {
for (int i = 0; i < multiValues.docValueCount(); i++) {
int term = (int) multiValues.nextOrd();
counts.incrementAndGet((int) ordMap.get(term));
}
}
@ -198,9 +196,8 @@ public class ConcurrentSortedSetDocValuesFacetCounts extends AbstractSortedSetDo
for (int doc = multiValues.nextDoc();
doc != DocIdSetIterator.NO_MORE_DOCS;
doc = multiValues.nextDoc()) {
for (int term = (int) multiValues.nextOrd();
term != SortedSetDocValues.NO_MORE_ORDS;
term = (int) multiValues.nextOrd()) {
for (int i = 0; i < multiValues.docValueCount(); i++) {
int term = (int) multiValues.nextOrd();
segCounts[term]++;
}
}
@ -208,9 +205,8 @@ public class ConcurrentSortedSetDocValuesFacetCounts extends AbstractSortedSetDo
for (int doc = it.nextDoc();
doc != DocIdSetIterator.NO_MORE_DOCS;
doc = it.nextDoc()) {
for (int term = (int) multiValues.nextOrd();
term != SortedSetDocValues.NO_MORE_ORDS;
term = (int) multiValues.nextOrd()) {
for (int i = 0; i < multiValues.docValueCount(); i++) {
int term = (int) multiValues.nextOrd();
segCounts[term]++;
}
}
@ -245,17 +241,15 @@ public class ConcurrentSortedSetDocValuesFacetCounts extends AbstractSortedSetDo
for (int doc = multiValues.nextDoc();
doc != DocIdSetIterator.NO_MORE_DOCS;
doc = multiValues.nextDoc()) {
for (int term = (int) multiValues.nextOrd();
term != SortedSetDocValues.NO_MORE_ORDS;
term = (int) multiValues.nextOrd()) {
for (int i = 0; i < multiValues.docValueCount(); i++) {
int term = (int) multiValues.nextOrd();
counts.incrementAndGet(term);
}
}
} else {
for (int doc = it.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = it.nextDoc()) {
for (int term = (int) multiValues.nextOrd();
term != SortedSetDocValues.NO_MORE_ORDS;
term = (int) multiValues.nextOrd()) {
for (int i = 0; i < multiValues.docValueCount(); i++) {
int term = (int) multiValues.nextOrd();
counts.incrementAndGet(term);
}
}

View File

@ -121,10 +121,9 @@ public class SortedSetDocValuesFacetCounts extends AbstractSortedSetDocValueFace
for (int doc = multiValues.nextDoc();
doc != DocIdSetIterator.NO_MORE_DOCS;
doc = multiValues.nextDoc()) {
int term = (int) multiValues.nextOrd();
while (term != SortedSetDocValues.NO_MORE_ORDS) {
for (int i = 0; i < multiValues.docValueCount(); i++) {
int term = (int) multiValues.nextOrd();
segCounts[term]++;
term = (int) multiValues.nextOrd();
}
}
}
@ -150,10 +149,9 @@ public class SortedSetDocValuesFacetCounts extends AbstractSortedSetDocValueFace
for (int doc = multiValues.nextDoc();
doc != DocIdSetIterator.NO_MORE_DOCS;
doc = multiValues.nextDoc()) {
int term = (int) multiValues.nextOrd();
while (term != SortedSetDocValues.NO_MORE_ORDS) {
for (int i = 0; i < multiValues.docValueCount(); i++) {
int term = (int) multiValues.nextOrd();
counts[term]++;
term = (int) multiValues.nextOrd();
}
}
}
@ -204,10 +202,9 @@ public class SortedSetDocValuesFacetCounts extends AbstractSortedSetDocValueFace
}
} else {
for (int doc = it.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = it.nextDoc()) {
int term = (int) multiValues.nextOrd();
while (term != SortedSetDocValues.NO_MORE_ORDS) {
for (int i = 0; i < multiValues.docValueCount(); i++) {
int term = (int) multiValues.nextOrd();
counts[(int) ordMap.get(term)]++;
term = (int) multiValues.nextOrd();
}
}
}
@ -220,10 +217,9 @@ public class SortedSetDocValuesFacetCounts extends AbstractSortedSetDocValueFace
}
} else {
for (int doc = it.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = it.nextDoc()) {
int term = (int) multiValues.nextOrd();
while (term != SortedSetDocValues.NO_MORE_ORDS) {
for (int i = 0; i < multiValues.docValueCount(); i++) {
int term = (int) multiValues.nextOrd();
segCounts[term]++;
term = (int) multiValues.nextOrd();
}
}
}
@ -246,10 +242,9 @@ public class SortedSetDocValuesFacetCounts extends AbstractSortedSetDocValueFace
}
} else {
for (int doc = it.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = it.nextDoc()) {
int term = (int) multiValues.nextOrd();
while (term != SortedSetDocValues.NO_MORE_ORDS) {
for (int i = 0; i < multiValues.docValueCount(); i++) {
int term = (int) multiValues.nextOrd();
counts[term]++;
term = (int) multiValues.nextOrd();
}
}
}