tanvipenumudy commented on code in PR #5565:
URL: https://github.com/apache/ozone/pull/5565#discussion_r1396734315
##########
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java:
##########
@@ -1702,7 +1687,19 @@ public OzoneKeyDetails getS3KeyDetails(String
bucketName, String keyName,
partNumber)
.collect(Collectors.toList());
keyInfo.updateLocationInfoList(filteredKeyLocationInfo, false);
- return getOzoneKeyDetails(keyInfo, true);
+ keyInfo.setDataSize(getTotalBytesRead(keyInfo));
+ return getOzoneKeyDetails(keyInfo);
+ }
+
+ private long getTotalBytesRead(OmKeyInfo keyInfo) throws IOException {
+ OzoneInputStream keyContent = getInputStreamWithRetryFunction(keyInfo);
+ byte[] buffer = new byte[4096];
+ int bytesRead;
+ long totalBytesRead = 0;
+ while ((bytesRead = keyContent.read(buffer)) != -1) {
+ totalBytesRead += bytesRead;
+ }
+ return totalBytesRead;
Review Comment:
That's right, I was not able to see any existing way in which the
OmKeyInfo#dataSize could dynamically get updated based on the updated
`OmKeyLocationInfo` list.
I am open to suggestions if there is a better way to handle this!
##########
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java:
##########
@@ -1702,7 +1687,19 @@ public OzoneKeyDetails getS3KeyDetails(String
bucketName, String keyName,
partNumber)
.collect(Collectors.toList());
keyInfo.updateLocationInfoList(filteredKeyLocationInfo, false);
- return getOzoneKeyDetails(keyInfo, true);
+ keyInfo.setDataSize(getTotalBytesRead(keyInfo));
+ return getOzoneKeyDetails(keyInfo);
+ }
+
+ private long getTotalBytesRead(OmKeyInfo keyInfo) throws IOException {
+ OzoneInputStream keyContent = getInputStreamWithRetryFunction(keyInfo);
+ byte[] buffer = new byte[4096];
+ int bytesRead;
+ long totalBytesRead = 0;
+ while ((bytesRead = keyContent.read(buffer)) != -1) {
+ totalBytesRead += bytesRead;
+ }
+ return totalBytesRead;
Review Comment:
That's right, I was not able to see any existing way in which the
`OmKeyInfo#dataSize` could dynamically get updated based on the updated
`OmKeyLocationInfo` list.
I am open to suggestions if there is a better way to handle this!
--
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]