pvary commented on code in PR #18027:
URL: https://github.com/apache/iceberg/pull/18027#discussion_r4015586223


##########
core/src/main/java/org/apache/iceberg/deletes/RoaringPositionBitmap.java:
##########
@@ -192,6 +193,43 @@ public void forEach(LongConsumer consumer) {
     }
   }
 
+  /**
+   * Iterates over the positions set within the given range, in ascending 
order.
+   *
+   * <p>Each underlying 32-bit bitmap that the range covers is traversed once, 
instead of resolving
+   * the containing bitmap for every position as {@link #contains(long)} does.
+   *
+   * @param posStartInclusive inclusive beginning of position range
+   * @param posEndExclusive exclusive ending of position range
+   * @param consumer a consumer for the positions that are set within the range
+   */
+  public void forEachInRange(long posStartInclusive, long posEndExclusive, 
LongConsumer consumer) {
+    Preconditions.checkArgument(
+        posStartInclusive <= posEndExclusive,
+        "Start position must not exceed end position: [%s, %s)",
+        posStartInclusive,
+        posEndExclusive);
+
+    if (posStartInclusive == posEndExclusive) {
+      return;
+    }
+
+    validatePosition(posStartInclusive);
+    validatePosition(posEndExclusive - 1);
+
+    int startKey = key(posStartInclusive);
+    int endKey = key(posEndExclusive - 1);
+
+    for (int key = startKey; key <= endKey && key < bitmaps.length; key++) {
+      long lowStart = key == startKey ? 
Integer.toUnsignedLong(pos32Bits(posStartInclusive)) : 0L;
+      long lowEnd =
+          key == endKey
+              ? Integer.toUnsignedLong(pos32Bits(posEndExclusive - 1)) + 1
+              : MAX_POS_32_BITS + 1;

Review Comment:
   Is this the same as `1L << 32` used elsewhere?



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