Conversation
Signed-off-by: 1fanwang <[email protected]>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Rationale for this change
Reading the writer's size after successfully closing a Parquet file throws a null-pointer exception because its column buffers have already been released. Callers cannot report the completed file size through the writer.
Closes #2037.
What changes are included in this PR?
Save the final byte position after writing the footer, before closing the output stream. The size accessor then uses that position without accessing released buffers or a closed channel.
Are these changes tested?
Testing Done
On Java 17, this standalone program writes one row, closes the file, and compares the reported size with the real file length.
Before, on 2df8d02:
After:
Run the following from the base checkout and the PR checkout, saving the source below after the build:
mvn -q -pl parquet-hadoop -am -DskipTests package dependency:build-classpath -Dmdep.outputFile=target/runtime-classpath java -cp "parquet-common/target/classes:parquet-hadoop/target/classes:$(cat parquet-hadoop/target/runtime-classpath)" WriterSizeProbe.java size.parquetReproducer source
Save as WriterSizeProbe.java:
The regressions also read back empty, single-row and multiple-row-group files through both local and FileChannel-backed outputs, including a second close.
Are there any user-facing changes?
After a successful close, the size accessor returns the completed file size, including the footer. Its behavior while the writer is open is unchanged.