varun-lakhyani commented on code in PR #17284:
URL: https://github.com/apache/iceberg/pull/17284#discussion_r3885513900


##########
core/src/main/java/org/apache/iceberg/io/EagerInputFile.java:
##########
@@ -60,12 +72,40 @@ public boolean exists() {
 
   @Override
   public SeekableInputStream newStream() {
-    byte[] bytes = new byte[(int) fileSize];
+    byte[] bytes = new byte[(int) length];
     try (SeekableInputStream src = delegate.newStream()) {
       IOUtil.readFully(src, bytes, 0, bytes.length);

Review Comment:
   
https://github.com/apache/iceberg/blob/b17b679d22cc8e65bd4cf8a18e93e39d89613a86/core/src/main/java/org/apache/iceberg/io/EagerInputFile.java#L77-L81
   If this seems good, I would want to replace this with readFullyExpectingEof 
and add it to IOUtil.
   it will look like this in IOUtil:
   ```java
   static void readFullyExpectingEof(InputStream stream, byte[] bytes, int 
offset, int length)
       throws IOException {
     readFully(stream, bytes, offset, length);
     if (stream.read() != -1) {
       throw new IOException("Did not reach the end of stream after reading " + 
length + " bytes");
     }
   }
   ```
   IOUtil seems a suitable place for this logic, as it is verifying the EOF 
after reading which is independent of Eager logic. Would you prefer this, or 
keep it inline here?



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