danny0405 commented on code in PR #12537:
URL: https://github.com/apache/hudi/pull/12537#discussion_r1908096830


##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/client/clustering/run/strategy/SingleSparkConsistentBucketClusteringExecutionStrategy.java:
##########
@@ -0,0 +1,208 @@
+/*
+ * 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.client.clustering.run.strategy;
+
+import org.apache.hudi.avro.HoodieAvroUtils;
+import org.apache.hudi.client.SparkTaskContextSupplier;
+import org.apache.hudi.client.WriteStatus;
+import org.apache.hudi.client.utils.LazyConcatenatingIterator;
+import org.apache.hudi.common.config.SerializableSchema;
+import org.apache.hudi.common.engine.HoodieEngineContext;
+import org.apache.hudi.common.engine.TaskContextSupplier;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.model.ClusteringGroupInfo;
+import org.apache.hudi.common.model.ClusteringOperation;
+import org.apache.hudi.common.model.ConsistentHashingNode;
+import org.apache.hudi.common.model.HoodieConsistentHashingMetadata;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.common.util.StringUtils;
+import org.apache.hudi.common.util.ValidationUtils;
+import org.apache.hudi.common.util.collection.ClosableIterator;
+import org.apache.hudi.common.util.queue.HoodieConsumer;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.exception.HoodieClusteringException;
+import org.apache.hudi.index.bucket.ConsistentBucketIdentifier;
+import org.apache.hudi.io.CreateHandleFactory;
+import org.apache.hudi.io.HoodieWriteHandle;
+import org.apache.hudi.io.IOUtils;
+import org.apache.hudi.io.WriteHandleFactory;
+import org.apache.hudi.table.HoodieTable;
+import 
org.apache.hudi.table.action.cluster.strategy.BaseConsistentHashingBucketClusteringPlanStrategy;
+import org.apache.hudi.util.ExecutorFactory;
+
+import org.apache.avro.Schema;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.function.Supplier;
+
+public class SingleSparkConsistentBucketClusteringExecutionStrategy<T> extends 
SingleSparkJobExecutionStrategy<T> {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(SingleSparkConsistentBucketClusteringExecutionStrategy.class);
+
+  private final String indexKeyFields;
+  private final Schema readerSchema;
+
+  public SingleSparkConsistentBucketClusteringExecutionStrategy(HoodieTable 
table, HoodieEngineContext engineContext,
+                                                                
HoodieWriteConfig writeConfig) {
+    super(table, engineContext, writeConfig);
+    this.indexKeyFields = table.getConfig().getBucketIndexHashField();
+    this.readerSchema = HoodieAvroUtils.addMetadataFields(new 
Schema.Parser().parse(writeConfig.getSchema()));
+  }
+
+  @Override
+  protected List<WriteStatus> performClusteringForGroup(ClusteringGroupInfo 
clusteringGroup, Map<String, String> strategyParams, boolean 
preserveHoodieMetadata, SerializableSchema schema,
+                                                        TaskContextSupplier 
taskContextSupplier, String instantTime) {
+    // deal with split / merge operations
+    ValidationUtils.checkArgument(clusteringGroup.getNumOutputGroups() >= 1, 
"Number of output groups should be at least 1");
+    if (clusteringGroup.getNumOutputGroups() == 1) {
+      // means that there is a merge operation
+      return performBucketMergeForGroup(clusteringGroup, strategyParams, 
preserveHoodieMetadata, schema, taskContextSupplier, instantTime);
+    }
+    // more than one output groups means split operation
+    return performBucketSplitForGroup(clusteringGroup, strategyParams, 
preserveHoodieMetadata, schema, taskContextSupplier, instantTime);
+  }
+
+  private List<ConsistentHashingNode> deconstructNodes(ClusteringGroupInfo 
clusteringGroupInfo) {

Review Comment:
   decodeConsistentHashingNodes?



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