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 9e0fc01c7c [core] Add snapshot cache for latest snapshot from file 
system (#6622)
9e0fc01c7c is described below

commit 9e0fc01c7c86d0c3492fa6d9b574bfc19e96797d
Author: Zouxxyy <[email protected]>
AuthorDate: Tue Nov 18 23:35:49 2025 +0800

    [core] Add snapshot cache for latest snapshot from file system (#6622)
---
 .../java/org/apache/paimon/utils/SnapshotManager.java     | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

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 085f751f28..05337bda59 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
@@ -165,19 +165,22 @@ public class SnapshotManager implements Serializable {
     }
 
     public @Nullable Snapshot latestSnapshot() {
+        Snapshot snapshot;
         if (snapshotLoader != null) {
             try {
-                Snapshot snapshot = snapshotLoader.load().orElse(null);
-                if (snapshot != null && cache != null) {
-                    cache.put(snapshotPath(snapshot.id()), snapshot);
-                }
-                return snapshot;
+                snapshot = snapshotLoader.load().orElse(null);
             } catch (UnsupportedOperationException ignored) {
+                snapshot = latestSnapshotFromFileSystem();
             } catch (IOException e) {
                 throw new UncheckedIOException(e);
             }
+        } else {
+            snapshot = latestSnapshotFromFileSystem();
         }
-        return latestSnapshotFromFileSystem();
+        if (snapshot != null && cache != null) {
+            cache.put(snapshotPath(snapshot.id()), snapshot);
+        }
+        return snapshot;
     }
 
     public @Nullable Snapshot latestSnapshotFromFileSystem() {

Reply via email to