Skip to content

Commit e3771ba

Browse files
committed
Unify GCD and non-GCD rangeIntoBitSet paths
1 parent 71a0881 commit e3771ba

1 file changed

Lines changed: 21 additions & 29 deletions

File tree

lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90DocValuesProducer.java

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2027,37 +2027,31 @@ public void rangeIntoBitSet(
20272027
}
20282028
return;
20292029
}
2030+
LongValues v;
2031+
long lo, hi;
20302032
if (rawValues != null) {
20312033
long[] bounds = transformGcdBounds(minValue, maxValue, mul, delta);
20322034
if (bounds == null) {
20332035
return;
20342036
}
2035-
int cardinality = denseFixedCardinality;
2036-
if (cardinality > 1) {
2037-
sortedNumericScalarRangeIntoBitSet(
2038-
rawValues, fromDoc, endDoc, cardinality, bounds[0], bounds[1], bitSet, offset);
2039-
return;
2040-
}
2041-
for (int currentDoc = fromDoc; currentDoc < endDoc; currentDoc++) {
2042-
long startOffset = addresses.get(currentDoc);
2043-
long endOffset = addresses.get(currentDoc + 1L);
2044-
if (sortedNumericMatchesRange(
2045-
rawValues, startOffset, endOffset, bounds[0], bounds[1])) {
2046-
bitSet.set(currentDoc - offset);
2047-
}
2048-
}
2049-
return;
2037+
v = rawValues;
2038+
lo = bounds[0];
2039+
hi = bounds[1];
2040+
} else {
2041+
v = values;
2042+
lo = minValue;
2043+
hi = maxValue;
20502044
}
20512045
int cardinality = denseFixedCardinality;
20522046
if (cardinality > 1) {
20532047
DOC_VALUES_RANGE_SUPPORT.sortedNumericRangeIntoBitSet(
2054-
values, fromDoc, endDoc, cardinality, minValue, maxValue, bitSet, offset);
2048+
v, fromDoc, endDoc, cardinality, lo, hi, bitSet, offset);
20552049
return;
20562050
}
20572051
for (int currentDoc = fromDoc; currentDoc < endDoc; currentDoc++) {
20582052
long startOffset = addresses.get(currentDoc);
20592053
long endOffset = addresses.get(currentDoc + 1L);
2060-
if (sortedNumericMatchesRange(values, startOffset, endOffset, minValue, maxValue)) {
2054+
if (sortedNumericMatchesRange(v, startOffset, endOffset, lo, hi)) {
20612055
bitSet.set(currentDoc - offset);
20622056
}
20632057
}
@@ -2157,29 +2151,27 @@ public void rangeIntoBitSet(
21572151
set = false;
21582152
return;
21592153
}
2154+
LongValues v;
2155+
long lo, hi;
21602156
if (rawValues != null) {
21612157
long[] bounds = transformGcdBounds(minValue, maxValue, mul, delta);
21622158
if (bounds == null) {
21632159
set = false;
21642160
return;
21652161
}
2166-
for (; currentDoc < endDoc; currentDoc = disi.nextDoc()) {
2167-
int index = disi.index();
2168-
long startOffset = addresses.get(index);
2169-
long endOffset = addresses.get(index + 1L);
2170-
if (sortedNumericMatchesRange(
2171-
rawValues, startOffset, endOffset, bounds[0], bounds[1])) {
2172-
bitSet.set(currentDoc - offset);
2173-
}
2174-
}
2175-
set = false;
2176-
return;
2162+
v = rawValues;
2163+
lo = bounds[0];
2164+
hi = bounds[1];
2165+
} else {
2166+
v = values;
2167+
lo = minValue;
2168+
hi = maxValue;
21772169
}
21782170
for (; currentDoc < endDoc; currentDoc = disi.nextDoc()) {
21792171
int index = disi.index();
21802172
long startOffset = addresses.get(index);
21812173
long endOffset = addresses.get(index + 1L);
2182-
if (sortedNumericMatchesRange(values, startOffset, endOffset, minValue, maxValue)) {
2174+
if (sortedNumericMatchesRange(v, startOffset, endOffset, lo, hi)) {
21832175
bitSet.set(currentDoc - offset);
21842176
}
21852177
}

0 commit comments

Comments
 (0)