keith-turner commented on code in PR #3799:
URL: https://github.com/apache/accumulo/pull/3799#discussion_r1364360013


##########
core/src/test/java/org/apache/accumulo/core/file/rfile/FencedRFileTest.java:
##########
@@ -205,6 +207,111 @@ public void testFencing12() throws IOException {
     assertFalse(iter.hasTop());
   }
 
+  @Test
+  public void testFirstAndLastKey() throws IOException {
+    final TestRFile trf = initTestFile();
+
+    Key firstKeyInFile =
+        newKey(formatString("r_", 0), formatString("cf_", 0), 
formatString("cq_", 0), "A", 4);
+    Key lastKeyInFile =
+        newKey(formatString("r_", 3), formatString("cf_", 3), 
formatString("cq_", 3), "D", 1);
+
+    // Todo: Some of thest tests may need to be changed after
+    // https://github.com/apache/accumulo/issues/3798 is completed
+
+    // Infinite range fence
+    // Should just be first/last keys of file
+    assertReader(trf, new Range(), (reader) -> {
+      assertEquals(firstKeyInFile, reader.getFirstKey());
+      assertEquals(lastKeyInFile, reader.getLastKey());
+    });
+
+    // Range inside of file so should return the keys of the fence
+    assertReader(trf, new Range("r_000001", "r_000002"), (reader) -> {
+      assertEquals(new Key("r_000001"), reader.getFirstKey());
+      assertEquals(new Key("r_000002"), reader.getLastKey());
+    });
+
+    // Test infinite start key
+    assertReader(trf, new Range(null, "r_000001"), (reader) -> {
+      assertEquals(firstKeyInFile, reader.getFirstKey());
+      assertEquals(new Key("r_000001"), reader.getLastKey());
+    });
+
+    // Test infinite end key
+    assertReader(trf, new Range("r_000002", null), (reader) -> {
+      assertEquals(new Key("r_000002"), reader.getFirstKey());
+      assertEquals(lastKeyInFile, reader.getLastKey());
+    });
+
+    // Test start key matches start of file
+    assertReader(trf, new Range("r_000000", "r_000002"), (reader) -> {
+      // start row of range matches first key in file so that should be 
returned instead
+      assertEquals(firstKeyInFile, reader.getFirstKey());
+      assertEquals(new Key("r_000002"), reader.getLastKey());
+    });
+
+    // Test end key matches end of file
+    assertReader(trf, new Range("r_000001", "r_000003"), (reader) -> {
+      assertEquals(new Key("r_000001"), reader.getFirstKey());
+      // end row of range matches last key in file so that should be returned 
instead
+      assertEquals(lastKeyInFile, reader.getLastKey());
+    });
+

Review Comment:
   ```suggestion
       // Test case where rows in range are less than and greater than keys
       assertReader(trf, new Range("a", "z"), (reader) -> {
         assertEquals(firstKeyInFile, reader.getFirstKey());
         assertEquals(lastKeyInFile, reader.getLastKey());
       });
   ```



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

Reply via email to