pvary commented on code in PR #13302:
URL: https://github.com/apache/iceberg/pull/13302#discussion_r2142821354


##########
flink/v2.0/flink/src/main/java/org/apache/iceberg/flink/maintenance/operator/AntiJoin.java:
##########
@@ -0,0 +1,117 @@
+/*
+ * 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.maintenance.operator;
+
+import org.apache.flink.api.common.functions.OpenContext;
+import org.apache.flink.api.common.state.ValueState;
+import org.apache.flink.api.common.state.ValueStateDescriptor;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.streaming.api.functions.co.KeyedCoProcessFunction;
+import org.apache.flink.util.Collector;
+import org.apache.iceberg.actions.DeleteOrphanFiles;
+import org.apache.iceberg.exceptions.ValidationException;
+import org.apache.iceberg.relocated.com.google.common.base.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AntiJoin extends KeyedCoProcessFunction<String, FileURI, FileURI, 
String> {
+  private static final Logger LOG = LoggerFactory.getLogger(AntiJoin.class);
+
+  private transient ValueState<FileURI> foundInTable;
+  private transient ValueState<FileURI> foundInFileSystem;
+  private final DeleteOrphanFiles.PrefixMismatchMode prefixMismatchMode;
+
+  public AntiJoin(DeleteOrphanFiles.PrefixMismatchMode prefixMismatchMode) {
+    this.prefixMismatchMode = prefixMismatchMode;
+  }
+
+  @Override
+  public void open(OpenContext openContext) throws Exception {
+    super.open(openContext);
+    foundInTable =
+        getRuntimeContext()
+            .getState(
+                new ValueStateDescriptor<>(
+                    "antiJoinFoundInTable", 
TypeInformation.of(FileURI.class)));
+    foundInFileSystem =
+        getRuntimeContext()
+            .getState(
+                new ValueStateDescriptor<>(
+                    "antiJoinFoundInFileSystem", 
TypeInformation.of(FileURI.class)));
+  }
+
+  @Override
+  public void processElement1(FileURI value, Context context, 
Collector<String> collector)
+      throws Exception {
+    foundInTable.update(value);
+    context.timerService().registerEventTimeTimer(context.timestamp());
+  }
+
+  @Override
+  public void processElement2(FileURI value, Context context, 
Collector<String> collector)
+      throws Exception {
+    foundInFileSystem.update(value);
+    context.timerService().registerEventTimeTimer(context.timestamp());
+  }
+
+  @Override
+  public void onTimer(long timestamp, OnTimerContext ctx, Collector<String> 
out) throws Exception {
+    if (foundInFileSystem.value() != null && foundInTable.value() == null) {
+      out.collect(foundInFileSystem.value().uriAsString());
+    } else if (foundInFileSystem.value() != null && foundInTable.value() != 
null) {
+      FileURI valid = foundInTable.value();
+      FileURI actual = foundInFileSystem.value();
+      boolean schemeMatch = uriComponentMatch(valid.scheme(), actual.scheme());
+      boolean authorityMatch = uriComponentMatch(valid.authority(), 
actual.authority());
+
+      if ((!schemeMatch || !authorityMatch)

Review Comment:
   Duplicated logic from Spark



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to