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

Fix HashPartitioner's negative result #709

Merged
merged 1 commit into from
Jul 18, 2016

Conversation

ttapjinda
Copy link
Contributor

Issue: I have found that for some Key, the Partition function of HashPartitioner return negative value. After I investigate the issue, I have found that if the fnv's Sum32 function returns 2147483648, which is -2147483648 in int32 and the negative of this will still be -2147483648 causing the negative result returned.

Reproduce: this issue can be reproduced by using "1468509572224" as message's key.

Change:

  • partitioner.go: Apply modulo before checking the negative value to ensure the positive result.
  • partitioner_test.go: Add TestHashPartitionerMinInt32 to test the error case.

Please feel free to suggest the better way to fix this issue.

@eapache
Copy link
Contributor

eapache commented Jul 18, 2016

Nice find, thanks!

@eapache eapache merged commit 4124e96 into IBM:master Jul 18, 2016
eapache added a commit that referenced this pull request Jul 18, 2016
Also remove unnecessary variable.
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