MCPcopy
hub / github.com/IBM/sarama / NewMurmur2Partitioner

Function NewMurmur2Partitioner

partitioner.go:263–265  ·  view source on GitHub ↗

NewMurmur2Partitioner returns a Partitioner that replicates the partitioning behavior of the Apache Kafka Java client's DefaultPartitioner. It uses the murmur2 hash algorithm with the formula: (murmur2(keyBytes) & 0x7fffffff) % numPartitions This guarantees that a given key is always routed to th

(topic string)

Source from the content-addressed store, hash-verified

261// Java producer using the default partitioner, enabling cross-language partition
262// affinity. If the message key is nil a random partition is chosen.
263func NewMurmur2Partitioner(topic string) Partitioner {
264 return &murmur2Partitioner{random: NewRandomPartitioner(topic)}
265}
266
267func (p *murmur2Partitioner) Partition(message *ProducerMessage, numPartitions int32) (int32, error) {
268 if message.Key == nil {

Callers 2

TestMurmur2PartitionerFunction · 0.85

Calls 1

NewRandomPartitionerFunction · 0.85

Tested by 2

TestMurmur2PartitionerFunction · 0.68