zhangyue19921010 commented on code in PR #12601:
URL: https://github.com/apache/hudi/pull/12601#discussion_r1915924556


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/BaseTableServicePlanActionExecutor.java:
##########
@@ -0,0 +1,165 @@
+/*
+ * 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.hudi.table.action;
+
+import org.apache.hudi.avro.model.HoodieClusteringPlan;
+import org.apache.hudi.avro.model.HoodieCompactionPlan;
+import org.apache.hudi.common.engine.HoodieEngineContext;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.model.HoodieCommitMetadata;
+import org.apache.hudi.common.model.HoodieWriteStat;
+import org.apache.hudi.common.model.TableServiceType;
+import org.apache.hudi.common.table.timeline.HoodieActiveTimeline;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.common.table.timeline.HoodieTimeline;
+import org.apache.hudi.common.table.timeline.TimelineUtils;
+import org.apache.hudi.common.table.timeline.versioning.v1.InstantComparatorV1;
+import org.apache.hudi.common.util.ClusteringUtils;
+import org.apache.hudi.common.util.CollectionUtils;
+import org.apache.hudi.common.util.CompactionUtils;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.common.util.collection.Pair;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.exception.HoodieException;
+import org.apache.hudi.exception.HoodieIOException;
+import org.apache.hudi.table.HoodieTable;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static 
org.apache.hudi.common.table.timeline.HoodieTimeline.COMMIT_ACTION;
+
+public abstract class BaseTableServicePlanActionExecutor<T, I, K, O, R> 
extends BaseActionExecutor<T, I, K, O, R> {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(BaseTableServicePlanActionExecutor.class);
+
+  public BaseTableServicePlanActionExecutor(HoodieEngineContext context, 
HoodieWriteConfig config,
+                                            HoodieTable<T, I, K, O> table, 
String instantTime) {
+    super(context, config, table, instantTime);
+  }
+
+  /**
+   * Get partitions, if strategy implement `IncrementalPartitionAwareStrategy` 
then return incremental partitions,
+   * otherwise return all partitions of the table
+   * @param strategy
+   * @return
+   */
+  public List<String> getPartitions(Object strategy, TableServiceType type) {
+    if (config.isIncrementalTableServiceEnable() && strategy instanceof 
IncrementalPartitionAwareStrategy) {
+      try {
+        // get incremental partitions.
+        LOG.info("Start to fetch incremental partitions for " + type);
+        Set<String> incrementalPartitions = getIncrementalPartitions(type);
+        if (!incrementalPartitions.isEmpty()) {
+          LOG.info("Fetched incremental partitions for " + type + ". " + 
incrementalPartitions);
+          return new ArrayList<>(incrementalPartitions);
+        }
+      } catch (Exception ex) {
+        LOG.warn("Failed to get incremental partitions", ex);
+      }
+    }
+
+    // fall back to get all partitions
+    LOG.info("Start to fetch all partitions for " + type);
+    return FSUtils.getAllPartitionPaths(context, 
table.getMetaClient().getStorage(),
+        config.getMetadataConfig(), table.getMetaClient().getBasePath());
+  }
+
+  private Set<String> getIncrementalPartitions(TableServiceType type) {
+    Pair<Option<HoodieInstant>, List<String>> missingPair = 
fetchMissingPartitions(type);
+    if (!missingPair.getLeft().isPresent()) {
+      // Last complete table service commit maybe archived.
+      return Collections.emptySet();

Review Comment:
   make senses. changed 
   For now, there are two situations fall back to get all partitions
   
   incremental partitions getting throws exceptions.
   last completed table service instant is archived.
   AND
   when incremental partition list is empty , we will skip current schedule.



##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/IncrementalPartitionAwareStrategy.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.hudi.table.action;
+
+import org.apache.hudi.common.util.collection.Pair;
+import org.apache.hudi.config.HoodieWriteConfig;
+
+import java.util.List;
+
+/**
+ * Marking strategy interface.

Review Comment:
   changed.



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