sodonnel commented on code in PR #11169:
URL: https://github.com/apache/ozone/pull/11169#discussion_r3913289538


##########
hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/utils/db/TestRDBTableStore.java:
##########
@@ -654,6 +654,37 @@ public void testPrefixedRangeKVs() throws Exception {
     assertEquals(0, rangeKVs.size());
   }
 
+  @Test
+  public void testRangeKVsStartKeyInclusiveAndAbsent() throws Exception {
+    Table<byte[], byte[]> testTable = rdbStore.getTable("PrefixFour");
+    byte[] prefix = "p/".getBytes(StandardCharsets.UTF_8);
+    for (String suffix : new String[] {"a", "c", "e"}) {
+      byte[] key = ("p/" + suffix).getBytes(StandardCharsets.UTF_8);
+      testTable.put(key, key);
+    }
+    byte[] present = "p/c".getBytes(StandardCharsets.UTF_8);
+    byte[] absentMiddle = "p/b".getBytes(StandardCharsets.UTF_8);
+    byte[] absentPastEnd = "p/z".getBytes(StandardCharsets.UTF_8);
+
+    // Existing start key: the range starts at that key (inclusive).
+    List<Table.KeyValue<byte[], byte[]>> rangeKVs =
+        testTable.getRangeKVs(present, 10, prefix);
+    assertEquals(2, rangeKVs.size());
+    assertArrayEquals(present, rangeKVs.get(0).getKey());
+
+    // Absent start key with a later key under the prefix: seek lands on a
+    // different key, so the range is empty.
+    assertEquals(0, testTable.getRangeKVs(absentMiddle, 10, prefix).size());
+    // Absent start key past every key: seek lands on nothing, range is empty.
+    assertEquals(0, testTable.getRangeKVs(absentPastEnd, 10, prefix).size());
+
+    // Same checks with no prefix (whole-table range).
+    rangeKVs = testTable.getRangeKVs(present, 10, null);
+    assertEquals(2, rangeKVs.size());
+    assertArrayEquals(present, rangeKVs.get(0).getKey());
+    assertEquals(0, testTable.getRangeKVs(absentMiddle, 10, null).size());

Review Comment:
   Can we add the absentPastEnd test case for the null prefix to complete all 
scenarios?



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