nsivabalan commented on code in PR #9006:
URL: https://github.com/apache/hudi/pull/9006#discussion_r1256360125


##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/client/clustering/run/strategy/ParquetToolsExecutionStrategy.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * 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.avro.Schema;
+import org.apache.hadoop.fs.Path;
+import org.apache.hudi.client.WriteStatus;
+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.model.ClusteringGroupInfo;
+import org.apache.hudi.common.model.ClusteringOperation;
+import org.apache.hudi.common.model.HoodieFileGroupId;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.model.HoodieRecordPayload;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.exception.HoodieClusteringException;
+import org.apache.hudi.io.HoodieFileWriteHandle;
+import org.apache.hudi.table.HoodieTable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Stream;
+
+/**
+ * This class gives skeleton implementation for set of clustering execution 
strategy
+ * that use parquet-tools commands.
+ */
+public abstract class ParquetToolsExecutionStrategy<T extends 
HoodieRecordPayload<T>>
+    extends SingleSparkJobExecutionStrategy<T> {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(ParquetToolsExecutionStrategy.class);
+
+  public ParquetToolsExecutionStrategy(
+      HoodieTable table, HoodieEngineContext engineContext, HoodieWriteConfig 
writeConfig) {
+    super(table, engineContext, writeConfig);
+  }
+
+  protected Stream<WriteStatus> runClusteringForGroup(ClusteringGroupInfo 
clusteringOps, Map<String, String> strategyParams,
+                                                      boolean 
preserveHoodieMetadata, SerializableSchema schema,
+                                                      TaskContextSupplier 
taskContextSupplier, String instantTime) {
+    LOG.info("Starting clustering operation on input file ids.");
+    List<ClusteringOperation> clusteringOperations = 
clusteringOps.getOperations();
+    if (clusteringOperations.size() > 1) {
+      throw new HoodieClusteringException("Expect only one clustering 
operation during rewrite: " + getClass().getName());
+    }
+
+    ClusteringOperation clusteringOperation = clusteringOperations.get(0);
+    String fileId = clusteringOperation.getFileId();
+    String partitionPath = clusteringOperation.getPartitionPath();
+    String dataFilePathStr = clusteringOperation.getDataFilePath();
+    Path oldFilePath = new Path(dataFilePathStr);
+    HoodieFileWriteHandle writeHandler = new 
HoodieFileWriteHandle(getWriteConfig(), instantTime, getHoodieTable(),
+        partitionPath, fileId, taskContextSupplier, oldFilePath);
+
+    // Executes the parquet-tools command.
+    executeTools(oldFilePath, writeHandler.getPath());

Review Comment:
   can we move the executeTools within HoodieFileWriteHandle



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