yuxiqian commented on code in PR #3970:
URL: https://github.com/apache/flink-cdc/pull/3970#discussion_r2020316593


##########
flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-paimon/src/main/java/org/apache/flink/cdc/connectors/paimon/sink/v2/PaimonEventSink.java:
##########
@@ -63,8 +64,16 @@ public DataStream<Event> 
addPreWriteTopology(DataStream<Event> dataStream) {
                 .name("Assign Bucket")
                 // All Events after BucketAssignOperator are decorated with 
BucketWrapper.
                 .partitionCustom(
-                        (bucket, numPartitions) -> bucket % numPartitions,
-                        (event) -> ((BucketWrapper) event).getBucket())
+                        (bucket, numPartitions) -> Math.abs(bucket) % 
numPartitions,
+                        (event) -> {
+                            if (event instanceof BucketWrapperChangeEvent) {

Review Comment:
   It's extremely rare, but `Math.abs(bucket)` still could be negative if 
`bucket = Integer.MIN_VALUE`. What about using `Math.floorMod(bucket, 
numPartitions)` to ensure getting a positive mod result here?



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