diff --git a/core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java b/core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java index 1dcfa6d3d41d..6143a4ee9097 100644 --- a/core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java +++ b/core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java @@ -85,7 +85,7 @@ abstract class MergingSnapshotProducer extends SnapshotProducer { // update data private final List newDataFiles = Lists.newArrayList(); private Long newDataFilesDataSequenceNumber; - private final Map> newDeleteFilesBySpec = Maps.newHashMap(); + private final Map>> newDeleteFilesBySpec = Maps.newHashMap(); private final List appendManifests = Lists.newArrayList(); private final List rewrittenAppendManifests = Lists.newArrayList(); private final SnapshotSummary.Builder addedFilesSummary = SnapshotSummary.builder(); @@ -237,22 +237,22 @@ protected void add(DataFile file) { /** Add a delete file to the new snapshot. */ protected void add(DeleteFile file) { Preconditions.checkNotNull(file, "Invalid delete file: null"); - add(new DeleteFileHolder(file)); + addDelete(new FileHolder<>(file)); } /** Add a delete file to the new snapshot. */ protected void add(DeleteFile file, long dataSequenceNumber) { Preconditions.checkNotNull(file, "Invalid delete file: null"); - add(new DeleteFileHolder(file, dataSequenceNumber)); + addDelete(new FileHolder<>(file, dataSequenceNumber)); } - private void add(DeleteFileHolder fileHolder) { - int specId = fileHolder.deleteFile().specId(); + private void addDelete(FileHolder fileHolder) { + int specId = fileHolder.file().specId(); PartitionSpec fileSpec = ops.current().spec(specId); - List deleteFiles = + List> deleteFiles = newDeleteFilesBySpec.computeIfAbsent(specId, s -> Lists.newArrayList()); deleteFiles.add(fileHolder); - addedFilesSummary.addedFile(fileSpec, fileHolder.deleteFile()); + addedFilesSummary.addedFile(fileSpec, fileHolder.file()); hasNewDeleteFiles = true; } @@ -1006,9 +1006,9 @@ private List newDeleteFilesAsManifests() { deleteFiles.forEach( df -> { if (df.dataSequenceNumber() != null) { - writer.add(df.deleteFile(), df.dataSequenceNumber()); + writer.add(df.file(), df.dataSequenceNumber()); } else { - writer.add(df.deleteFile()); + writer.add(df.file()); } }); } finally { @@ -1132,33 +1132,33 @@ protected ManifestReader newManifestReader(ManifestFile manifest) { } } - private static class DeleteFileHolder { - private final DeleteFile deleteFile; + private static class FileHolder>{ + private final T file; private final Long dataSequenceNumber; /** * Wrap a delete file for commit with a given data sequence number * - * @param deleteFile delete file + * @param file content file * @param dataSequenceNumber data sequence number to apply */ - DeleteFileHolder(DeleteFile deleteFile, long dataSequenceNumber) { - this.deleteFile = deleteFile; + FileHolder(T file, long dataSequenceNumber) { + this.file = file; this.dataSequenceNumber = dataSequenceNumber; } /** * Wrap a delete file for commit with the latest sequence number * - * @param deleteFile delete file + * @param file the content fle */ - DeleteFileHolder(DeleteFile deleteFile) { - this.deleteFile = deleteFile; + FileHolder(T file) { + this.file = file; this.dataSequenceNumber = null; } - public DeleteFile deleteFile() { - return deleteFile; + public T file() { + return file; } public Long dataSequenceNumber() {