ArafatKhan2198 commented on code in PR #8002:
URL: https://github.com/apache/ozone/pull/8002#discussion_r1980497871


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/spi/impl/ReconDBProvider.java:
##########
@@ -83,11 +83,16 @@ static void truncateTable(Table table) throws IOException {
     if (table == null) {
       return;
     }
-    try (TableIterator<Object, ? extends KeyValue<Object, Object>>
-            tableIterator = table.iterator()) {
-      while (tableIterator.hasNext()) {
-        KeyValue<Object, Object> entry = tableIterator.next();
-        table.delete(entry.getKey());
+    try (TableIterator<Object, ? extends KeyValue<Object, Object>> iterator = 
table.iterator()) {
+      if (iterator.hasNext()) {
+        Object firstKey = iterator.next().getKey();
+        Object lastKey = null;
+        while (iterator.hasNext()) {
+          lastKey = iterator.next().getKey();
+        }
+        if (lastKey != null) {
+          table.deleteRange(firstKey, lastKey);  // Efficient bulk deletion

Review Comment:
   Will take care of it in a separate PR for now, after digging into the code a 
little bit.



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