Skip to content

Commit 7228fb1

Browse files
committed
Add a constructor to allow passing in footer for InputFiles
1 parent 37a29d9 commit 7228fb1

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ParquetFileReader.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -926,18 +926,16 @@ public ParquetFileReader(InputFile file, ParquetReadOptions options) throws IOEx
926926
}
927927

928928
public ParquetFileReader(InputFile file, ParquetReadOptions options, SeekableInputStream f) throws IOException {
929+
this(file, readFooter(file, options, f, new ParquetMetadataConverter(options)), options, f);
930+
}
931+
932+
public ParquetFileReader(InputFile file, ParquetMetadata footer,ParquetReadOptions options, SeekableInputStream f) throws IOException {
929933
this.converter = new ParquetMetadataConverter(options);
930934
this.file = file;
931935
this.f = f;
932936
this.options = options;
933-
try {
934-
this.footer = readFooter(file, options, f, converter);
935-
} catch (Exception e) {
936-
// In case that reading footer throws an exception in the constructor, the new stream
937-
// should be closed. Otherwise, there's no way to close this outside.
938-
f.close();
939-
throw e;
940-
}
937+
this.footer = footer;
938+
941939
this.fileMetaData = footer.getFileMetaData();
942940
this.fileDecryptor = fileMetaData.getFileDecryptor(); // must be called before filterRowGroups!
943941
if (null != fileDecryptor && fileDecryptor.plaintextFile()) {

0 commit comments

Comments
 (0)