taoran92 commented on code in PR #4422:
URL: https://github.com/apache/flink-cdc/pull/4422#discussion_r3763448426


##########
flink-cdc-connect/flink-cdc-source-connectors/flink-connector-debezium/src/main/java/io/debezium/relational/CachedTableFilter.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.debezium.relational;
+
+import org.apache.flink.shaded.guava31.com.google.common.cache.CacheBuilder;
+import org.apache.flink.shaded.guava31.com.google.common.cache.CacheLoader;
+import org.apache.flink.shaded.guava31.com.google.common.cache.LoadingCache;
+
+import io.debezium.relational.Tables.TableFilter;
+
+/** A bounded cache for table filter results. */
+public class CachedTableFilter implements TableFilter {
+
+    private static final long TABLE_FILTER_CACHE_MAXIMUM_SIZE = 1024;
+
+    private final TableFilter rawTableFilter;
+    private final LoadingCache<TableId, Boolean> tableFilterCache;
+
+    private CachedTableFilter(TableFilter rawTableFilter) {
+        this.rawTableFilter = rawTableFilter;
+        this.tableFilterCache =
+                CacheBuilder.newBuilder()
+                        .maximumSize(TABLE_FILTER_CACHE_MAXIMUM_SIZE)

Review Comment:
   @ruanhang1993 thanks for reviewing. 
   
   I don't think a TTL is necessary here. The filtering result is deterministic 
for a TableId under a fixed source configuration, and filter changes create or 
install a new filter instance. A TTL would therefore only introduce periodic 
cache misses without preventing any known stale-result scenario. If mutable 
filtering rules are supported in the future, explicit cache invalidation or 
cache replacement would provide clearer semantics than time-based expiration.
   
   I suggest keeping eviction simple currently: use only a bounded, LRU-style 
size policy to prevent OOM, without adding TTL. WDYT?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to