danny0405 commented on a change in pull request #3203:
URL: https://github.com/apache/hudi/pull/3203#discussion_r728695624



##########
File path: 
hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/utils/HoodieRealtimeInputFormatUtils.java
##########
@@ -69,17 +70,18 @@
   private static final Logger LOG = 
LogManager.getLogger(HoodieRealtimeInputFormatUtils.class);
 
   public static InputSplit[] getRealtimeSplits(Configuration conf, 
Stream<FileSplit> fileSplits) throws IOException {
-    Map<Path, List<FileSplit>> partitionsToParquetSplits =
-        fileSplits.collect(Collectors.groupingBy(split -> 
split.getPath().getParent()));
+    // for all unique split parents, obtain all delta files based on delta 
commit timeline,
+    // grouped on file id
+    List<InputSplit> rtSplits = new ArrayList<>();
+    List<FileSplit> candidateFileSplits = 
fileSplits.collect(Collectors.toList());
+    Map<Path, List<FileSplit>> partitionsToParquetSplits = candidateFileSplits

Review comment:
       `candidateFileSplits` => `fileSplitList`

##########
File path: 
hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/realtime/HoodieParquetRealtimeInputFormat.java
##########
@@ -119,6 +307,11 @@ void addProjectionToJobConf(final RealtimeSplit 
realtimeSplit, final JobConf job
     addProjectionToJobConf(realtimeSplit, jobConf);
     LOG.info("Creating record reader with readCols :" + 
jobConf.get(ColumnProjectionUtils.READ_COLUMN_NAMES_CONF_STR)
         + ", Ids :" + 
jobConf.get(ColumnProjectionUtils.READ_COLUMN_IDS_CONF_STR));
+
+    // for log only split, we no need parquet reader, set it to empty
+    if (FSUtils.isLogFile(realtimeSplit.getPath())) {

Review comment:
       `we no need parquet reader, set it to empty` => `set the parquet reader 
as empty`

##########
File path: 
hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/realtime/HoodieEmptyRecordReader.java
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.hadoop.realtime;
+
+import org.apache.hadoop.io.ArrayWritable;
+import org.apache.hadoop.io.NullWritable;
+import org.apache.hadoop.io.Writable;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapred.RecordReader;
+
+import java.io.IOException;
+
+/**
+ * dummy record for log only realtime split.
+ */

Review comment:
       `dummy record` => `Dummy record reader`

##########
File path: 
hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/utils/HoodieRealtimeInputFormatUtils.java
##########
@@ -99,7 +101,32 @@
         }
       }
       Option<HoodieVirtualKeyInfo> finalHoodieVirtualKeyInfo = 
hoodieVirtualKeyInfo;
-      partitionsToParquetSplits.keySet().forEach(partitionPath -> {
+      // deal with incremental query
+      candidateFileSplits.stream().forEach(s -> {
+        try {

Review comment:
       Something like this:
   ```java
     private static Map<Path, List<FileSplit>> filterOutIncrementalSplits(
         List<FileSplit> fileSplitList,
         List<InputSplit> rtSplits,
         final Option<HoodieVirtualKeyInfo> finalHoodieVirtualKeyInfo) {
       return fileSplitList.stream().filter(s -> {
         // deal with incremental query.
         try {
           if (s instanceof BaseFileWithLogsSplit) {
             BaseFileWithLogsSplit bs = (BaseFileWithLogsSplit)s;
             if (bs.getBelongToIncrementalSplit()) {
               rtSplits.add(new HoodieRealtimeFileSplit(bs, bs.getBasePath(), 
bs.getDeltaLogPaths(), bs.getMaxCommitTime(), finalHoodieVirtualKeyInfo));
               return false;
             }
           } else if (s instanceof RealtimeBootstrapBaseFileSplit) {
             rtSplits.add(s);
             return false;
           }
         } catch (IOException e) {
           throw new HoodieIOException("Error creating hoodie real time split 
", e);
         }
         return true;
       }).collect(Collectors.groupingBy(split -> split.getPath().getParent()));
     }
   ```

##########
File path: 
hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/utils/HoodieRealtimeInputFormatUtils.java
##########
@@ -99,7 +101,32 @@
         }
       }
       Option<HoodieVirtualKeyInfo> finalHoodieVirtualKeyInfo = 
hoodieVirtualKeyInfo;
-      partitionsToParquetSplits.keySet().forEach(partitionPath -> {
+      // deal with incremental query
+      candidateFileSplits.stream().forEach(s -> {
+        try {

Review comment:
       Can we abstract this filtering logic out as a separate tool method ?

##########
File path: 
hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/utils/HoodieRealtimeInputFormatUtils.java
##########
@@ -99,7 +101,32 @@
         }
       }
       Option<HoodieVirtualKeyInfo> finalHoodieVirtualKeyInfo = 
hoodieVirtualKeyInfo;
-      partitionsToParquetSplits.keySet().forEach(partitionPath -> {
+      // deal with incremental query
+      candidateFileSplits.stream().forEach(s -> {
+        try {

Review comment:
       And the only usage of `partitionsToParquetSplits` it so collect the 
partition paths, we can simplify it as a partition path set.




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