stankiewicz commented on code in PR #36112:
URL: https://github.com/apache/beam/pull/36112#discussion_r2355176635


##########
sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/KafkaIO.java:
##########
@@ -1845,18 +1846,16 @@ public PCollection<KafkaRecord<K, V>> expand(PBegin 
input) {
                 "Offsets committed due to usage of commitOffsetsInFinalize() 
and may not capture all work processed due to use of withRedistribute() with 
duplicates enabled");
           }
 
-          if (kafkaRead.getRedistributeNumKeys() == 0) {
-            return output.apply(
-                "Insert Redistribute",
-                Redistribute.<KafkaRecord<K, V>>arbitrarily()
-                    .withAllowDuplicates(kafkaRead.isAllowDuplicates()));
-          } else {
-            return output.apply(
-                "Insert Redistribute with Shards",
-                Redistribute.<KafkaRecord<K, V>>arbitrarily()
-                    .withAllowDuplicates(kafkaRead.isAllowDuplicates())
-                    .withNumBuckets((int) kafkaRead.getRedistributeNumKeys()));
+          RedistributeArbitrarily<KafkaRecord<K, V>> redistribute =
+              Redistribute.<KafkaRecord<K, V>>arbitrarily()
+                  .withAllowDuplicates(kafkaRead.isAllowDuplicates());
+          if (kafkaRead.getOffsetDeduplication() != null && 
kafkaRead.getOffsetDeduplication()) {
+            redistribute = redistribute.withDeterministicSharding(true);

Review Comment:
   In my opinion Redistribute.RedistributeByKey should be used instead of 
arbitrary. if someone is setting also numKeys, sharding should hash/modulo the 
key.. 



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