rdblue commented on code in PR #19129: URL: https://github.com/apache/iceberg/pull/19129#discussion_r4807611781
########## core/src/main/java/org/apache/iceberg/ManifestListProducer.java: ########## @@ -0,0 +1,729 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.iceberg; + +import static org.apache.iceberg.TableProperties.MANIFEST_MIN_MERGE_COUNT; +import static org.apache.iceberg.TableProperties.MANIFEST_MIN_MERGE_COUNT_DEFAULT; +import static org.apache.iceberg.TableProperties.MANIFEST_TARGET_SIZE_BYTES; +import static org.apache.iceberg.TableProperties.MANIFEST_TARGET_SIZE_BYTES_DEFAULT; +import static org.apache.iceberg.TableProperties.SNAPSHOT_ID_INHERITANCE_ENABLED; +import static org.apache.iceberg.TableProperties.SNAPSHOT_ID_INHERITANCE_ENABLED_DEFAULT; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import org.apache.iceberg.encryption.EncryptedOutputFile; +import org.apache.iceberg.encryption.EncryptingFileIO; +import org.apache.iceberg.expressions.Expression; +import org.apache.iceberg.expressions.Expressions; +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.base.Predicate; +import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList; +import org.apache.iceberg.relocated.com.google.common.collect.Iterables; +import org.apache.iceberg.relocated.com.google.common.collect.Lists; +import org.apache.iceberg.relocated.com.google.common.collect.Maps; +import org.apache.iceberg.relocated.com.google.common.collect.Sets; +import org.apache.iceberg.relocated.com.google.common.collect.Streams; +import org.apache.iceberg.util.ContentFileUtil; +import org.apache.iceberg.util.DataFileSet; +import org.apache.iceberg.util.DeleteFileSet; +import org.apache.iceberg.util.SnapshotUtil; +import org.apache.iceberg.util.ThreadPools; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +class ManifestListProducer implements ProducerActions { + private static final Logger LOG = LoggerFactory.getLogger(ManifestListProducer.class); + + private final String tableName; + private final TableOperations ops; + private final FileIO io; + private final Map<Integer, PartitionSpec> specsById; + private final long snapshotId; + private final int formatVersion; + private final boolean canInheritSnapshotId; + private final ManifestWriteManager writeManager; + private final ManifestMergeManager<DataFile> mergeManager; + private final ManifestFilterManager<DataFile> filterManager; + private final ManifestMergeManager<DeleteFile> deleteMergeManager; + private final ManifestFilterManager<DeleteFile> deleteFilterManager; + private final AtomicInteger dvMergeAttempt = new AtomicInteger(0); + private Consumer<String> deleteFunc; + private ExecutorService workerPool = ThreadPools.getWorkerPool(); + + // update data + private final Map<Integer, DataFileSet> newDataFilesBySpec = Maps.newHashMap(); + private final List<DeleteFile> v2Deletes = Lists.newArrayList(); + private final Map<String, List<DeleteFile>> dvsByReferencedFile = Maps.newLinkedHashMap(); + private final List<ManifestFile> appendManifests = Lists.newArrayList(); + private final List<ManifestFile> rewrittenAppendManifests = Lists.newArrayList(); + private Expression deleteExpression = Expressions.alwaysFalse(); + + // cache new data manifests after writing + private final List<ManifestFile> cachedNewDataManifests = Lists.newLinkedList(); + private boolean hasNewDataFiles = false; + + // cache new manifests for delete files + private final List<ManifestFile> cachedNewDeleteManifests = Lists.newLinkedList(); + private boolean hasNewDeleteFiles = false; + + // operation results, set by apply + private List<DeleteFile> addedDeleteFiles = Lists.newArrayList(); + private int duplicateDeleteCount = 0; + private List<DataFile> deletedDataFiles = null; + private List<DataFile> missingDataFiles = null; + private List<String> missingDataLocations = null; + private List<DeleteFile> missingDeleteFiles = null; + private List<DeleteFile> deletedDeleteFiles = null; + + ManifestListProducer(String tableName, TableOperations ops, long snapshotId, int formatVersion) { + this.tableName = tableName; + this.ops = ops; + this.io = ops.io(); Review Comment: Yeah, I saw the test failures and updated it to use ops.io(). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
