@@ -926,10 +926,48 @@ 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 );
929+ this .converter = new ParquetMetadataConverter (options );
930+ this .file = file ;
931+ this .f = f ;
932+ this .options = options ;
933+ try {
934+ this .footer = readFooter (file , options , f , converter );
935+ } catch (IOException e ) {
936+ f .close ();
937+ throw e ;
938+ }
939+
940+ this .fileMetaData = footer .getFileMetaData ();
941+ this .fileDecryptor = fileMetaData .getFileDecryptor (); // must be called before filterRowGroups!
942+ if (null != fileDecryptor && fileDecryptor .plaintextFile ()) {
943+ this .fileDecryptor = null ; // Plaintext file. No need in decryptor
944+ }
945+
946+ try {
947+ this .blocks = filterRowGroups (footer .getBlocks ());
948+ } catch (Exception e ) {
949+ // In case that filterRowGroups throws an exception in the constructor, the new stream
950+ // should be closed. Otherwise, there's no way to close this outside.
951+ f .close ();
952+ throw e ;
953+ }
954+ this .blockIndexStores = listWithNulls (this .blocks .size ());
955+ this .blockRowRanges = listWithNulls (this .blocks .size ());
956+ for (ColumnDescriptor col : footer .getFileMetaData ().getSchema ().getColumns ()) {
957+ paths .put (ColumnPath .get (col .getPath ()), col );
958+ }
959+
960+ if (options .usePageChecksumVerification ()) {
961+ this .crc = new CRC32 ();
962+ this .crcAllocator = ReusingByteBufferAllocator .strict (options .getAllocator ());
963+ } else {
964+ this .crc = null ;
965+ this .crcAllocator = null ;
966+ }
930967 }
931968
932- public ParquetFileReader (InputFile file , ParquetMetadata footer ,ParquetReadOptions options , SeekableInputStream f ) throws IOException {
969+ public ParquetFileReader (InputFile file , ParquetMetadata footer , ParquetReadOptions options , SeekableInputStream f )
970+ throws IOException {
933971 this .converter = new ParquetMetadataConverter (options );
934972 this .file = file ;
935973 this .f = f ;
0 commit comments