Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functionality for custom hash partitioner. #837

Merged
merged 1 commit into from
Feb 27, 2017

Conversation

kruftmeister
Copy link
Contributor

The function NewCustomHashPartitioner is a wrapper around the PartitionerConstructor, allowing for specifying the hash algorithm, which will be used.

Background for the proposed change: messages published on compacted topics by services, written in different languages (Go, Java, etc) end up on different partitions, although they have the same key. We were able to narrow the problem down to different hashing algorithms used by the different libraries, when determining the partition: murmur2 for a Java lib, FNV in sarama, crc32 for .NET and xxHash in librdkafka.
A quick workaround is of course to copy/paste the hashPartitioner implementation to change the implementation of the hash.Hash32 interface ...which is basically one line out of ~50. So I decided I'd propose this PR to facilitate the use of different hashing algorithms, based on specific needs.

The wrapper function NewCustomHashPartitioner is a wrapper around the PartitionerConstructor, allowing for specifying the hash algorithm, which will be used.
@eapache
Copy link
Contributor

eapache commented Feb 27, 2017

Thanks, this makes sense to me.

It was a couple of years ago now, but I swear we chose FNV at the time because that's what the upstream kafka libs were using. I'm surprised to see so much variation now. Anyway.

@eapache eapache merged commit a71bff8 into IBM:master Feb 27, 2017
@kruftmeister
Copy link
Contributor Author

Thanks! I can now update to the new version and get rid of the crufty current solution I mentioned above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants