danny0405 commented on code in PR #9012:
URL: https://github.com/apache/hudi/pull/9012#discussion_r1233808423
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/utils/Pipelines.java:
##########
@@ -327,14 +337,51 @@ public static DataStream<HoodieRecord>
rowDataToHoodieRecord(Configuration conf,
*/
public static DataStream<Object> hoodieStreamWrite(Configuration conf,
DataStream<HoodieRecord> dataStream) {
if (OptionsResolver.isBucketIndexType(conf)) {
- WriteOperatorFactory<HoodieRecord> operatorFactory =
BucketStreamWriteOperator.getFactory(conf);
- int bucketNum = conf.getInteger(FlinkOptions.BUCKET_INDEX_NUM_BUCKETS);
- String indexKeyFields = OptionsResolver.getIndexKeyField(conf);
- BucketIndexPartitioner<HoodieKey> partitioner = new
BucketIndexPartitioner<>(bucketNum, indexKeyFields);
- return dataStream.partitionCustom(partitioner, HoodieRecord::getKey)
- .transform(opName("bucket_write", conf),
TypeInformation.of(Object.class), operatorFactory)
- .uid(opUID("bucket_write", conf))
- .setParallelism(conf.getInteger(FlinkOptions.WRITE_TASKS));
+ HoodieIndex.BucketIndexEngineType bucketIndexEngineType =
OptionsResolver.getBucketEngineType(conf);
+ switch (bucketIndexEngineType) {
+ case SIMPLE:
+ int bucketNum =
conf.getInteger(FlinkOptions.BUCKET_INDEX_NUM_BUCKETS);
+ String indexKeyFields = OptionsResolver.getIndexKeyField(conf);
+ BucketIndexPartitioner<HoodieKey> partitioner = new
BucketIndexPartitioner<>(bucketNum, indexKeyFields);
+ return dataStream.partitionCustom(partitioner, HoodieRecord::getKey)
+ .transform(
+ opName("bucket_write", conf),
+ TypeInformation.of(Object.class),
+ BucketStreamWriteOperator.getFactory(conf))
+ .uid(opUID("bucket_write", conf))
+ .setParallelism(conf.getInteger(FlinkOptions.WRITE_TASKS));
+ case CONSISTENT_HASHING:
+ String writeOperation = conf.get(FlinkOptions.OPERATION);
+ switch (WriteOperationType.fromValue(writeOperation)) {
+ case INSERT:
+ case UPSERT:
Review Comment:
We can use `OptionsResolver.isInsertOverwrite`
--
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]