dchristle commented on code in PR #84:
URL:
https://github.com/apache/flink-connector-pulsar/pull/84#discussion_r1518922858
##########
flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/enumerator/assigner/SplitAssignerBase.java:
##########
@@ -125,11 +127,12 @@ protected int partitionOwner(TopicPartition partition) {
@VisibleForTesting
static int calculatePartitionOwner(String topic, int partitionId, int
parallelism) {
- int startIndex = ((topic.hashCode() * 31) & 0x7FFFFFFF) % parallelism;
+ // int startIndex = ((topic.hashCode() * 31) & 0x7FFFFFFF) %
parallelism;
/*
* Here, the assumption is that the id of Pulsar partitions are always
ascending starting from
* 0. Therefore, can be used directly as the offset clockwise from the
start index.
*/
- return (startIndex + partitionId) % parallelism;
+ // return (startIndex + partitionId) % parallelism;
+ return idCounter.getAndIncrement() % parallelism;
Review Comment:
This change would make assignment no longer deterministic from the inputs,
since getAndIncrement will increment `idCounter` each time it's called. The use
of `hashCode` should already ensure the partitions are somewhat evenly
distributed across subtasks.
--
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]