elek commented on a change in pull request #2051:
URL: https://github.com/apache/ozone/pull/2051#discussion_r620079781



##########
File path: 
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java
##########
@@ -858,9 +859,17 @@ public OzoneKeyDetails getKeyDetails(
     OmKeyInfo keyInfo = ozoneManagerClient.lookupKey(keyArgs);
 
     List<OzoneKeyLocation> ozoneKeyLocations = new ArrayList<>();
-    keyInfo.getLatestVersionLocations().getBlocksLatestVersionOnly().forEach(
-        (a) -> ozoneKeyLocations.add(new OzoneKeyLocation(a.getContainerID(),
-            a.getLocalID(), a.getLength(), a.getOffset())));
+    long lastKeyOffset = 0L;
+    long lastLength = 0L;
+    List<OmKeyLocationInfo> omKeyLocationInfos = keyInfo
+        .getLatestVersionLocations().getBlocksLatestVersionOnly();
+    for (OmKeyLocationInfo info: omKeyLocationInfos) {
+      ozoneKeyLocations.add(new OzoneKeyLocation(info.getContainerID(),
+          info.getLocalID(), info.getLength(), info.getOffset(),
+          lastKeyOffset + lastLength));
+      lastKeyOffset = lastLength + lastKeyOffset;
+      lastLength = info.getLength();
+    }

Review comment:
       Fix me if I am wrong, but based on my understanding the variable usage 
can be simplified in this way:
   
   ```suggestion
       long lastKeyOffset = 0L;
       List<OmKeyLocationInfo> omKeyLocationInfos = keyInfo
           .getLatestVersionLocations().getBlocksLatestVersionOnly();
       for (OmKeyLocationInfo info: omKeyLocationInfos) {
         ozoneKeyLocations.add(new OzoneKeyLocation(info.getContainerID(),
             info.getLocalID(), info.getLength(), info.getOffset(),
             lastKeyOffset));
         lastKeyOffset += info.getLength();
       }
   ```




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

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