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


##########
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:
   We should consider implementing `dropColumnFamily` a more performative API 
call on rocks DB column families compared to `deleteRange` when we want to 
truncate the whole table data.



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