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

Hash code updates. #394

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

PaulSandoz
Copy link
Contributor

@PaulSandoz PaulSandoz commented Feb 14, 2019

This pull request contains a number of updates related to the hash code of sets and maps primarily to enable the removal of HollowObjectHashCodeFinder and related hash code functionality at least on the producer side and limited use on the client side (specifically to ensure efficient lookup of elements or keys when using HollowSet or HollowMap until a solution is implemented that can reliably extract a hash key from an object).

  • Support @HollowHashKey and hash key with empty fields for hollow set and map schema. This feature can override the application of a default hash key (see HollowObjectMapper.useDefaultHashKeys which is true by default) when it is required that ordinals be used as the hash code.

  • Allow a consumer to filter out hash keys of set or map schema. The consumer needs to register an instance of HollowObjectHashCodeFinder whose method getTypesWithDefinedHashCodes returns a Set that contains the element or key type of the set or map schema. This is a breaking change for an edge case: prior to this change a set/map with a hash key would override that of HollowObjectHashCodeFinder. However, prior to this change it was not expected that a consumer implement getTypesWithDefinedHashCodes with anything but an empty set.

  • Ensure a map or set whose element or key type is filtered (or not present) can still be processed. Any hash key is ignored since the field paths cannot be resolved.

  • When performing a checksum calculation for a set or map relax the schema equality check for the hash keys if the schema evolved from no hash key to with a hash key. This enables a transition from no hash key (the hash is defined externally using HollowObjectHashCodeFinder) to a hash key (the hash is defined by the hash key on the schema).

  • Ensure a producer can transition (with restoration) from a state where HollowObjectHashCodeFinder was used (and where default hash keys were not enabled) to generate hash codes to where HollowObjectHashCodeFinder is not used (and where where default hash keys are enabled). If hash codes are the same in both cases then the checksum calculation performed in the integrity check stage should not fail.

@PaulSandoz PaulSandoz self-assigned this Feb 14, 2019
@PaulSandoz PaulSandoz requested review from a user, akhaku, dkoszewnik and Sunjeet February 14, 2019 22:04
@PaulSandoz PaulSandoz force-pushed the set-map-hash-code-tests branch 2 times, most recently from 3715b14 to a5fc9b9 Compare February 18, 2019 18:12
@PaulSandoz PaulSandoz force-pushed the set-map-hash-code-tests branch 3 times, most recently from 5e0f859 to 547b8b2 Compare February 19, 2019 23:49
@PaulSandoz
Copy link
Contributor Author

I pushed another commit that:

  • fixes the bug for schema mismatch when applying a checking; and
  • simplifies the field path array argument processing for set and map schema when constructed to explicitly use the ordinal as the hash code.

@PaulSandoz PaulSandoz force-pushed the set-map-hash-code-tests branch from e45ac90 to 3885fd3 Compare February 26, 2019 16:37
Paul Sandoz added 3 commits March 8, 2019 11:03
- Simplfy whether a set or map schema specifies a hash function
for ordinal values of elements or keys
- Fix issue checking for schema mistmatch, and test
This feature seems overly complex and has little value especially
when the deprecated HollowObjectHashCodeFinder is removed.
A declaration of @HollowHashCode(fields = {}) overrides the
default hash key generation for a schema as performed by the
object mapper.
@PaulSandoz PaulSandoz force-pushed the set-map-hash-code-tests branch from 3885fd3 to 9105940 Compare March 8, 2019 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants