Writing Scala Codecs for the Java Driver
The text discusses the overhead incurred when using the DataStax Java driver for converting data between Java and Scala during read or write operations. It suggests using native Scala codecs to avoid this overhead, which unfortunately do not exist officially. However, the TypeCodec API in the Java driver can be extended to create custom codecs. The text provides examples of creating such codecs directly in Scala for handling CQL types and demonstrates how to use them with the DataStax Java driver. It also discusses the challenges of dealing with nullable values in Scala and provides solutions using Option[Int] and composite patterns. Finally, it introduces a Type Class pattern to convert implicitly between Java and Scala types for more concise code.
Company
DataStax
Date published
Aug. 8, 2017
Author(s)
Alexandre Dutra
Word count
2396
Language
English
Hacker News points
None found.