You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2021/10/11 06:03:25 UTC

[GitHub] [hudi] garyli1019 commented on a change in pull request #3741: [HUDI-2501] Add HoodieData abstraction and refactor compaction actions in hudi-client module

garyli1019 commented on a change in pull request #3741:
URL: https://github.com/apache/hudi/pull/3741#discussion_r725795673



##########
File path: hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/HoodieCopyOnWriteTableOperation.java
##########
@@ -0,0 +1,43 @@
+/*
+ * 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;
+
+import org.apache.hudi.client.WriteStatus;
+import org.apache.hudi.common.model.HoodieBaseFile;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.model.HoodieRecordPayload;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Interface for insert and update operations in compaction.
+ *
+ * @param <T> HoodieRecordPayload type.
+ */
+public interface HoodieCopyOnWriteTableOperation<T extends HoodieRecordPayload> {
+  Iterator<List<WriteStatus>> handleUpdate(String instantTime, String partitionPath, String fileId,

Review comment:
       Can we have both batch interface and streaming interface? Like `handleUpdates` and `handleUpdate`. `handleUpdate(HoodieRecord)` is to process record one by one instead of a `Map`. 

##########
File path: hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/compact/ScheduleCompactionActionExecutor.java
##########
@@ -45,31 +46,67 @@
 import java.util.Set;
 import java.util.stream.Collectors;
 
-@SuppressWarnings("checkstyle:LineLength")
-public class FlinkScheduleCompactionActionExecutor<T extends HoodieRecordPayload> extends
-    BaseScheduleCompactionActionExecutor<T, List<HoodieRecord<T>>, List<HoodieKey>, List<WriteStatus>> {
+public class ScheduleCompactionActionExecutor<T extends HoodieRecordPayload, I, K, O> extends BaseActionExecutor<T, I, K, O, Option<HoodieCompactionPlan>> {
 
-  private static final Logger LOG = LogManager.getLogger(FlinkScheduleCompactionActionExecutor.class);
+  private static final Logger LOG = LogManager.getLogger(ScheduleCompactionActionExecutor.class);
 
   private final Option<Map<String, String>> extraMetadata;
+  private final HoodieCompactor compactor;
 
-  public FlinkScheduleCompactionActionExecutor(HoodieEngineContext context,
-                                               HoodieWriteConfig config,
-                                               HoodieTable<T, List<HoodieRecord<T>>, List<HoodieKey>, List<WriteStatus>> table,
-                                               String instantTime,
-                                               Option<Map<String, String>> extraMetadata) {
-    super(context, config, table, instantTime, extraMetadata);
+  public ScheduleCompactionActionExecutor(HoodieEngineContext context,
+                                          HoodieWriteConfig config,
+                                          HoodieTable<T, I, K, O> table,
+                                          String instantTime,
+                                          Option<Map<String, String>> extraMetadata,
+                                          HoodieCompactor compactor) {
+    super(context, config, table, instantTime);
     this.extraMetadata = extraMetadata;
+    this.compactor = compactor;
   }
 
   @Override
-  protected HoodieCompactionPlan scheduleCompaction() {
+  public Option<HoodieCompactionPlan> execute() {

Review comment:
       Not related to this refactoring but wanted to get opinions from you guys. 
   I tried something about async compaction scheduling in a separate job and found it's difficult. Cause we need to generate the compaction plan when we put the compaction.request in the timeline. I was wondering if we can separate the compaction instant creation and compaction plan generation. e.g. We can drop the `ts2.compaction.request` after the `ts1.deltacomit.inflight`, when ts1 completed, `ts3.deltacommit.inflight` will see the `ts2.compaction.request` and cut the file slice to a new log file, then when we actually executing the ts2 compaction, we generate the compaction plan on run time. Do you guys think this is ok for async compaction scheduling?

##########
File path: hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/HoodieTable.java
##########
@@ -366,12 +367,13 @@ public HoodieActiveTimeline getActiveTimeline() {
   /**
    * Run Compaction on the table. Compaction arranges the data so that it is optimized for data access.
    *
-   * @param context HoodieEngineContext
+   * @param context               HoodieEngineContext
    * @param compactionInstantTime Instant Time
+   * @param writeClient           Write client
    */
   public abstract HoodieWriteMetadata<O> compact(HoodieEngineContext context,
-                                              String compactionInstantTime);
-
+                                                 String compactionInstantTime,
+                                                 AbstractHoodieWriteClient writeClient);

Review comment:
       Should we avoid having WriteClient inside HoodieTable? this looks like a nested dependency.




-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org