devabhishekpal commented on code in PR #8568:
URL: https://github.com/apache/ozone/pull/8568#discussion_r2161055638
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/OMDBInsightEndpoint.java:
##########
@@ -635,17 +636,21 @@ private void getPendingForDeletionDirInfo(
* @return total used data size in bytes
* @throws IOException ioEx
*/
- protected long fetchSizeForDeletedDirectory(long objectId)
+ protected Pair<Long, Long> fetchSizeForDeletedDirectory(long objectId)
throws IOException {
NSSummary nsSummary = reconNamespaceSummaryManager.getNSSummary(objectId);
if (nsSummary == null) {
- return 0L;
+ return Pair.of(0L, 0L);
}
long totalSize = nsSummary.getSizeOfFiles();
+ long totalReplicatedSize = nsSummary.getReplicatedSizeOfFiles();
+
for (long childId : nsSummary.getChildDir()) {
- totalSize += fetchSizeForDeletedDirectory(childId);
+ Pair<Long, Long> childSize = fetchSizeForDeletedDirectory(childId);
+ totalSize += childSize.getLeft();
+ totalReplicatedSize += childSize.getRight();
}
Review Comment:
We can use a stream and simplify the summation.
```
Pair<Long, Long> totals = nsSummary.getChildDir().stream()
.map(this::fetchSizeForDeletedDirectory)
.reduce(
Pair.of(0L, 0L),
(acc, pair) -> Pair.of(acc.getLeft() + pair.getLeft(),
acc.getRight() + pair.getRight())
);
totalSize += totals.getLeft();
totalReplicatedSize += totals.getRight();
```
--
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]