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

GEODE-5845 Document not to use enums for keys #2605

Merged
merged 2 commits into from Oct 17, 2018

Conversation

Projects
None yet
4 participants
@karensmolermiller
Contributor

karensmolermiller commented Oct 15, 2018

@Bill Review, please.

@Bill

This comment has been minimized.

Contributor

Bill commented Oct 16, 2018

These changes are perfectly clear ✓

Only suggestion I have is to consistently put parenthesis with the method name when referring to hashCode() as a method. When referring to the general concept, I suggest using the compound noun "hash code".

## <a id="managing_data_entry_keys" class="no-quick-link"></a>Keys
The `hashCode()` of the key for a data entry maps the entry
within the region; no duplicates are permitted.

This comment has been minimized.

@upthewaterspout

upthewaterspout Oct 16, 2018

Contributor

This comment about hashcodes is a little confusing - it sounds like no duplicate hashcodes are permitted, which is not true. What are we trying to tell the user about their hashCode method here?

This comment has been minimized.

@upthewaterspout

upthewaterspout Oct 16, 2018

Contributor

Also, since we are stressing that hashCode must return the same value across servers, maybe we should also mention that equals should return the same result on different servers as well?

@@ -49,3 +49,10 @@ The region uses hashing on keys. If you define a custom class to use as a key, f
- `equals`
- `hashCode`. The default `hashCode` inherited from `Object` uses identity, which is different in every system member. In partitioned regions, hashing based on identity puts data in the wrong place. For details, see the Java API documentation for `java.lang.Object`.
Do not base the `hashCode` implementation on an enumerated type
(`enum`) data member within a key.

This comment has been minimized.

@upthewaterspout

upthewaterspout Oct 16, 2018

Contributor

Maybe this should just say - do not call hashCode on an Enum in your hashCode method? You can use an enum, but you'll have to come up with your own way of hashing it.

@karensmolermiller karensmolermiller merged commit 2f5fe0a into apache:develop Oct 17, 2018

@karensmolermiller karensmolermiller deleted the karensmolermiller:feature/GEODE-5845 branch Oct 17, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment