From 5b7390c033e2ba76eecd96cc417439f26b586ad9 Mon Sep 17 00:00:00 2001 From: Felix Geller Date: Sat, 9 Sep 2023 14:17:12 +0200 Subject: [PATCH] produce: tweaks --- produce.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/produce.go b/produce.go index 496dc3a..49dc1b7 100644 --- a/produce.go +++ b/produce.go @@ -346,16 +346,13 @@ func (cmd *produceCmd) deserializeLines(in chan string, out chan message, partit } var part int32 = 0 - if msg.Value != nil && cmd.partitioner == "hashCodeByValue" { - part = hashCodePartition(*msg.Value, partitionCount) - msg.Partition = &part - } else { - if msg.Key != nil && cmd.partitioner == "hashCode" { + if msg.Partition == nil { + if msg.Value != nil && cmd.partitioner == "hashCodeByValue" { + part = hashCodePartition(*msg.Value, partitionCount) + } else if msg.Key != nil && cmd.partitioner == "hashCode" { part = hashCodePartition(*msg.Key, partitionCount) } - if msg.Partition == nil { - msg.Partition = &part - } + msg.Partition = &part } out <- msg