wzhero1 commented on code in PR #7027:
URL: https://github.com/apache/paimon/pull/7027#discussion_r3013706217


##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/expire/ExpireSnapshotsPlan.java:
##########
@@ -0,0 +1,230 @@
+/*
+ * 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.paimon.flink.expire;
+
+import org.apache.paimon.Snapshot;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The plan for snapshot expiration, containing four groups of tasks organized 
by deletion phase.
+ *
+ * <p>The plan organizes tasks into four groups for correct deletion order:
+ *
+ * <ul>
+ *   <li>{@link #dataFileTasks()}: Phase 1a - Delete data files (can be 
parallelized)
+ *   <li>{@link #changelogFileTasks()}: Phase 1b - Delete changelog files (can 
be parallelized)
+ *   <li>{@link #manifestTasks()}: Phase 2a - Delete manifest files (serial)
+ *   <li>{@link #snapshotFileTasks()}: Phase 2b - Delete snapshot metadata 
files (serial)
+ * </ul>
+ */
+public class ExpireSnapshotsPlan implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private static final ExpireSnapshotsPlan EMPTY =
+            new ExpireSnapshotsPlan(
+                    Collections.emptyList(),
+                    Collections.emptyList(),
+                    Collections.emptyList(),
+                    Collections.emptyList(),
+                    null,
+                    0,
+                    0,
+                    Collections.emptyMap());
+
+    private final List<SnapshotExpireTask> dataFileTasks;
+    private final List<SnapshotExpireTask> changelogFileTasks;
+    private final List<SnapshotExpireTask> manifestTasks;
+    private final List<SnapshotExpireTask> snapshotFileTasks;
+    private final ProtectionSet protectionSet;
+    private final long beginInclusiveId;
+    private final long endExclusiveId;
+
+    /** Pre-collected snapshot cache from planner to avoid redundant snapshot 
reads. */
+    private final Map<Long, Snapshot> snapshotCache;
+
+    public ExpireSnapshotsPlan(
+            List<SnapshotExpireTask> dataFileTasks,
+            List<SnapshotExpireTask> changelogFileTasks,
+            List<SnapshotExpireTask> manifestTasks,
+            List<SnapshotExpireTask> snapshotFileTasks,
+            ProtectionSet protectionSet,
+            long beginInclusiveId,
+            long endExclusiveId,
+            Map<Long, Snapshot> snapshotCache) {
+        this.dataFileTasks = dataFileTasks;
+        this.changelogFileTasks = changelogFileTasks;
+        this.manifestTasks = manifestTasks;
+        this.snapshotFileTasks = snapshotFileTasks;
+        this.protectionSet = protectionSet;
+        this.beginInclusiveId = beginInclusiveId;
+        this.endExclusiveId = endExclusiveId;
+        this.snapshotCache = snapshotCache;
+    }
+
+    public static ExpireSnapshotsPlan empty() {
+        return EMPTY;
+    }
+
+    public boolean isEmpty() {
+        return dataFileTasks.isEmpty()
+                && changelogFileTasks.isEmpty()
+                && manifestTasks.isEmpty()
+                && snapshotFileTasks.isEmpty();
+    }
+
+    /** Get data file deletion tasks (Phase 1a). These can be executed in 
parallel. */
+    public List<SnapshotExpireTask> dataFileTasks() {

Review Comment:
   Removed.



##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/expire/ExpireSnapshotsPlan.java:
##########
@@ -0,0 +1,230 @@
+/*
+ * 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.paimon.flink.expire;
+
+import org.apache.paimon.Snapshot;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The plan for snapshot expiration, containing four groups of tasks organized 
by deletion phase.
+ *
+ * <p>The plan organizes tasks into four groups for correct deletion order:
+ *
+ * <ul>
+ *   <li>{@link #dataFileTasks()}: Phase 1a - Delete data files (can be 
parallelized)
+ *   <li>{@link #changelogFileTasks()}: Phase 1b - Delete changelog files (can 
be parallelized)
+ *   <li>{@link #manifestTasks()}: Phase 2a - Delete manifest files (serial)
+ *   <li>{@link #snapshotFileTasks()}: Phase 2b - Delete snapshot metadata 
files (serial)
+ * </ul>
+ */
+public class ExpireSnapshotsPlan implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private static final ExpireSnapshotsPlan EMPTY =
+            new ExpireSnapshotsPlan(
+                    Collections.emptyList(),
+                    Collections.emptyList(),
+                    Collections.emptyList(),
+                    Collections.emptyList(),
+                    null,
+                    0,
+                    0,
+                    Collections.emptyMap());
+
+    private final List<SnapshotExpireTask> dataFileTasks;
+    private final List<SnapshotExpireTask> changelogFileTasks;
+    private final List<SnapshotExpireTask> manifestTasks;
+    private final List<SnapshotExpireTask> snapshotFileTasks;
+    private final ProtectionSet protectionSet;
+    private final long beginInclusiveId;
+    private final long endExclusiveId;
+
+    /** Pre-collected snapshot cache from planner to avoid redundant snapshot 
reads. */
+    private final Map<Long, Snapshot> snapshotCache;
+
+    public ExpireSnapshotsPlan(
+            List<SnapshotExpireTask> dataFileTasks,
+            List<SnapshotExpireTask> changelogFileTasks,
+            List<SnapshotExpireTask> manifestTasks,
+            List<SnapshotExpireTask> snapshotFileTasks,
+            ProtectionSet protectionSet,
+            long beginInclusiveId,
+            long endExclusiveId,
+            Map<Long, Snapshot> snapshotCache) {
+        this.dataFileTasks = dataFileTasks;
+        this.changelogFileTasks = changelogFileTasks;
+        this.manifestTasks = manifestTasks;
+        this.snapshotFileTasks = snapshotFileTasks;
+        this.protectionSet = protectionSet;
+        this.beginInclusiveId = beginInclusiveId;
+        this.endExclusiveId = endExclusiveId;
+        this.snapshotCache = snapshotCache;
+    }
+
+    public static ExpireSnapshotsPlan empty() {
+        return EMPTY;
+    }
+
+    public boolean isEmpty() {
+        return dataFileTasks.isEmpty()
+                && changelogFileTasks.isEmpty()
+                && manifestTasks.isEmpty()
+                && snapshotFileTasks.isEmpty();
+    }
+
+    /** Get data file deletion tasks (Phase 1a). These can be executed in 
parallel. */
+    public List<SnapshotExpireTask> dataFileTasks() {
+        return dataFileTasks;
+    }
+
+    /** Get changelog file deletion tasks (Phase 1b). These can be executed in 
parallel. */
+    public List<SnapshotExpireTask> changelogFileTasks() {

Review Comment:
   Removed.



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

Reply via email to