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


##########
core/src/test/java/org/apache/iceberg/deletes/TestRoaringPositionBitmap.java:
##########
@@ -350,6 +350,117 @@ public void testAddAllSparseBitmaps() {
     assertThat(bitmap1.cardinality()).isEqualTo(4);
   }
 
+  @TestTemplate
+  public void testForEachInRange() {
+    RoaringPositionBitmap bitmap = new RoaringPositionBitmap();
+    bitmap.setRange(10L, 20L);
+
+    // the beginning is inclusive and the end is exclusive
+    assertThat(collectInRange(bitmap, 12L, 15L)).containsExactly(12L, 13L, 
14L);
+    assertThat(collectInRange(bitmap, 0L, 10L)).isEmpty();
+    assertThat(collectInRange(bitmap, 20L, 30L)).isEmpty();
+  }
+
+  @TestTemplate
+  public void testForEachInRangeEmptyRange() {
+    RoaringPositionBitmap bitmap = new RoaringPositionBitmap();
+    bitmap.setRange(10L, 20L);
+
+    assertThat(collectInRange(bitmap, 15L, 15L)).isEmpty();
+  }
+
+  @TestTemplate
+  public void testForEachInRangeInvalidRange() {
+    RoaringPositionBitmap bitmap = new RoaringPositionBitmap();
+
+    assertThatThrownBy(() -> bitmap.forEachInRange(20L, 10L, pos -> {}))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessageContaining("Start position must not exceed end position");
+  }
+
+  @TestTemplate
+  public void testForEachInRangeAcrossContainers() {
+    RoaringPositionBitmap bitmap = new RoaringPositionBitmap();
+    bitmap.setRange(CONTAINER_OFFSET - 2, CONTAINER_OFFSET + 2);
+
+    assertThat(collectInRange(bitmap, CONTAINER_OFFSET - 3, CONTAINER_OFFSET + 
3))
+        .containsExactly(
+            CONTAINER_OFFSET - 2, CONTAINER_OFFSET - 1, CONTAINER_OFFSET, 
CONTAINER_OFFSET + 1);
+  }
+
+  @TestTemplate
+  public void testForEachInRangeAcrossKeys() {

Review Comment:
   Thanks for sharing this! I've adopted a variation of this test and expanded 
it into an exhaustive sweep around the boundary to ensure it's fully covered.



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