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


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/FileSizeCountTask.java:
##########
@@ -233,20 +272,25 @@ private void writeCountsToDB(boolean isDbTruncated,
         FileCountBySize fileCountRecord =
             fileCountBySizeDao.findById(recordToFind);
         if (fileCountRecord == null && newRecord.getCount() > 0L) {
-          // insert new row only for non-zero counts.
+          // Insert new row only for non-zero counts.
           insertToDb.add(newRecord);
         } else if (fileCountRecord != null) {
-          newRecord.setCount(fileCountRecord.getCount() +
-              fileSizeCountMap.get(key));
+          newRecord.setCount(fileCountRecord.getCount() + count);
           updateInDb.add(newRecord);
         }
       } else if (newRecord.getCount() > 0) {
-        // insert new row only for non-zero counts.
+        // Insert new row only for non-zero counts.
         insertToDb.add(newRecord);
       }
     });
-    fileCountBySizeDao.insert(insertToDb);
-    fileCountBySizeDao.update(updateInDb);
+
+    // Perform batch inserts and updates
+    if (!insertToDb.isEmpty()) {

Review Comment:
   This `if` check is redundant.



##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/FileSizeCountTask.java:
##########
@@ -233,20 +272,25 @@ private void writeCountsToDB(boolean isDbTruncated,
         FileCountBySize fileCountRecord =
             fileCountBySizeDao.findById(recordToFind);
         if (fileCountRecord == null && newRecord.getCount() > 0L) {
-          // insert new row only for non-zero counts.
+          // Insert new row only for non-zero counts.
           insertToDb.add(newRecord);
         } else if (fileCountRecord != null) {
-          newRecord.setCount(fileCountRecord.getCount() +
-              fileSizeCountMap.get(key));
+          newRecord.setCount(fileCountRecord.getCount() + count);
           updateInDb.add(newRecord);
         }
       } else if (newRecord.getCount() > 0) {
-        // insert new row only for non-zero counts.
+        // Insert new row only for non-zero counts.
         insertToDb.add(newRecord);
       }
     });
-    fileCountBySizeDao.insert(insertToDb);
-    fileCountBySizeDao.update(updateInDb);
+
+    // Perform batch inserts and updates
+    if (!insertToDb.isEmpty()) {
+      fileCountBySizeDao.insert(insertToDb);
+    }
+    if (!updateInDb.isEmpty()) {

Review Comment:
   This `if` check is redundant.



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