dombizita commented on code in PR #5159:
URL: https://github.com/apache/ozone/pull/5159#discussion_r1302953206


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/OMDBInsightEndpoint.java:
##########
@@ -520,6 +528,49 @@ private void getPendingForDeletionDirInfo(
     }
   }
 
+  /**
+   * Fetches the size of a deleted directory identified by the given path.
+   * The size is obtained from the NSSummary table using the directory 
objectID.
+   * The path is expected to be in the format :-
+   * "/volumeId/bucketId/parentId/dirName/dirObjectId".
+   *
+   * @param path The path of the deleted directory.
+   * @return The size of the deleted directory.
+   * @throws IOException If an I/O error occurs while retrieving the size.
+   */
+  public long fetchSizeForDeletedDirectory(String path)
+      throws IOException {
+    if (Strings.isNullOrEmpty(path)) {
+      LOG.error("Invalid path: Path is null or empty");
+      return 0L;
+    }
+
+    String[] parts = path.split("/");
+    if (parts.length != 6) {
+      LOG.error("Invalid path format: {}", path);
+      return 0L;
+    }
+    /* DB key in DeletedDirectoryTable =>
+                      "/volumeId/bucketId/parentId/dirName/dirObjectId" */
+    String directoryObjectId = parts[5];
+
+    try {
+      long convertedValue = Long.parseLong(directoryObjectId);
+      NSSummary nsSummary =
+          reconNamespaceSummaryManager.getNSSummary(convertedValue);
+      if (nsSummary != null) {
+        return nsSummary.getSizeOfFiles();

Review Comment:
   @sumitagrawl is correct. just an idea: if you go through all the 
sub-directories and further recursively to get the correct size, wouldn't that 
be a bit too much to calculate here for each deleted directory? 



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