-
Notifications
You must be signed in to change notification settings - Fork 3k
Core: Use avro compression properties from table properties while writing Manifest and Manifest list files. #5893
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
sumeetgajjar
wants to merge
5
commits into
apache:master
from
sumeetgajjar:avro_manifest_file_configs
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bdf9d24
Respect avro compression properties for manifest files
sumeetgajjar e4d9485
Fix spotless java check
sumeetgajjar 4790f81
Fix stylecheck errors
sumeetgajjar 288458b
Explicitly pass compression codec and compression level instead of ge…
sumeetgajjar 93a3866
Incorporate second round of feedback
sumeetgajjar 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
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
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
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
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 |
|---|---|---|
|
|
@@ -31,14 +31,18 @@ | |
| abstract class ManifestListWriter implements FileAppender<ManifestFile> { | ||
| private final FileAppender<ManifestFile> writer; | ||
|
|
||
| private ManifestListWriter(OutputFile file, Map<String, String> meta) { | ||
| this.writer = newAppender(file, meta); | ||
| private ManifestListWriter( | ||
| OutputFile file, | ||
| Map<String, String> meta, | ||
| String compressionCodec, | ||
| Integer compressionLevel) { | ||
| this.writer = newAppender(file, meta, compressionCodec, compressionLevel); | ||
| } | ||
|
|
||
| protected abstract ManifestFile prepare(ManifestFile manifest); | ||
|
|
||
| protected abstract FileAppender<ManifestFile> newAppender( | ||
| OutputFile file, Map<String, String> meta); | ||
| OutputFile file, Map<String, String> meta, String compressionCodec, Integer compressionLevel); | ||
|
|
||
| @Override | ||
| public void add(ManifestFile manifest) { | ||
|
|
@@ -73,14 +77,22 @@ public long length() { | |
| static class V2Writer extends ManifestListWriter { | ||
| private final V2Metadata.IndexedManifestFile wrapper; | ||
|
|
||
| V2Writer(OutputFile snapshotFile, long snapshotId, Long parentSnapshotId, long sequenceNumber) { | ||
| V2Writer( | ||
| OutputFile snapshotFile, | ||
| long snapshotId, | ||
| Long parentSnapshotId, | ||
| long sequenceNumber, | ||
| String compressionCodec, | ||
| Integer compressionLevel) { | ||
| super( | ||
| snapshotFile, | ||
| ImmutableMap.of( | ||
| "snapshot-id", String.valueOf(snapshotId), | ||
| "parent-snapshot-id", String.valueOf(parentSnapshotId), | ||
| "sequence-number", String.valueOf(sequenceNumber), | ||
| "format-version", "2")); | ||
| "format-version", "2"), | ||
| compressionCodec, | ||
| compressionLevel); | ||
| this.wrapper = new V2Metadata.IndexedManifestFile(snapshotId, sequenceNumber); | ||
| } | ||
|
|
||
|
|
@@ -90,15 +102,25 @@ protected ManifestFile prepare(ManifestFile manifest) { | |
| } | ||
|
|
||
| @Override | ||
| protected FileAppender<ManifestFile> newAppender(OutputFile file, Map<String, String> meta) { | ||
| protected FileAppender<ManifestFile> newAppender( | ||
| OutputFile file, | ||
| Map<String, String> meta, | ||
| String compressionCodec, | ||
| Integer compressionLevel) { | ||
| try { | ||
| return Avro.write(file) | ||
| .schema(V2Metadata.MANIFEST_LIST_SCHEMA) | ||
| .named("manifest_file") | ||
| .meta(meta) | ||
| .overwrite() | ||
| .build(); | ||
|
|
||
| Avro.WriteBuilder builder = | ||
| Avro.write(file) | ||
| .schema(V2Metadata.MANIFEST_LIST_SCHEMA) | ||
| .named("manifest_file") | ||
| .meta(meta) | ||
| .overwrite(); | ||
| if (compressionCodec != null) { | ||
| builder.set(TableProperties.AVRO_COMPRESSION, compressionCodec); | ||
| } | ||
| if (compressionLevel != null) { | ||
| builder.set(TableProperties.AVRO_COMPRESSION_LEVEL, compressionLevel.toString()); | ||
| } | ||
| return builder.build(); | ||
| } catch (IOException e) { | ||
| throw new RuntimeIOException(e, "Failed to create snapshot list writer for path: %s", file); | ||
| } | ||
|
|
@@ -108,13 +130,20 @@ protected FileAppender<ManifestFile> newAppender(OutputFile file, Map<String, St | |
| static class V1Writer extends ManifestListWriter { | ||
| private final V1Metadata.IndexedManifestFile wrapper = new V1Metadata.IndexedManifestFile(); | ||
|
|
||
| V1Writer(OutputFile snapshotFile, long snapshotId, Long parentSnapshotId) { | ||
| V1Writer( | ||
| OutputFile snapshotFile, | ||
| long snapshotId, | ||
| Long parentSnapshotId, | ||
| String compressionCodec, | ||
| Integer compressionLevel) { | ||
| super( | ||
| snapshotFile, | ||
| ImmutableMap.of( | ||
| "snapshot-id", String.valueOf(snapshotId), | ||
| "parent-snapshot-id", String.valueOf(parentSnapshotId), | ||
| "format-version", "1")); | ||
| "format-version", "1"), | ||
| compressionCodec, | ||
| compressionLevel); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -126,15 +155,25 @@ protected ManifestFile prepare(ManifestFile manifest) { | |
| } | ||
|
|
||
| @Override | ||
| protected FileAppender<ManifestFile> newAppender(OutputFile file, Map<String, String> meta) { | ||
| protected FileAppender<ManifestFile> newAppender( | ||
| OutputFile file, | ||
| Map<String, String> meta, | ||
| String compressionCodec, | ||
| Integer compressionLevel) { | ||
| try { | ||
| return Avro.write(file) | ||
| .schema(V1Metadata.MANIFEST_LIST_SCHEMA) | ||
| .named("manifest_file") | ||
| .meta(meta) | ||
| .overwrite() | ||
| .build(); | ||
|
|
||
| Avro.WriteBuilder builder = | ||
| Avro.write(file) | ||
| .schema(V1Metadata.MANIFEST_LIST_SCHEMA) | ||
| .named("manifest_file") | ||
| .meta(meta) | ||
| .overwrite(); | ||
| if (compressionCodec != null) { | ||
| builder.set(TableProperties.AVRO_COMPRESSION, compressionCodec); | ||
| } | ||
| if (compressionLevel != null) { | ||
| builder.set(TableProperties.AVRO_COMPRESSION_LEVEL, compressionLevel.toString()); | ||
| } | ||
|
Comment on lines
+170
to
+175
Contributor
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. Nit: newline between blocks and the next statement |
||
| return builder.build(); | ||
| } catch (IOException e) { | ||
| throw new RuntimeIOException(e, "Failed to create snapshot list writer for path: %s", file); | ||
| } | ||
|
|
||
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.
is this used anywhere?
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.
It seems not and can be removed.