Skip to content

Commit 6d7c75f

Browse files
committed
Address comment and add javadoc
1 parent 1efc030 commit 6d7c75f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,21 @@ public static ParquetFileReader open(InputFile file, ParquetReadOptions options,
724724
return new ParquetFileReader(file, options, f);
725725
}
726726

727+
/**
728+
* Open a {@link InputFile file} with {@link ParquetMetadata footer} and {@link ParquetReadOptions options}.
729+
*
730+
* @param file an input file
731+
* @param footer a {@link ParquetMetadata} footer already read from the file
732+
* @param options parquet read options
733+
* @param f the input stream for the file
734+
* @return an open ParquetFileReader
735+
* @throws IOException if there is an error while opening the file
736+
*/
737+
public static ParquetFileReader open(InputFile file, ParquetMetadata footer, ParquetReadOptions options, SeekableInputStream f)
738+
throws IOException {
739+
return new ParquetFileReader(file, footer, options, f);
740+
}
741+
727742
protected final SeekableInputStream f;
728743
private final InputFile file;
729744
private final ParquetReadOptions options;
@@ -925,6 +940,12 @@ public ParquetFileReader(InputFile file, ParquetReadOptions options) throws IOEx
925940
this(file, options, file.newStream());
926941
}
927942

943+
/**
944+
* @param file Path to a parquet file
945+
* @param options {@link ParquetReadOptions}
946+
* @param f a {@link SeekableInputStream} for the parquet file
947+
* @throws IOException if the file can not be opened
948+
*/
928949
public ParquetFileReader(InputFile file, ParquetReadOptions options, SeekableInputStream f) throws IOException {
929950
this.converter = new ParquetMetadataConverter(options);
930951
this.file = file;
@@ -933,6 +954,8 @@ public ParquetFileReader(InputFile file, ParquetReadOptions options, SeekableInp
933954
try {
934955
this.footer = readFooter(file, options, f, converter);
935956
} catch (IOException e) {
957+
// In case that reading footer throws an exception in the constructor, the new stream
958+
// should be closed. Otherwise, there's no way to close this outside.
936959
f.close();
937960
throw e;
938961
}
@@ -966,6 +989,13 @@ public ParquetFileReader(InputFile file, ParquetReadOptions options, SeekableInp
966989
}
967990
}
968991

992+
/**
993+
* @param file Path to a parquet file
994+
* @param footer a {@link ParquetMetadata} footer already read from the file
995+
* @param options {@link ParquetReadOptions}
996+
* @param f a {@link SeekableInputStream} for the parquet file
997+
* @throws IOException if the file can not be opened
998+
*/
969999
public ParquetFileReader(InputFile file, ParquetMetadata footer, ParquetReadOptions options, SeekableInputStream f)
9701000
throws IOException {
9711001
this.converter = new ParquetMetadataConverter(options);

0 commit comments

Comments
 (0)