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 9573fcd866 [core] Optimize FileStoreCommitImpl#filterCommitted when 
commit strict mode is set (#7239)
9573fcd866 is described below

commit 9573fcd86675260250b96fb737593acf216dd39b
Author: tsreaper <[email protected]>
AuthorDate: Tue Feb 10 09:21:04 2026 +0800

    [core] Optimize FileStoreCommitImpl#filterCommitted when commit strict mode 
is set (#7239)
    
    It is costly to find the latest snapshot of user if there are many
    snapshots. This PR optimizes `FileStoreCommitImpl#filterCommitted` when
    commit strict mode is set: we only search until the safe snapshot ID.
---
 .../apache/paimon/operation/FileStoreCommitImpl.java  | 10 +++++++++-
 .../java/org/apache/paimon/utils/SnapshotManager.java | 19 +++++++++++--------
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git 
a/paimon-core/src/main/java/org/apache/paimon/operation/FileStoreCommitImpl.java
 
b/paimon-core/src/main/java/org/apache/paimon/operation/FileStoreCommitImpl.java
index 685b0c23a0..acca626205 100644
--- 
a/paimon-core/src/main/java/org/apache/paimon/operation/FileStoreCommitImpl.java
+++ 
b/paimon-core/src/main/java/org/apache/paimon/operation/FileStoreCommitImpl.java
@@ -255,7 +255,15 @@ public class FileStoreCommitImpl implements 
FileStoreCommit {
                     "Committables must be sorted according to identifiers 
before filtering. This is unexpected.");
         }
 
-        Optional<Snapshot> latestSnapshot = 
snapshotManager.latestSnapshotOfUser(commitUser);
+        Optional<Snapshot> latestSnapshot =
+                options.commitStrictModeLastSafeSnapshot()
+                        .map(
+                                id ->
+                                        snapshotManager.latestSnapshotOfUser(
+                                                commitUser,
+                                                
snapshotManager.latestSnapshotId(),
+                                                id + 1))
+                        
.orElse(snapshotManager.latestSnapshotOfUser(commitUser));
         if (latestSnapshot.isPresent()) {
             List<ManifestCommittable> result = new ArrayList<>();
             for (ManifestCommittable committable : committables) {
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 b7671006c0..2fb624c71e 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
@@ -587,23 +587,26 @@ public class SnapshotManager implements Serializable {
     }
 
     public Optional<Snapshot> latestSnapshotOfUser(String user) {
-        return latestSnapshotOfUser(user, latestSnapshotId());
+        return latestSnapshotOfUser(user, latestSnapshotId(), null);
     }
 
     public Optional<Snapshot> latestSnapshotOfUserFromFilesystem(String user) {
-        return latestSnapshotOfUser(user, latestSnapshotIdFromFileSystem());
+        return latestSnapshotOfUser(user, latestSnapshotIdFromFileSystem(), 
null);
     }
 
-    private Optional<Snapshot> latestSnapshotOfUser(String user, Long 
latestId) {
+    public Optional<Snapshot> latestSnapshotOfUser(
+            String user, Long latestId, @Nullable Long earliestId) {
         if (latestId == null) {
             return Optional.empty();
         }
+        if (earliestId == null) {
+            earliestId =
+                    Preconditions.checkNotNull(
+                            earliestSnapshotId(),
+                            "Latest snapshot id is not null, but earliest 
snapshot id is null. "
+                                    + "This is unexpected.");
+        }
 
-        long earliestId =
-                Preconditions.checkNotNull(
-                        earliestSnapshotId(),
-                        "Latest snapshot id is not null, but earliest snapshot 
id is null. "
-                                + "This is unexpected.");
         for (long id = latestId; id >= earliestId; id--) {
             Snapshot snapshot;
             try {

Reply via email to