This is an automated email from the ASF dual-hosted git repository.

lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new a0eeee0e1 [core] Rename findOverlappedSnapshots to findSkippingTags
a0eeee0e1 is described below

commit a0eeee0e11155390648450cc5102e845e799bdda
Author: Jingsong <[email protected]>
AuthorDate: Tue Oct 15 15:08:19 2024 +0800

    [core] Rename findOverlappedSnapshots to findSkippingTags
---
 .../apache/paimon/table/ExpireChangelogImpl.java    |  5 +++--
 .../apache/paimon/table/ExpireSnapshotsImpl.java    | 21 +++++++++++++++++++--
 .../org/apache/paimon/utils/SnapshotManager.java    | 19 +------------------
 3 files changed, 23 insertions(+), 22 deletions(-)

diff --git 
a/paimon-core/src/main/java/org/apache/paimon/table/ExpireChangelogImpl.java 
b/paimon-core/src/main/java/org/apache/paimon/table/ExpireChangelogImpl.java
index 246a85cbd..ce5497545 100644
--- a/paimon-core/src/main/java/org/apache/paimon/table/ExpireChangelogImpl.java
+++ b/paimon-core/src/main/java/org/apache/paimon/table/ExpireChangelogImpl.java
@@ -37,6 +37,8 @@ import java.util.List;
 import java.util.Set;
 import java.util.function.Predicate;
 
+import static org.apache.paimon.table.ExpireSnapshotsImpl.findSkippingTags;
+
 /** Cleanup the changelog in changelog directory. */
 public class ExpireChangelogImpl implements ExpireSnapshots {
 
@@ -137,8 +139,7 @@ public class ExpireChangelogImpl implements ExpireSnapshots 
{
         List<Snapshot> taggedSnapshots = tagManager.taggedSnapshots();
 
         List<Snapshot> skippingSnapshots =
-                SnapshotManager.findOverlappedSnapshots(
-                        taggedSnapshots, earliestId, endExclusiveId);
+                findSkippingTags(taggedSnapshots, earliestId, endExclusiveId);
         skippingSnapshots.add(snapshotManager.changelog(endExclusiveId));
         Set<String> manifestSkippSet = 
changelogDeletion.manifestSkippingSet(skippingSnapshots);
         for (long id = earliestId; id < endExclusiveId; id++) {
diff --git 
a/paimon-core/src/main/java/org/apache/paimon/table/ExpireSnapshotsImpl.java 
b/paimon-core/src/main/java/org/apache/paimon/table/ExpireSnapshotsImpl.java
index eb163f8fa..2c83b63c9 100644
--- a/paimon-core/src/main/java/org/apache/paimon/table/ExpireSnapshotsImpl.java
+++ b/paimon-core/src/main/java/org/apache/paimon/table/ExpireSnapshotsImpl.java
@@ -35,11 +35,15 @@ import org.slf4j.LoggerFactory;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.UncheckedIOException;
+import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.function.Predicate;
 
+import static 
org.apache.paimon.utils.SnapshotManager.findPreviousOrEqualSnapshot;
+import static org.apache.paimon.utils.SnapshotManager.findPreviousSnapshot;
+
 /** An implementation for {@link ExpireSnapshots}. */
 public class ExpireSnapshotsImpl implements ExpireSnapshots {
 
@@ -212,8 +216,7 @@ public class ExpireSnapshotsImpl implements ExpireSnapshots 
{
 
         // delete manifests and indexFiles
         List<Snapshot> skippingSnapshots =
-                SnapshotManager.findOverlappedSnapshots(
-                        taggedSnapshots, beginInclusiveId, endExclusiveId);
+                findSkippingTags(taggedSnapshots, beginInclusiveId, 
endExclusiveId);
 
         try {
             
skippingSnapshots.add(snapshotManager.tryGetSnapshot(endExclusiveId));
@@ -277,4 +280,18 @@ public class ExpireSnapshotsImpl implements 
ExpireSnapshots {
     public SnapshotDeletion snapshotDeletion() {
         return snapshotDeletion;
     }
+
+    /** Find the skipping tags in sortedTags for range of [beginInclusive, 
endExclusive). */
+    public static List<Snapshot> findSkippingTags(
+            List<Snapshot> sortedTags, long beginInclusive, long endExclusive) 
{
+        List<Snapshot> overlappedSnapshots = new ArrayList<>();
+        int right = findPreviousSnapshot(sortedTags, endExclusive);
+        if (right >= 0) {
+            int left = Math.max(findPreviousOrEqualSnapshot(sortedTags, 
beginInclusive), 0);
+            for (int i = left; i <= right; i++) {
+                overlappedSnapshots.add(sortedTags.get(i));
+            }
+        }
+        return overlappedSnapshots;
+    }
 }
diff --git 
a/paimon-core/src/main/java/org/apache/paimon/utils/SnapshotManager.java 
b/paimon-core/src/main/java/org/apache/paimon/utils/SnapshotManager.java
index 4dda63960..2dccc8250 100644
--- a/paimon-core/src/main/java/org/apache/paimon/utils/SnapshotManager.java
+++ b/paimon-core/src/main/java/org/apache/paimon/utils/SnapshotManager.java
@@ -723,23 +723,6 @@ public class SnapshotManager implements Serializable {
         return listVersionedFiles(fileIO, dir, 
prefix).reduce(reducer).orElse(null);
     }
 
-    /**
-     * Find the overlapping snapshots between sortedSnapshots and range of 
[beginInclusive,
-     * endExclusive).
-     */
-    public static List<Snapshot> findOverlappedSnapshots(
-            List<Snapshot> sortedSnapshots, long beginInclusive, long 
endExclusive) {
-        List<Snapshot> overlappedSnapshots = new ArrayList<>();
-        int right = findPreviousSnapshot(sortedSnapshots, endExclusive);
-        if (right >= 0) {
-            int left = Math.max(findPreviousOrEqualSnapshot(sortedSnapshots, 
beginInclusive), 0);
-            for (int i = left; i <= right; i++) {
-                overlappedSnapshots.add(sortedSnapshots.get(i));
-            }
-        }
-        return overlappedSnapshots;
-    }
-
     public static int findPreviousSnapshot(List<Snapshot> sortedSnapshots, 
long targetSnapshotId) {
         for (int i = sortedSnapshots.size() - 1; i >= 0; i--) {
             if (sortedSnapshots.get(i).id() < targetSnapshotId) {
@@ -749,7 +732,7 @@ public class SnapshotManager implements Serializable {
         return -1;
     }
 
-    private static int findPreviousOrEqualSnapshot(
+    public static int findPreviousOrEqualSnapshot(
             List<Snapshot> sortedSnapshots, long targetSnapshotId) {
         for (int i = sortedSnapshots.size() - 1; i >= 0; i--) {
             if (sortedSnapshots.get(i).id() <= targetSnapshotId) {

Reply via email to