Allow user to register custom type codecs


Final decision:

Please refer to the online documentation for details:

Initial ticket description:

A common request is to support deserialization of query results to other types (e.g. dates as JDK 8 dates). Currently users can call getBytesUnsafe and add their logic in a separate utility method, but it would be more convenient if this was integrated in the API.

We could expose the TypeCodec type and allow custom implementations to be registered with the cluster:

Then we would have new getters on GettableData. I can see the case where multiple custom codecs would have the same target type, so it's probably best to pass the codec class as a type token:

Some experimentation is still needed to sort out the details:

  • does the API above work with generic result types?

  • how do we deal with the protocol version on the 2.1 branch?

  • what about variable binding? (in particular for simple statements, where the type of the target column is unknown)

  • handling collections, i.e. make List<T> work when only a Codec<T> is provided, not a Codec<List<T>>



Pull Requests



Alex Dutra
July 23, 2015, 11:13 AM

The PR is now stable. Please read the following documents for information about the current state of code:

README file:

Upgrade Guide (with summary of API breaking changes):



Alex Dutra


Olivier Michallat

Fix versions