ivandika3 commented on code in PR #7558:
URL: https://github.com/apache/ozone/pull/7558#discussion_r1908268764


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java:
##########
@@ -509,6 +509,33 @@ private OmKeyInfo readKeyInfo(OmKeyArgs args, BucketLayout 
bucketLayout)
     if (args.getLatestVersionLocation()) {
       slimLocationVersion(value);
     }
+    int partNumberParam = args.getMultipartUploadPartNumber();
+    if (partNumberParam > 0) {
+      OmKeyLocationInfoGroup latestLocationVersion = 
value.getLatestVersionLocations();
+      if (latestLocationVersion != null && 
latestLocationVersion.isMultipartKey()) {
+        List<OmKeyLocationInfo> currentLocations =
+            
value.getKeyLocationVersions().get(value.getKeyLocationVersions().size() - 1)
+                .getLocationList()
+                .stream()
+                .filter(it -> it.getPartNumber() == partNumberParam)
+                .collect(Collectors.toList());
+
+        value.setKeyLocationVersions(
+            Collections.singletonList(
+                new OmKeyLocationInfoGroup(
+                    latestLocationVersion.getVersion(),
+                    currentLocations,
+                    true
+                )
+            )
+        );
+
+        long dataLength = currentLocations.stream()
+            .mapToLong(BlockLocationInfo::getLength)
+            .sum();
+        value.setDataSize(dataLength);

Review Comment:
   > It seems better to use 
value.updateLocationInfoList(filteredKeyLocationInfo, true, true) to avoid 
unnecessary calculations.
   
   Nice catch, the block ID check can be skipped since it's only used for key 
commit requests. 
   
   Could you also update the `RpcClient#getS3KeyDetails` to also use 
`updateLocationInfoList(filteredKeyLocationInfo, true, true)`? 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]

Reply via email to