mirror of https://github.com/apache/lucene.git
Slight improvement/optimization to duplicate facet value checking (ref: LUCENE-9964) (#234)
This commit is contained in:
parent
645b64ef4e
commit
3037e33025
|
@ -162,14 +162,14 @@ public class LongValueFacetCounts extends Facets {
|
||||||
if (limit > 0) {
|
if (limit > 0) {
|
||||||
totCount++;
|
totCount++;
|
||||||
}
|
}
|
||||||
long previousValue = 0;
|
long previousValue = -1;
|
||||||
for (int i = 0; i < limit; i++) {
|
for (int i = 0; i < limit; i++) {
|
||||||
long value = multiValues.nextValue();
|
long value = multiValues.nextValue();
|
||||||
// do not increment the count for duplicate values
|
// do not increment the count for duplicate values
|
||||||
if (i == 0 || value != previousValue) {
|
if (value != previousValue) {
|
||||||
increment(value);
|
increment(value);
|
||||||
|
previousValue = value;
|
||||||
}
|
}
|
||||||
previousValue = value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,14 +214,14 @@ public class LongValueFacetCounts extends Facets {
|
||||||
if (limit > 0) {
|
if (limit > 0) {
|
||||||
totCount++;
|
totCount++;
|
||||||
}
|
}
|
||||||
long previousValue = 0;
|
long previousValue = -1;
|
||||||
for (int i = 0; i < limit; i++) {
|
for (int i = 0; i < limit; i++) {
|
||||||
long value = multiValues.nextValue();
|
long value = multiValues.nextValue();
|
||||||
// do not increment the count for duplicate values
|
// do not increment the count for duplicate values
|
||||||
if (i == 0 || value != previousValue) {
|
if (value != previousValue) {
|
||||||
increment(value);
|
increment(value);
|
||||||
|
previousValue = value;
|
||||||
}
|
}
|
||||||
previousValue = value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,8 +193,13 @@ abstract class RangeFacetCounts extends Facets {
|
||||||
totCount++;
|
totCount++;
|
||||||
} else {
|
} else {
|
||||||
counter.startMultiValuedDoc();
|
counter.startMultiValuedDoc();
|
||||||
|
long previous = -1;
|
||||||
for (int j = 0; j < limit; j++) {
|
for (int j = 0; j < limit; j++) {
|
||||||
counter.addMultiValued(mapDocValue(multiValues.nextValue()));
|
long val = mapDocValue(multiValues.nextValue());
|
||||||
|
if (val != previous) {
|
||||||
|
counter.addMultiValued(val);
|
||||||
|
previous = val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (counter.endMultiValuedDoc()) {
|
if (counter.endMultiValuedDoc()) {
|
||||||
totCount++;
|
totCount++;
|
||||||
|
|
Loading…
Reference in New Issue