pvary commented on code in PR #15241:
URL: https://github.com/apache/iceberg/pull/15241#discussion_r2773252750


##########
core/src/main/java/org/apache/iceberg/SnapshotFileChanges.java:
##########
@@ -0,0 +1,268 @@
+/*
+ * 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 java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Queue;
+import java.util.concurrent.ExecutorService;
+import org.apache.iceberg.exceptions.RuntimeIOException;
+import org.apache.iceberg.io.FileIO;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+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.Queues;
+import org.apache.iceberg.util.Tasks;
+
+/**
+ * Helper class for retrieving file changes in a snapshot with caching.
+ *
+ * <p>This class caches the results of file change detection operations, 
making it efficient to
+ * query multiple file change types for the same snapshot. By default, 
manifests are read
+ * sequentially. Use {@link Builder#executeWith(ExecutorService)} to enable 
parallel reading.
+ */
+public class SnapshotFileChanges {
+  private final Snapshot snapshot;
+  private final FileIO io;
+  private final Map<Integer, PartitionSpec> specsById;
+  private final ExecutorService executorService;
+
+  private List<DataFile> addedDataFiles = null;
+  private List<DataFile> removedDataFiles = null;
+  private List<DeleteFile> addedDeleteFiles = null;
+  private List<DeleteFile> removedDeleteFiles = null;
+
+  private SnapshotFileChanges(
+      Snapshot snapshot,
+      FileIO io,
+      Map<Integer, PartitionSpec> specsById,
+      ExecutorService executorService) {
+    Preconditions.checkArgument(snapshot != null, "Snapshot cannot be null");
+    Preconditions.checkArgument(io != null, "FileIO cannot be null");
+    Preconditions.checkArgument(specsById != null, "Partition specs cannot be 
null");
+    this.snapshot = snapshot;
+    this.io = io;
+    this.specsById = specsById;
+    this.executorService = executorService;
+  }
+
+  /**
+   * Create a builder for SnapshotFileChanges.
+   *
+   * @param snapshot the snapshot to detect file changes for
+   * @param io a {@link FileIO} instance used for reading files from storage
+   * @param specsById a map of partition spec IDs to partition specs
+   * @return a new Builder
+   */
+  public static Builder builder(
+      Snapshot snapshot, FileIO io, Map<Integer, PartitionSpec> specsById) {
+    return new Builder(snapshot, io, specsById);
+  }
+
+  /** Returns all data files added to the table in this snapshot */
+  public Iterable<DataFile> addedDataFiles() {
+    if (addedDataFiles == null) {
+      cacheDataFileChanges();
+    }
+    return addedDataFiles;

Review Comment:
   We need a prompt for the AIs to add newlines 🤖 



-- 
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]

Reply via email to