ChenSammi commented on code in PR #6273:
URL: https://github.com/apache/ozone/pull/6273#discussion_r1503676829


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyRequest.java:
##########
@@ -953,6 +965,27 @@ protected OmKeyInfo wrapUncommittedBlocksAsPseudoKey(
     return pseudoKeyInfo;
   }
 
+  /**
+   * Updates the metadata of an OmKeyInfo object with new metadata.
+   *
+   * @param dbKeyInfo   The existing OmKeyInfo object whose metadata is to be 
updated.
+   * @param newMetadata The new metadata map to update the existing metadata 
with.
+   */
+  protected void updateMetadata(OmKeyInfo dbKeyInfo,
+                                Map<String, String> newMetadata) {
+    if (dbKeyInfo == null || newMetadata == null || newMetadata.isEmpty()) {
+      return;
+    }
+    Map<String, String> existingMetadata = dbKeyInfo.getMetadata();
+    // Update existing metadata with new entries or values from newMetadata
+    for (Map.Entry<String, String> entry : newMetadata.entrySet()) {
+      String key = entry.getKey();
+      String value = entry.getValue();
+      // Update or add new metadata entry
+      existingMetadata.put(key, value);

Review Comment:
   Since the key is overwritten, we shall clear the old metadata, replace it 
with new metadata, not adding the news and keeps the old.



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