varun-lakhyani commented on code in PR #17284:
URL: https://github.com/apache/iceberg/pull/17284#discussion_r3897444994
##########
core/src/main/java/org/apache/iceberg/io/EagerInputFile.java:
##########
@@ -60,12 +72,44 @@ 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);
+ // reads from the already open stream; no additional request
+ if (src.read() != -1) {
+ throw new IOException("Did not reach the end of stream after reading "
+ length + " bytes");
+ }
} catch (IOException e) {
throw new RuntimeIOException(e, "Failed to fetch file: %s",
delegate.location());
}
return new EagerInputStream(bytes);
}
+
+ /** An {@link EagerInputFile} that preserves the delegate's Hadoop
configuration. */
+ private static class EagerInputFileConfigurable extends EagerInputFile
+ implements HadoopConfigurable {
+
+ private final HadoopConfigurable delegate;
+
+ EagerInputFileConfigurable(InputFile delegate, long length) {
+ super(delegate, length);
+ Preconditions.checkArgument(
+ delegate instanceof HadoopConfigurable,
+ "Cannot create a Hadoop configurable eager input file from %s",
Review Comment:
donw
##########
core/src/main/java/org/apache/iceberg/io/EagerInputFile.java:
##########
@@ -60,12 +72,44 @@ 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);
+ // reads from the already open stream; no additional request
+ if (src.read() != -1) {
+ throw new IOException("Did not reach the end of stream after reading "
+ length + " bytes");
Review Comment:
done
--
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]