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

Typelevel Cats based module added #921

Merged
merged 25 commits into from
May 5, 2023
Merged

Typelevel Cats based module added #921

merged 25 commits into from
May 5, 2023

Conversation

yisraelU
Copy link
Contributor

@yisraelU yisraelU commented Apr 21, 2023

A module that provides a Schema Visitor for the Show and Hash typeclasses from Typelevel Cats
Implementation as follows
The general direction for Hash, is to provide a hashcode for data based off its its data model vs a smithy4s implementation detail.
This leads to data wrappers that are not reflective of the model , to be excluded from the hash implementation
*Wherever hashes are combined , this is done using the strategies outlined in MurmurHash3

  • Structs
    • This follows closely the scala implementation for hashing Products . It combines productSeed, the struct ShapeId name, and the hash of all its parts
  • Unions
    • Combination of hash of label and the value
  • Enumerations
    • here an Enumeration is treated as its underlying data type , if its an IntEnum as an integer otherwise a String

@yisraelU yisraelU changed the title cats module added Typelevel Cats based module added Apr 21, 2023
build.sbt Show resolved Hide resolved
@yisraelU
Copy link
Contributor Author

yisraelU commented Apr 25, 2023

@Baccata
Im thinking should the Hash instance of ByteArray be implemented the way it is

_.array.hashCode

Based upon our discussions above it should be different because its wrapped in a case class

In addition should Enumeration use the case class/object formula or the hash of the underlying values , perhaps string value combined with int value

@Baccata
Copy link
Contributor

Baccata commented Apr 26, 2023

Im thinking should the Hash instance of ByteArray be implemented the way it is
Based upon our discussions above it should be different because its wrapped in a case class

In this case the wrapping in a case class is an implementation detail, as opposed to something that's reflected in the metamodel.

When you wrap a piece of data in a structure at the smithy level however, the hashcode driven by the schema (which reflects that smithy-level information) ought to take the wrapping into consideration.

In addition should Enumeration use the case class/object formula or the hash of the underlying values , perhaps string value combined with int value

Good question. For enumeration, I think we should use either the hashcode of the Int value if the enum has the IntEnum hint, or the hashcode of the String value otherwise.

@yisraelU yisraelU marked this pull request as ready for review April 26, 2023 22:28
@yisraelU yisraelU requested a review from lewisjkl April 26, 2023 22:29
@Baccata Baccata merged commit 83fbb92 into series/0.18 May 5, 2023
@Baccata Baccata deleted the cats branch May 5, 2023 14:02
@lewisjkl lewisjkl mentioned this pull request May 8, 2023
@Baccata Baccata mentioned this pull request May 9, 2023
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.

3 participants