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


##########
flink/v2.0/flink/src/main/java/org/apache/iceberg/flink/maintenance/operator/TablePlanner.java:
##########
@@ -0,0 +1,139 @@
+/*
+ * 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 java.util.concurrent.ExecutorService;
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.api.common.functions.OpenContext;
+import org.apache.flink.metrics.Counter;
+import org.apache.flink.streaming.api.functions.ProcessFunction;
+import org.apache.flink.util.Collector;
+import org.apache.iceberg.MetadataTableType;
+import org.apache.iceberg.MetadataTableUtils;
+import org.apache.iceberg.Table;
+import org.apache.iceberg.flink.TableLoader;
+import org.apache.iceberg.flink.maintenance.api.DeleteOrphanFiles;
+import org.apache.iceberg.flink.maintenance.api.Trigger;
+import org.apache.iceberg.flink.source.FlinkSplitPlanner;
+import org.apache.iceberg.flink.source.ScanContext;
+import org.apache.iceberg.flink.source.split.IcebergSourceSplit;
+import org.apache.iceberg.flink.source.split.IcebergSourceSplitSerializer;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.util.ThreadPools;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** Plans the splits to read a metadata table content. */
+@Internal
+public class TablePlanner extends ProcessFunction<Trigger, 
TablePlanner.SplitInfo> {
+  private static final Logger LOG = 
LoggerFactory.getLogger(TablePlanner.class);
+
+  private final String taskName;
+  private final int taskIndex;
+  private final TableLoader tableLoader;
+  private final int workerPoolSize;
+  private final ScanContext scanContext;
+  private transient ExecutorService workerPool;
+  private transient Counter errorCounter;
+  private transient Table table;
+  private final boolean caseSensitive;
+  private transient IcebergSourceSplitSerializer splitSerializer;
+
+  public TablePlanner(
+      String taskName,
+      int taskIndex,
+      TableLoader tableLoader,
+      ScanContext scanContext,
+      int workerPoolSize,
+      boolean caseSensitive) {
+    Preconditions.checkNotNull(taskName, "Task name should no be null");
+    Preconditions.checkNotNull(tableLoader, "Table should no be null");
+    Preconditions.checkArgument(scanContext.isStreaming(), "Streaming should 
be set to true");
+
+    this.taskName = taskName;
+    this.taskIndex = taskIndex;
+    this.tableLoader = tableLoader;
+    this.scanContext = scanContext;
+    this.workerPoolSize = workerPoolSize;
+    this.caseSensitive = caseSensitive;
+  }
+
+  @Override
+  public void open(OpenContext openContext) throws Exception {
+    tableLoader.open();
+    Table tableOri = tableLoader.loadTable();
+    this.table =
+        MetadataTableUtils.createMetadataTableInstance(tableOri, 
MetadataTableType.ALL_FILES);

Review Comment:
   Maybe extract this from the operator, and provide this in the constructor.
   It would be nice if this planner could remain independent of which table we 
read, and the query/table could be provided as a parameter



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