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 2022/04/20 08:11:30 UTC

[GitHub] [hudi] wxplovecc commented on a diff in pull request #5362: [HUDI-3918] Improve flink bulk_insert perform for partitioned table

wxplovecc commented on code in PR #5362:
URL: https://github.com/apache/hudi/pull/5362#discussion_r853851616


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/utils/Pipelines.java:
##########
@@ -102,9 +102,15 @@ public static DataStreamSink<Object> bulkInsert(Configuration conf, RowType rowT
       InternalTypeInfo<RowData> typeInfo = InternalTypeInfo.of(rowTypeWithFileId);
 
       Map<String, String> bucketIdToFileId = new HashMap<>();
-      dataStream = dataStream.partitionCustom(partitioner, keyGen::getRecordKey)
-          .map(record -> BucketBulkInsertWriterHelper.rowWithFileId(bucketIdToFileId, keyGen, record, indexKeys, numBuckets), typeInfo)
-          .setParallelism(conf.getInteger(FlinkOptions.WRITE_TASKS)); // same parallelism as write task to avoid shuffle
+      if (OptionsResolver.isPartitionedTable(conf)) {
+        dataStream = dataStream.keyBy(keyGen::getPartitionPath)
+                .map(record -> BucketBulkInsertWriterHelper.rowWithFileId(bucketIdToFileId, keyGen, record, indexKeys, numBuckets), typeInfo)
+                .setParallelism(conf.getInteger(FlinkOptions.WRITE_TASKS)); // same parallelism as write task to avoid shuffle
+      } else {
+        dataStream = dataStream.partitionCustom(partitioner, keyGen::getRecordKey)
+                .map(record -> BucketBulkInsertWriterHelper.rowWithFileId(bucketIdToFileId, keyGen, record, indexKeys, numBuckets), typeInfo)

Review Comment:
   > Why shuffle the input with partition path first ?
   
   - Shuffle with custom partitioner was not friendly to partition table with less bucket (eg. partition by day and 1 bucket),It only use 1 write task
   - Make sure the same partition processed in same task avoid duplicated fileId



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