Skip to content

Using a custom Converter

broach edited this page Mar 26, 2012 · 15 revisions

Why would I need a custom Converter?

When storing data in or retrieving data from Riak, a Converter is used to serialize the Java object passed in. When no Converter is specified and you're using your own Domain Object (POJO) the default JSONConverter is used. Behind the scenes this takes your object, uses the Jackson JSON library to serialize it, and stores the resulting JSON text in Riak. This can be advantageous if, for example, you are planning on accessing this data from other (non-java) applications.

If you wanted to use a different serialization library, a custom Converter would be required. Lets look at how you would write a Converter to use the popular Kryo serialization library to serialize and deserialize your objects.

A custom Converter example using Kryo for Serialization and Deserialization