This class is used to serialise and deserialise multiple object types.
This overcomes the limitation of a graph schema requiring all vertex types
to use the same serialiser.
The serialiser used is stored at the first byte of the serialised byte[]
The maximum number of different serialiser keys that can be used is limited to 256 (the size of a byte).
byte array [42,*,*,*,*,*]
^
^
serialiser byte key
When multiple serialisers that operate on the same value type are added,
the last one to be added will be used for serialisation. This happens
regardless of the key value used when adding to the MultiSerialiser (shown in example)
For deserialising the correct serialiser is always chosen based on the byte key at the start of the byte[].
In the below example, the MultiSerialiser has 3 Integer serialisers.
There is backwards compatibility to deserialise all three byte arrays. However
when re-serialising the Integer object, only the last serialiser will be used (key 8, OrderedIntegerSerialiser)
This allows the MultiSerialiser to be updated with improvements and maintain backwards compatibility.
Json
{
"serialisers" : [ {
"key" : 0,
"serialiser" : {
"class" : "uk.gov.gchq.gaffer.serialisation.implementation.StringSerialiser",
"charset" : "UTF-8"
},
"valueClass" : "java.lang.String"
}, {
"key" : 7,
"serialiser" : {
"class" : "uk.gov.gchq.gaffer.serialisation.IntegerSerialiser",
"charset" : "ISO-8859-1"
},
"valueClass" : "java.lang.Integer"
}, {
"key" : 24,
"serialiser" : {
"class" : "uk.gov.gchq.gaffer.serialisation.implementation.raw.RawIntegerSerialiser"
},
"valueClass" : "java.lang.Integer"
}, {
"key" : 8,
"serialiser" : {
"class" : "uk.gov.gchq.gaffer.serialisation.implementation.ordered.OrderedIntegerSerialiser"
},
"valueClass" : "java.lang.Integer"
} ]
}