chihsuan commented on code in PR #10879:
URL: https://github.com/apache/ozone/pull/10879#discussion_r3664711202


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/spi/impl/ReconDBProvider.java:
##########
@@ -111,16 +110,22 @@ public DBStore getDbStore() {
     return dbStore;
   }
 
-  static void truncateTable(Table table) throws IOException {
+  static <K> void truncateTable(Table<K, ?> table) throws IOException {
     if (table == null) {
       return;
     }
-    try (TableIterator<Object, Table.KeyValue<Object, Object>> tableIterator = 
table.iterator()) {
-      while (tableIterator.hasNext()) {
-        KeyValue<Object, Object> entry = tableIterator.next();
-        table.delete(entry.getKey());
+    final K firstKey;
+    final K lastKey;
+    try (TableIterator<K, K> keyIterator = table.keyIterator()) {
+      if (!keyIterator.hasNext()) {
+        return;
       }
+      firstKey = keyIterator.next();
+      keyIterator.seekToLast();
+      lastKey = keyIterator.next();
     }
+    table.deleteRange(firstKey, lastKey);
+    table.delete(lastKey);

Review Comment:
   Thanks for the sketch! will move it into `Table` as `clear()` with the 
`deleteRange` overload.



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