salvatore-campagna commented on code in PR #16160:
URL: https://github.com/apache/lucene/pull/16160#discussion_r3389968668


##########
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);

Review Comment:
   We already use `Math.floorDiv` for the upper bound. Is there a reason we use 
`ceilDiv` instead of `Math.ceilDiv` for the lower one? With `mul > 0` 
`Math.ceilDiv` is documented to never overflow, so the `Math.addExact` in the 
positive branch looks redundant. Symmetriccally `Math.ceilDiv` / 
`Math.floorDiv` would also read more naturally side by side.



##########
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);

Review Comment:
   We already use `Math.floorDiv` for the upper bound. Is there a reason we use 
`ceilDiv` instead of `Math.ceilDiv` for the lower one? With `mul > 0` 
`Math.ceilDiv` is documented to never overflow, so the `Math.addExact` in the 
positive branch looks redundant. Symmetrically `Math.ceilDiv` / `Math.floorDiv` 
would also read more naturally side by side.



-- 
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]

Reply via email to