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


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/OmTableInsightTask.java:
##########
@@ -179,6 +200,40 @@ private Triple<Long, Long, Long> getTableSizeAndCount(
     return Triple.of(count, unReplicatedSize, replicatedSize);
   }
 
+  /**
+   * 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 (path == null || path.isEmpty()) {
+      return 0L;
+    }
+    String[] parts = path.split("/");
+    String directoryObjectId = parts.length >= 6 ? parts[5] : "";

Review Comment:
   My appologies for the mistake, I forgot to add a slash `"/"` at the starting 
of the path given in comment 
   The fetchSizeForDeletedDirectory method is used to fetch the size of a 
deleted directory based on its path. The path is expected to be in the format: 
`"/volumeId/bucketId/parentId/dirName/dirObjectId"`.
   
   Here's a breakdown of how the method works:
   
   1. The method first checks if the provided path is null or empty. If it is, 
an error is logged, and the method returns a size of 0.
   
   2. The path is then split using the `"/"` delimiter. The resulting array, 
`parts`, will contain the individual components of the path. For example, if 
the path is `"/volumeId/bucketId/parentId/dirName/dirObjectId"`, the parts 
array will be **_`["", "volumeId", "bucketId", "parentId", "dirName", 
"objectId"]`_**.
   
   3. The method checks if the parts array has at least 6 elements. If it 
doesn't, it indicates an invalid path format, and an error is logged. The 
method returns a size of 0 in this case.
   
   4. The directory object ID is extracted from the parts array. In the example 
path, the directory object ID would be "`objectId`" `(parts[5])`.
   
   5. The directory object ID is parsed as a long value. If parsing is 
successful, the method retrieves the corresponding NSSummary object from the 
nsSummaryTable using the directory object ID as the key.
   
   6. If an NSSummary object is found, the method returns the size of the 
deleted directory obtained from the NSSummary object using the getSizeOfFiles() 
method.
   
   7. If no NSSummary object is found, an error is logged indicating that the 
NSSummary was not found for the directory.
   
   If any error occurs during the process, the method returns a size of 0.



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