wgtmac commented on code in PR #3262:
URL: https://github.com/apache/parquet-java/pull/3262#discussion_r2292567404
##########
parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ParquetFileReader.java:
##########
@@ -943,6 +965,51 @@ public ParquetFileReader(InputFile file,
ParquetReadOptions options, SeekableInp
f.close();
throw e;
}
+
+ this.fileMetaData = footer.getFileMetaData();
Review Comment:
Can't we simply write this:
```java
public ParquetFileReader(InputFile file, ParquetReadOptions options,
SeekableInputStream f) throws IOException {
this(file, readFooter(file, options, f, /*closeStreamOnFailure=*/true),
options, f);
}
```
To keep the same behavior, we also need to modify readFooter to close the
stream once failed:
```java
public static final ParquetMetadata readFooter(InputFile file,
ParquetReadOptions options, SeekableInputStream f, boolean closeStreamOnFailure)
throws IOException {
ParquetMetadataConverter converter = new
ParquetMetadataConverter(options);
try {
return readFooter(file, options, f, converter);
} catch (Exception e) {
// In case that readFooter throws an exception in the constructor, the
new stream
// should be closed. Otherwise, there's no way to close this outside.
if (closeStreamOnFailure) {
f.close();
}
throw e;
}
}
```
--
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]