rdblue commented on code in PR #4608:
URL: https://github.com/apache/iceberg/pull/4608#discussion_r856666294


##########
aws/src/main/java/org/apache/iceberg/aws/s3/S3InputStream.java:
##########
@@ -111,6 +114,19 @@ public int read(byte[] b, int off, int len) throws 
IOException {
     return bytesRead;
   }
 
+  @Override
+  public void readFully(long position, byte[] buffer, int offset, int length) {
+    GetObjectRequest.Builder requestBuilder = GetObjectRequest.builder()
+        .bucket(location.bucket())
+        .key(location.key())
+        .range(String.format("bytes=%s-%s", position, position + length));

Review Comment:
   I think this needs to use `position + length - 1`. From the RFC 2616 docs:
   
   ```
   Examples of byte-ranges-specifier values (assuming an entity-body of length 
10000):
   
         - The first 500 bytes (byte offsets 0-499, inclusive):  bytes=0-
           499
         - The second 500 bytes (byte offsets 500-999, inclusive):
           bytes=500-999
         - The final 500 bytes (byte offsets 9500-9999, inclusive):
           bytes=-500
         - Or bytes=9500-
         - The first and last bytes only (bytes 0 and 9999):  bytes=0-0,-1
         - Several legal but not canonical specifications of the second 500
           bytes (byte offsets 500-999, inclusive):
            bytes=500-600,601-999
            bytes=500-700,601-999
   ```
   
   For the first example, position=0 and length=500, this would request 
`bytes=0-500` instead of `bytes=0-499`.



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