Repository navigation
Core, Spark 4.2: Refactor: Wire in InputFilesDecryptor into Spark readers #18486
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
base: main
Are you sure you want to change the base?
Changes from all commits
d3740b3
3d19f32
14b252d
d31e510
d0890af
840fab8
a292ef8
e3518f8
3626199
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,12 +22,13 @@ | |||||||||||||||||
| import java.util.Map; | ||||||||||||||||||
| import org.apache.iceberg.CombinedScanTask; | ||||||||||||||||||
| import org.apache.iceberg.ContentFile; | ||||||||||||||||||
| import org.apache.iceberg.DeleteFile; | ||||||||||||||||||
| import org.apache.iceberg.FileScanTask; | ||||||||||||||||||
| import org.apache.iceberg.ScanTask; | ||||||||||||||||||
| import org.apache.iceberg.io.FileIO; | ||||||||||||||||||
| import org.apache.iceberg.io.InputFile; | ||||||||||||||||||
| import org.apache.iceberg.relocated.com.google.common.base.Preconditions; | ||||||||||||||||||
| import org.apache.iceberg.relocated.com.google.common.collect.Maps; | ||||||||||||||||||
| import org.apache.iceberg.util.TableScanUtil; | ||||||||||||||||||
|
|
||||||||||||||||||
| /** Resolves the files referenced by scan tasks into readable, decrypted {@link InputFile}s. */ | ||||||||||||||||||
| public class InputFilesDecryptor { | ||||||||||||||||||
|
|
@@ -48,8 +49,14 @@ public InputFilesDecryptor( | |||||||||||||||||
| EncryptingFileIO.combine(io, encryption)); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * Returns a decryptor for the files referenced by the given tasks. | ||||||||||||||||||
| * | ||||||||||||||||||
| * <p>Resolution of referenced files are performed lazily on the first call of {@link | ||||||||||||||||||
| * #getInputFile(String)}. | ||||||||||||||||||
| */ | ||||||||||||||||||
| public static InputFilesDecryptor fromTasks( | ||||||||||||||||||
|
Collaborator
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 we add a short Javadoc here? An unsupported task only fails on the first
Suggested change
Contributor
Author
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. Ahh, I always forget to add the javadoc comment to this public method, thanks for pointing that out and for the suggestion. |
||||||||||||||||||
| Iterable<FileScanTask> tasks, EncryptingFileIO encryptingIO) { | ||||||||||||||||||
| Iterable<? extends ScanTask> tasks, EncryptingFileIO encryptingIO) { | ||||||||||||||||||
| return new InputFilesDecryptor(() -> referencedFiles(tasks).iterator(), encryptingIO); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
@@ -71,12 +78,11 @@ private Map<String, InputFile> inputFiles() { | |||||||||||||||||
| return lazyInputFiles; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| private static Collection<ContentFile<?>> referencedFiles(Iterable<FileScanTask> tasks) { | ||||||||||||||||||
| private static Collection<ContentFile<?>> referencedFiles(Iterable<? extends ScanTask> tasks) { | ||||||||||||||||||
| Map<String, ContentFile<?>> files = Maps.newHashMap(); | ||||||||||||||||||
| for (FileScanTask task : tasks) { | ||||||||||||||||||
| files.put(task.file().location(), task.file()); | ||||||||||||||||||
| for (DeleteFile delete : task.deletes()) { | ||||||||||||||||||
| files.put(delete.location(), delete); | ||||||||||||||||||
| for (ScanTask task : tasks) { | ||||||||||||||||||
|
gaborkaszab marked this conversation as resolved.
Resolved
|
||||||||||||||||||
| for (ContentFile<?> file : TableScanUtil.referencedFiles(task)) { | ||||||||||||||||||
| files.put(file.location(), file); | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
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.