-
Notifications
You must be signed in to change notification settings - Fork 1.5k
GH-3141: Add constructor to ParquetFileReader to allow passing in parquet footer #3165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
69b63ca
Add a constructor to allow passing in footer for InputFiles
yuzhu 3d82937
Add constructor
yuzhu f1b9b01
Address comment and add javadoc
yuzhu 56197e3
Resolve conflict
yuzhu cce9f1f
Reformat
yuzhu 0e88c9d
Address comment
yuzhu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -729,6 +729,21 @@ public static ParquetFileReader open(InputFile file, ParquetReadOptions options, | |
| return new ParquetFileReader(file, options, f); | ||
| } | ||
|
|
||
| /** | ||
| * Open a {@link InputFile file} with {@link ParquetMetadata footer} and {@link ParquetReadOptions options}. | ||
| * | ||
| * @param file an input file | ||
| * @param footer a {@link ParquetMetadata} footer already read from the file | ||
| * @param options parquet read options | ||
| * @param f the input stream for the file | ||
| * @return an open ParquetFileReader | ||
| * @throws IOException if there is an error while opening the file | ||
| */ | ||
| public static ParquetFileReader open(InputFile file, ParquetMetadata footer, ParquetReadOptions options, SeekableInputStream f) | ||
| throws IOException { | ||
| return new ParquetFileReader(file, footer, options, f); | ||
| } | ||
|
|
||
| protected SeekableInputStream f; | ||
| private final InputFile file; | ||
| private final ParquetReadOptions options; | ||
|
|
@@ -930,6 +945,12 @@ public ParquetFileReader(InputFile file, ParquetReadOptions options) throws IOEx | |
| this(file, options, file.newStream()); | ||
| } | ||
|
|
||
| /** | ||
| * @param file Path to a parquet file | ||
| * @param options {@link ParquetReadOptions} | ||
| * @param f a {@link SeekableInputStream} for the parquet file | ||
| * @throws IOException if the file can not be opened | ||
| */ | ||
| public ParquetFileReader(InputFile file, ParquetReadOptions options, SeekableInputStream f) throws IOException { | ||
| this.converter = new ParquetMetadataConverter(options); | ||
| this.file = file; | ||
|
|
@@ -943,6 +964,51 @@ public ParquetFileReader(InputFile file, ParquetReadOptions options, SeekableInp | |
| f.close(); | ||
| throw e; | ||
| } | ||
|
|
||
| this.fileMetaData = footer.getFileMetaData(); | ||
| this.fileDecryptor = fileMetaData.getFileDecryptor(); // must be called before filterRowGroups! | ||
| if (null != fileDecryptor && fileDecryptor.plaintextFile()) { | ||
| this.fileDecryptor = null; // Plaintext file. No need in decryptor | ||
| } | ||
|
|
||
| try { | ||
| this.blocks = filterRowGroups(footer.getBlocks()); | ||
| } catch (Exception e) { | ||
| // In case that filterRowGroups throws an exception in the constructor, the new stream | ||
| // should be closed. Otherwise, there's no way to close this outside. | ||
| f.close(); | ||
| throw e; | ||
| } | ||
| this.blockIndexStores = listWithNulls(this.blocks.size()); | ||
| this.blockRowRanges = listWithNulls(this.blocks.size()); | ||
| for (ColumnDescriptor col : footer.getFileMetaData().getSchema().getColumns()) { | ||
| paths.put(ColumnPath.get(col.getPath()), col); | ||
| } | ||
|
|
||
| if (options.usePageChecksumVerification()) { | ||
| this.crc = new CRC32(); | ||
| this.crcAllocator = ReusingByteBufferAllocator.strict(options.getAllocator()); | ||
| } else { | ||
| this.crc = null; | ||
| this.crcAllocator = null; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @param file Path to a parquet file | ||
| * @param footer a {@link ParquetMetadata} footer already read from the file | ||
| * @param options {@link ParquetReadOptions} | ||
| * @param f a {@link SeekableInputStream} for the parquet file | ||
| * @throws IOException if the file can not be opened | ||
| */ | ||
| public ParquetFileReader(InputFile file, ParquetMetadata footer, ParquetReadOptions options, SeekableInputStream f) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add a javadoc for this new method?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add the corresponding |
||
| throws IOException { | ||
| this.converter = new ParquetMetadataConverter(options); | ||
| this.file = file; | ||
| this.f = f; | ||
| this.options = options; | ||
| this.footer = footer; | ||
|
|
||
| this.fileMetaData = footer.getFileMetaData(); | ||
| this.fileDecryptor = fileMetaData.getFileDecryptor(); // must be called before filterRowGroups! | ||
| if (null != fileDecryptor && fileDecryptor.plaintextFile()) { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep its original comment