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 30dcfb50da [core] Remove useless codes in CachingCatalog
30dcfb50da is described below

commit 30dcfb50da92691fed24228fd11665b59d39a6b6
Author: Jingsong <[email protected]>
AuthorDate: Thu Dec 12 13:28:07 2024 +0800

    [core] Remove useless codes in CachingCatalog
---
 .../org/apache/paimon/catalog/CachingCatalog.java  | 36 ++++------------------
 .../java/org/apache/paimon/catalog/Identifier.java |  8 -----
 2 files changed, 6 insertions(+), 38 deletions(-)

diff --git 
a/paimon-core/src/main/java/org/apache/paimon/catalog/CachingCatalog.java 
b/paimon-core/src/main/java/org/apache/paimon/catalog/CachingCatalog.java
index e92a589d41..82d503b7a2 100644
--- a/paimon-core/src/main/java/org/apache/paimon/catalog/CachingCatalog.java
+++ b/paimon-core/src/main/java/org/apache/paimon/catalog/CachingCatalog.java
@@ -30,15 +30,9 @@ import org.apache.paimon.utils.SegmentsCache;
 
 import 
org.apache.paimon.shade.caffeine2.com.github.benmanes.caffeine.cache.Cache;
 import 
org.apache.paimon.shade.caffeine2.com.github.benmanes.caffeine.cache.Caffeine;
-import 
org.apache.paimon.shade.caffeine2.com.github.benmanes.caffeine.cache.RemovalCause;
-import 
org.apache.paimon.shade.caffeine2.com.github.benmanes.caffeine.cache.RemovalListener;
 import 
org.apache.paimon.shade.caffeine2.com.github.benmanes.caffeine.cache.Ticker;
 import 
org.apache.paimon.shade.caffeine2.com.github.benmanes.caffeine.cache.Weigher;
 
-import org.checkerframework.checker.nullness.qual.NonNull;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import javax.annotation.Nullable;
 
 import java.time.Duration;
@@ -59,8 +53,6 @@ import static 
org.apache.paimon.utils.Preconditions.checkNotNull;
 /** A {@link Catalog} to cache databases and tables and manifests. */
 public class CachingCatalog extends DelegateCatalog {
 
-    private static final Logger LOG = 
LoggerFactory.getLogger(CachingCatalog.class);
-
     private final Duration expirationInterval;
     private final int snapshotMaxNumPerTable;
 
@@ -125,7 +117,6 @@ public class CachingCatalog extends DelegateCatalog {
         this.tableCache =
                 Caffeine.newBuilder()
                         .softValues()
-                        .removalListener(new 
TableInvalidatingRemovalListener())
                         .executor(Runnable::run)
                         .expireAfterAccess(expirationInterval)
                         .ticker(ticker)
@@ -201,8 +192,12 @@ public class CachingCatalog extends DelegateCatalog {
             throws TableNotExistException {
         super.dropTable(identifier, ignoreIfNotExists);
         invalidateTable(identifier);
-        if (identifier.isMainTable()) {
-            invalidateAttachedTables(identifier);
+
+        // clear all branch tables of this table
+        for (Identifier i : tableCache.asMap().keySet()) {
+            if (identifier.getTableName().equals(i.getTableName())) {
+                tableCache.invalidate(i);
+            }
         }
     }
 
@@ -302,16 +297,6 @@ public class CachingCatalog extends DelegateCatalog {
         }
     }
 
-    private class TableInvalidatingRemovalListener implements 
RemovalListener<Identifier, Table> {
-        @Override
-        public void onRemoval(Identifier identifier, Table table, @NonNull 
RemovalCause cause) {
-            LOG.debug("Evicted {} from the table cache ({})", identifier, 
cause);
-            if (RemovalCause.EXPIRED.equals(cause)) {
-                // ignore now
-            }
-        }
-    }
-
     @Override
     public void invalidateTable(Identifier identifier) {
         tableCache.invalidate(identifier);
@@ -320,15 +305,6 @@ public class CachingCatalog extends DelegateCatalog {
         }
     }
 
-    /** invalidate attached tables, such as cached branches. */
-    private void invalidateAttachedTables(Identifier identifier) {
-        for (@NonNull Identifier i : tableCache.asMap().keySet()) {
-            if (identifier.getTableName().equals(i.getTableName())) {
-                tableCache.invalidate(i);
-            }
-        }
-    }
-
     // ================================== refresh 
================================================
     // following caches will affect the latency of table, so refresh method is 
provided for engine
 
diff --git 
a/paimon-core/src/main/java/org/apache/paimon/catalog/Identifier.java 
b/paimon-core/src/main/java/org/apache/paimon/catalog/Identifier.java
index 6cca6824e3..01456f0b3a 100644
--- a/paimon-core/src/main/java/org/apache/paimon/catalog/Identifier.java
+++ b/paimon-core/src/main/java/org/apache/paimon/catalog/Identifier.java
@@ -123,14 +123,6 @@ public class Identifier implements Serializable {
         return systemTable;
     }
 
-    public boolean isMainTable() {
-        return getBranchName() == null && getSystemTableName() == null;
-    }
-
-    public boolean isBranch() {
-        return getBranchName() != null && getSystemTableName() == null;
-    }
-
     public boolean isSystemTable() {
         return getSystemTableName() != null;
     }

Reply via email to