mxm commented on code in PR #18149:
URL: https://github.com/apache/iceberg/pull/18149#discussion_r4631578118


##########
flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/source/lookup/FullCacheReloadTriggerFactory.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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 org.apache.iceberg.flink.source.lookup;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import javax.annotation.Nullable;
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.table.connector.source.lookup.LookupOptions;
+import 
org.apache.flink.table.connector.source.lookup.LookupOptions.LookupCacheType;
+import 
org.apache.flink.table.connector.source.lookup.cache.trigger.CacheReloadTrigger;
+import 
org.apache.flink.table.connector.source.lookup.cache.trigger.PeriodicCacheReloadTrigger;
+import 
org.apache.flink.table.connector.source.lookup.cache.trigger.TimedCacheReloadTrigger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Internal
+public class FullCacheReloadTriggerFactory {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(FullCacheReloadTriggerFactory.class);
+
+  private static final String FULL_CACHE_PREFIX = "lookup.full-cache.";
+
+  public static @Nullable CacheReloadTrigger create(Configuration lookupConf) {
+    if (!lookupConf.contains(LookupOptions.FULL_CACHE_RELOAD_STRATEGY)) {
+      warnIgnoredOptions(lookupConf);
+      return null;
+    }
+
+    Configuration triggerConf = new Configuration(lookupConf);
+    triggerConf.set(LookupOptions.CACHE_TYPE, LookupCacheType.FULL);
+
+    return switch (lookupConf.get(LookupOptions.FULL_CACHE_RELOAD_STRATEGY)) {
+      case PERIODIC -> PeriodicCacheReloadTrigger.fromConfig(triggerConf);
+      case TIMED -> TimedCacheReloadTrigger.fromConfig(triggerConf);
+    };
+  }
+
+  private static void warnIgnoredOptions(Configuration lookupConf) {
+    List<String> ignored =
+        lookupConf.keySet().stream()
+            .filter(key -> key.startsWith(FULL_CACHE_PREFIX))

Review Comment:
   This prefix also matches `lookup.full-cache.eager-load`, so a join with 
`'lookup.full-cache.eager-load'='false'` logs that the option is ignored, 
although it is applied. Could we check the four reload options instead of the 
prefix?



##########
flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/source/lookup/IcebergFullCachingLookupFunction.java:
##########
@@ -68,15 +73,21 @@ public class IcebergFullCachingLookupFunction extends 
LookupFunction {
   private final List<Expression> pushedFilters;
   private final boolean caseSensitive;
   private final boolean eagerLoad;
+  private final @Nullable CacheReloadTrigger reloadTrigger;
 
   private transient Table table;
   private transient IcebergLookupReader reader;
   private transient RowDataSerializer rowSerializer;
-  private transient RowDataSerializer keySerializer;
+  private transient RowDataSerializer lookupKeySerializer;
+  private transient RowDataSerializer loadKeySerializer;

Review Comment:
   NIT: Could we add a comment on why there are two key serializers? No test 
fails if they are merged again.
   
   ```suggestion
     // lookup() and reloads run on different threads, and toBinaryRow reuses 
its output row
     private transient RowDataSerializer lookupKeySerializer;
     private transient RowDataSerializer loadKeySerializer;
   ```



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to