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

Improve codecs #33

Merged
merged 18 commits into from
Mar 7, 2022
Merged

Improve codecs #33

merged 18 commits into from
Mar 7, 2022

Conversation

calvinlfer
Copy link
Collaborator

@calvinlfer calvinlfer commented Mar 7, 2022

Divide codecs into 3 parts:

  1. Primitive Encoders and Decoders (as per documentation). Primitives include UdtValue and materialization of any type A that can be derived using 2
  2. User-Defined Types Encoders and Decoders which derive from 1 (note the mutual induction which is necessary to provide valid instances for 3 since you cannot have Rows nested within Rows but you can have UdtValues nested in Rows)
  3. Row Decoders and a Row Component Encoder which also derive from 1

This separation allows us to eliminate writing down derive when it comes to codecs for any structure (be it a Row or a UdtValue).

Special-casing optimizations have been done on Primitive codecs in order to avoid using the generic get or set method whenever possible which results in a lookup to the internal driver codec registry.

For example:
image

Add coverage + coveralls integration into the builds

Improve error messages giving users the opportunity to see exactly what went wrong via DecoderException and the structure that failed to decode.

For example:

implicit val eitherPersonDecoder = CqlRowDecoder[Person].either
cql"SELECT * FROM persons"
  .query[Either[codecs.DecoderException, Person]]
  .execute
  .tap {
    case Left(d: DecoderException) =>
      putStrLn(s"DecoderException: ${d.debug}")
​
    case _ =>
      UIO.unit
   }

Improve compositionality of codecs

@calvinlfer calvinlfer self-assigned this Mar 7, 2022
@calvinlfer calvinlfer merged commit 0450173 into zio1 Mar 7, 2022
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.

None yet

1 participant