-
Notifications
You must be signed in to change notification settings - Fork 161
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
Shift to use ordered maps for Schema.Record and Schema.Enumeration #5
Comments
Hey, you could use ListMap
|
thinkharderdev
added a commit
to thinkharderdev/zio-schema
that referenced
this issue
May 6, 2021
thinkharderdev
added a commit
to thinkharderdev/zio-schema
that referenced
this issue
May 6, 2021
Add UnorderedRecord for case classes with arity > 22 and CaseObject for objects Use ListMap for case class encoding to guarantee preserved insert order Use 2.12 compatible SortedMap and ListMap
landlockedsurfer
pushed a commit
to landlockedsurfer/zio-schema
that referenced
this issue
May 28, 2022
* Fixes zio#5: Use SortedMap for generic Record and Enumeration schemas Add UnorderedRecord for case classes with arity > 22 and CaseObject for objects Use ListMap for case class encoding to guarantee preserved insert order Use 2.12 compatible SortedMap and ListMap * Resolve conflicts after rebase * Use ListMap for generic structure encoding * Merge upstream/main * work around yet another jdk8 bug Co-authored-by: thinkharder <thinkharderdev@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently, we are using a
Map
for the keys in records and enumerations, which means that we cannot rely on the key ordering. Yet for some protocols, such as grpc, the ordering is very important: it must be stable and ideally reflected by case class / subtype ordering. In order to accommodate this, we need to switch to a map type that allows linear ordering of keys.Scala has SortedMap, which could be used, but is not really ideal (it wants to order based on a property of the keys, but that would force us to store
(Int, String)
in the map, which is unpleasant to work with). Possibly we could use an ordinary map, together with an array that maintains key ordering; or we could create our own OrderedMap type.The text was updated successfully, but these errors were encountered: