-
Notifications
You must be signed in to change notification settings - Fork 19
Serializers
pingles edited this page Sep 28, 2011
·
1 revision
Hector uses Serializers to make it simpler when querying for data from Cassandra which stores keys, names and values as byte arrays.
Most of the get-x
functions (get-columns
for example) have optional arguments that allow the caller to specify the serializer to use for the keys, names and values.
Below is a list of supported serializers
- :integer
- :string
- :bytes
- :long
- :uuid
- :bigint
- :bool
- :date
- :object
- :ascii
- :byte-buffer
- :char
- :double
- :float
- :short
Additionally, it's trivial to write your own serializer (should you wish to). Instead of passing one of the keywords above (as an optional parameter to a function), you can instead pass an instance of an object that implements Hector's Serializer
interface.
The following code shows how to implement a TimeUUID deserializer that you could pass to the get-x
functions:
(proxy [Serializer] []
(fromBytes [b] (TimeUUIDUtils/toUUID b))
(fromByteBuffer [bb] (TimeUUIDUtils/uuid bb)))