From 30dcfb50da92691fed24228fd11665b59d39a6b6 Mon Sep 17 00:00:00 2001 From: Jingsong Date: Thu, 12 Dec 2024 13:28:07 +0800 Subject: [PATCH] [core] Remove useless codes in CachingCatalog --- .../apache/paimon/catalog/CachingCatalog.java | 36 ++++--------------- .../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 e92a589d411e..82d503b7a272 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.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 @@ /** 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 CachingCatalog( this.tableCache = Caffeine.newBuilder() .softValues() - .removalListener(new TableInvalidatingRemovalListener()) .executor(Runnable::run) .expireAfterAccess(expirationInterval) .ticker(ticker) @@ -201,8 +192,12 @@ public void dropTable(Identifier identifier, boolean ignoreIfNotExists) 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 void dropPartition(Identifier identifier, Map partitions) } } - private class TableInvalidatingRemovalListener implements RemovalListener { - @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 void invalidateTable(Identifier identifier) { } } - /** 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 6cca6824e32b..01456f0b3ae1 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 String getBranchNameOrDefault() { return systemTable; } - public boolean isMainTable() { - return getBranchName() == null && getSystemTableName() == null; - } - - public boolean isBranch() { - return getBranchName() != null && getSystemTableName() == null; - } - public boolean isSystemTable() { return getSystemTableName() != null; }