You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2021/09/14 08:57:26 UTC

[GitHub] [ozone] adoroszlai commented on a change in pull request #2572: HDDS-5435 Reduce usage of OmKeyLocationInfoGroup.getLocationList()

adoroszlai commented on a change in pull request #2572:
URL: https://github.com/apache/ozone/pull/2572#discussion_r708059557



##########
File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/s3/multipart/S3MultipartUploadCompleteRequest.java
##########
@@ -472,8 +472,10 @@ private long getMultipartDataSize(String requestedVolume,
           .getKeyLocationVersions().get(0);
 
       // Set partNumber in each block.
-      currentKeyInfoGroup.getLocationList().forEach(
-          omKeyLocationInfo -> omKeyLocationInfo.setPartNumber(partNumber));
+      currentKeyInfoGroup.getLocationLists().stream()
+          .flatMap(List::stream)
+          .forEach(omKeyLocationInfo ->
+              omKeyLocationInfo.setPartNumber(partNumber));
 
       partLocationInfos.addAll(currentKeyInfoGroup.getLocationList());

Review comment:
       There is another call to `getLocationList` here.  If we keep it, might as well store the list and reuse it for setting part number, too.

##########
File path: hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/KeyInputStream.java
##########
@@ -167,8 +167,9 @@ private synchronized void initialize(OmKeyInfo keyInfo,
             BlockID blockID = keyLocationInfo.getBlockID();
             List<OmKeyLocationInfo> collect =
                 newKeyInfo.getLatestVersionLocations()
-                .getLocationList()
+                .getLocationLists()
                 .stream()
+                .flatMap(List::stream)
                 .filter(l -> l.getBlockID().equals(blockID))
                 .collect(Collectors.toList());

Review comment:
       Since we only use the first matching location (`collect.get(0)`), this could be further optimized by using `findFirst()` instead of `collect()`:
   
   ```
               return newKeyInfo.getLatestVersionLocations()
                   .getLocationLists()
                   .stream()
                   .flatMap(List::stream)
                   .filter(l -> l.getBlockID().equals(blockID))
                   .findFirst()
                   .map(OmKeyLocationInfo::getPipeline)
                   .orElse(null);
   ```




-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org