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 hashCode and equals to UniformGranularitySpec #1824

Merged
merged 1 commit into from
Oct 26, 2015

Conversation

drcrallen
Copy link
Contributor

  • Also add hashCode != 0 to AllGranularity and NoneGranularity

This was causing some problems in unit tests in some libraries I'm developing.

@@ -62,7 +62,7 @@ public boolean equals(Object o)
@Override
public int hashCode()
{
return 0;
return getClass().hashCode();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain why this is necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise All and None have a hash collision. Minor detail, and I can take it out if people are worried about the impact.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, then we can just make it 0 for none and 1 for all, if collisions are a problem. Seems unnecessary to use class name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to -1, and 1 as per conversation on slack

* Also add hashCode != 0 to AllGranularity and NoneGranularity
@drcrallen drcrallen force-pushed the UniformGranularitySpecHashEquals branch from ce9ca54 to f432b8e Compare October 13, 2015 23:42
@himanshug
Copy link
Contributor

LGTM

@drcrallen drcrallen added this to the 0.9.0 milestone Oct 20, 2015
@fjy
Copy link
Contributor

fjy commented Oct 26, 2015

👍

fjy added a commit that referenced this pull request Oct 26, 2015
Add hashCode and equals to UniformGranularitySpec
@fjy fjy merged commit 5a082b2 into apache:master Oct 26, 2015
@drcrallen drcrallen deleted the UniformGranularitySpecHashEquals branch October 27, 2015 14:26
@gianm gianm modified the milestones: 0.8.3, 0.9.0 Dec 1, 2015
@gianm gianm mentioned this pull request Dec 4, 2015
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.

5 participants