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


##########
flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/maintenance/operator/EqualityConvertReader.java:
##########
@@ -0,0 +1,129 @@
+/*
+ * 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.annotation.Internal;
+import org.apache.flink.api.common.functions.OpenContext;
+import org.apache.flink.streaming.api.functions.ProcessFunction;
+import org.apache.flink.util.Collector;
+import org.apache.flink.util.OutputTag;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.Table;
+import org.apache.iceberg.data.Record;
+import org.apache.iceberg.flink.TableLoader;
+import org.apache.iceberg.formats.FormatModelRegistry;
+import org.apache.iceberg.formats.ReadBuilder;
+import org.apache.iceberg.io.CloseableIterable;
+import org.apache.iceberg.io.DeleteSchemaUtil;
+import org.apache.iceberg.io.InputFile;
+import org.apache.iceberg.relocated.com.google.common.collect.Sets;
+import org.apache.iceberg.types.TypeUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Parallel reader that processes {@link ReadCommand}s from the planner and 
emits {@link
+ * IndexCommand}s. Each instance reads a subset of files and emits row-level 
index commands for the
+ * workers.
+ */
+@Internal
+public class EqualityConvertReader extends ProcessFunction<ReadCommand, 
IndexCommand> {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(EqualityConvertReader.class);
+
+  public static final OutputTag<DVPosition> DV_POSITION_STREAM =
+      new OutputTag<>("dv-position-stream") {};
+
+  private final TableLoader tableLoader;
+
+  private transient Table table;
+  private transient EqualityFieldSerializer fieldSerializer;
+
+  public EqualityConvertReader(TableLoader tableLoader) {
+    this.tableLoader = tableLoader;
+  }
+
+  @Override
+  public void open(OpenContext openContext) throws Exception {
+    super.open(openContext);
+    if (!tableLoader.isOpen()) {
+      tableLoader.open();
+    }
+
+    table = tableLoader.loadTable();
+    fieldSerializer = new EqualityFieldSerializer();
+  }
+
+  @Override
+  public void processElement(ReadCommand cmd, Context ctx, 
Collector<IndexCommand> out)
+      throws Exception {
+    try {
+      if (cmd.type() == ReadCommand.Type.POS_DELETE_FILE) {
+        readPosDeleteFile(cmd, ctx);
+        return;
+      }
+
+      Schema keySchema = TypeUtil.select(table.schema(), 
Sets.newHashSet(cmd.equalityFieldIds()));

Review Comment:
   Do we check correctness somewhere? So every field is still in the table 
schema?



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