n3nash commented on a change in pull request #2275:
URL: https://github.com/apache/hudi/pull/2275#discussion_r549057217
##########
File path:
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/table/action/commit/BaseSparkCommitActionExecutor.java
##########
@@ -88,6 +93,18 @@ public BaseSparkCommitActionExecutor(HoodieEngineContext
context,
super(context, config, table, instantTime, operationType, extraMetadata);
}
+ private JavaRDD<HoodieRecord<T>>
clusteringHandleRecordsUpdate(JavaRDD<HoodieRecord<T>> inputRecordsRDD) {
Review comment:
rename this to clusteringHandleUpdate as well, records is implied
##########
File path:
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/client/clustering/update/strategy/SparkRejectUpdateStrategy.java
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.update.strategy;
+
+import org.apache.hudi.client.common.HoodieSparkEngineContext;
+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.exception.HoodieClusteringUpdateException;
+import org.apache.hudi.table.action.cluster.strategy.UpdateStrategy;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.apache.spark.api.java.JavaRDD;
+
+import java.util.HashSet;
+import java.util.List;
+
+/**
+ * Update strategy based on following.
Review comment:
Nit -> remove the "just throw exception now" to "throw exception"
##########
File path:
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/client/clustering/update/strategy/SparkRejectUpdateStrategy.java
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.update.strategy;
+
+import org.apache.hudi.client.common.HoodieSparkEngineContext;
+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.exception.HoodieClusteringUpdateException;
+import org.apache.hudi.table.action.cluster.strategy.UpdateStrategy;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.apache.spark.api.java.JavaRDD;
+
+import java.util.HashSet;
+import java.util.List;
+
+/**
+ * Update strategy based on following.
+ * if some file group have update record, just throw exception now
+ */
+public class SparkRejectUpdateStrategy<T extends HoodieRecordPayload<T>>
extends UpdateStrategy<T, JavaRDD<HoodieRecord<T>>> {
+ private static final Logger LOG =
LogManager.getLogger(SparkRejectUpdateStrategy.class);
+
+ public SparkRejectUpdateStrategy(HoodieSparkEngineContext engineContext,
HashSet<HoodieFileGroupId> fileGroupsInPendingClustering) {
+ super(engineContext, fileGroupsInPendingClustering);
+ }
+
+ private List<HoodieFileGroupId>
getFileGroupIdsWithRecordUpdate(JavaRDD<HoodieRecord<T>> inputRecords) {
Review comment:
Rename to getGroupIdsWithUpdate
##########
File path:
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/cluster/strategy/UpdateStrategy.java
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.cluster.strategy;
+
+import org.apache.hudi.client.common.HoodieEngineContext;
+import org.apache.hudi.common.model.HoodieFileGroupId;
+import org.apache.hudi.common.model.HoodieRecordPayload;
+
+import java.util.Set;
+
+/**
+ * When file groups in clustering, write records to these file group need to
check.
+ */
+public abstract class UpdateStrategy<T extends HoodieRecordPayload<T>, I> {
+
+ protected final HoodieEngineContext engineContext;
+ protected Set<HoodieFileGroupId> fileGroupsInPendingClustering;
+
+ protected UpdateStrategy(HoodieEngineContext engineContext,
Set<HoodieFileGroupId> fileGroupsInPendingClustering) {
+ this.engineContext = engineContext;
+ this.fileGroupsInPendingClustering = fileGroupsInPendingClustering;
+ }
+
+ /**
+ * Check the update records to the file group in clustering.
+ * @param taggedRecordsRDD the records will write, can get the update record,
Review comment:
Nit : for comments, please replace with "the records to write, tagged
with target file id"
##########
File path:
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/cluster/strategy/UpdateStrategy.java
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.cluster.strategy;
+
+import org.apache.hudi.client.common.HoodieEngineContext;
+import org.apache.hudi.common.model.HoodieFileGroupId;
+import org.apache.hudi.common.model.HoodieRecordPayload;
+
+import java.util.Set;
+
+/**
+ * When file groups in clustering, write records to these file group need to
check.
+ */
+public abstract class UpdateStrategy<T extends HoodieRecordPayload<T>, I> {
+
+ protected final HoodieEngineContext engineContext;
+ protected Set<HoodieFileGroupId> fileGroupsInPendingClustering;
+
+ protected UpdateStrategy(HoodieEngineContext engineContext,
Set<HoodieFileGroupId> fileGroupsInPendingClustering) {
+ this.engineContext = engineContext;
+ this.fileGroupsInPendingClustering = fileGroupsInPendingClustering;
+ }
+
+ /**
+ * Check the update records to the file group in clustering.
+ * @param taggedRecordsRDD the records will write, can get the update record,
+ * future can update tagged records location to a
different fileId.
+ * @return the recordsRDD strategy updated
+ */
+ public abstract I handleRecordUpdate(I taggedRecordsRDD);
Review comment:
This looks like will be applicable for an RDD of records, if yes, rename
this to 'handleUpdate'
##########
File path:
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/table/action/commit/UpsertPartitioner.java
##########
@@ -129,6 +129,34 @@ private int addUpdateBucket(String partitionPath, String
fileIdHint) {
return bucket;
}
+ /**
+ * Get the in pending clustering fileId for each partition path.
+ * @return partition path to pending clustering file groups id
+ */
+ private Map<String, Set<String>>
getPartitionPathToPendingClusteringFileGroupsId() {
+ Map<String, Set<String>> partitionPathToInPendingClusteringFileId =
+ table.getFileSystemView().getFileGroupsInPendingClustering()
+ .map(fileGroupIdAndInstantPair ->
+ Pair.of(fileGroupIdAndInstantPair.getKey().getPartitionPath(),
fileGroupIdAndInstantPair.getKey().getFileId()))
+ .collect(Collectors.groupingBy(Pair::getKey,
Collectors.mapping(Pair::getValue, Collectors.toSet())));
+ return partitionPathToInPendingClusteringFileId;
+ }
+
+ /**
+ * Exclude the small file in pending clustering, because in pending
clustering file not support update now.
Review comment:
Please Change to : "exclude small file handling for clustering since
update path is not supported"
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]