costin commented on code in PR #16160:
URL: https://github.com/apache/lucene/pull/16160#discussion_r3416825781
##########
lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90DocValuesProducer.java:
##########
@@ -480,6 +480,59 @@ static void rangeIntoBitSet(
values, fromDoc, toDoc, minValue, maxValue, bitSet, offset);
}
+ private static void rangeGcdDeltaIntoBitSet(
+ LongValues values,
+ int fromDoc,
+ int toDoc,
+ long minValue,
+ long maxValue,
+ long mul,
+ long delta,
+ FixedBitSet bitSet,
+ int offset) {
+ long encodedMin;
+ long encodedMax;
+ try {
+ encodedMin = Math.subtractExact(minValue, delta);
+ encodedMax = Math.subtractExact(maxValue, delta);
+ if (mul != 1) {
+ encodedMin = ceilDiv(encodedMin, mul);
+ encodedMax = Math.floorDiv(encodedMax, mul);
+ }
+ encodedMin = Math.max(0, encodedMin);
+ } catch (ArithmeticException _) {
Review Comment:
Good question. Initially they used to hit the per-doc fallback.
However I've added two saturating helpers (saturatingShiftLower,
saturatingShiftUpper) that catch the overflow and saturate to Long.MIN_VALUE /
Long.MAX_VALUE based on the sign of delta. It turns out that combined with
Math.ceilDiv / Math.floorDiv (overflow-safe for mul > 0), open-bound queries
now stay on the SIMD path.
A useful side effect: the per-doc decoded fallback is provably unreachable,
so I removed it.
The reachable code path is now bound transform → SIMD kernel, no scalar
branch.
New tests cover this: WithOpenLowerBound, WithOpenUpperBound,
WithBothOpenBounds.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]