ArafatKhan2198 commented on code in PR #8797:
URL: https://github.com/apache/ozone/pull/8797#discussion_r2255965835
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/NSSummaryTaskDbEventHandler.java:
##########
@@ -199,4 +241,42 @@ protected boolean flushAndCommitNSToDB(Map<Long,
NSSummary> nsSummaryMap) {
}
return true;
}
+
+ /**
+ * Propagates size and count changes upwards through the parent chain.
+ * This ensures that when files are added/deleted, all ancestor directories
+ * reflect the total changes in their sizeOfFiles and numOfFiles fields.
+ */
+ protected void propagateSizeUpwards(long objectId, long sizeChange,
+ long countChange, Map<Long, NSSummary>
nsSummaryMap)
+ throws IOException {
+ // Get the current directory's NSSummary
+ NSSummary nsSummary = nsSummaryMap.get(objectId);
+ if (nsSummary == null) {
+ nsSummary = reconNamespaceSummaryManager.getNSSummary(objectId);
+ }
+ if (nsSummary == null) {
+ return; // No more parents to update
+ }
+
+ // Continue propagating to parent
+ long parentId = nsSummary.getParentId();
+ if (parentId != 0) {
Review Comment:
Made the changes!
Thanks!
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/NSSummaryTaskDbEventHandler.java:
##########
@@ -199,4 +241,42 @@ protected boolean flushAndCommitNSToDB(Map<Long,
NSSummary> nsSummaryMap) {
}
return true;
}
+
+ /**
+ * Propagates size and count changes upwards through the parent chain.
+ * This ensures that when files are added/deleted, all ancestor directories
+ * reflect the total changes in their sizeOfFiles and numOfFiles fields.
+ */
+ protected void propagateSizeUpwards(long objectId, long sizeChange,
+ long countChange, Map<Long, NSSummary>
nsSummaryMap)
+ throws IOException {
+ // Get the current directory's NSSummary
+ NSSummary nsSummary = nsSummaryMap.get(objectId);
+ if (nsSummary == null) {
+ nsSummary = reconNamespaceSummaryManager.getNSSummary(objectId);
+ }
+ if (nsSummary == null) {
+ return; // No more parents to update
+ }
+
+ // Continue propagating to parent
+ long parentId = nsSummary.getParentId();
+ if (parentId != 0) {
+ // Get parent's NSSummary
+ NSSummary parentSummary = nsSummaryMap.get(parentId);
+ if (parentSummary == null) {
+ parentSummary = reconNamespaceSummaryManager.getNSSummary(parentId);
+ }
+ if (parentSummary != null) {
+ // Update parent's totals
+ parentSummary.setSizeOfFiles(parentSummary.getSizeOfFiles() +
sizeChange);
+ parentSummary.setNumOfFiles(parentSummary.getNumOfFiles() +
(int)countChange);
Review Comment:
Made the changes!
Thanks!
--
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]