Package uk.gov.gchq.gaffer.serialisation
Interface ToBytesSerialiser<T>
-
- All Superinterfaces:
Serialiser<T,byte[]>
,Serializable
- All Known Implementing Classes:
AvroSerialiser
,BooleanSerialiser
,BoundedTimestampSetSerialiser
,BytesSerialiser
,CompactRawIntegerSerialiser
,CompactRawLongSerialiser
,CustomMapSerialiser
,DeltaLongTimeSeriesSerialiser
,DoublesSketchSerialiser
,DoublesUnionSerialiser
,EdgeIdSerialiser
,EdgeSerialiser
,ElementIdSerialiser
,ElementSerialiser
,EntityIdSerialiser
,EntitySerialiser
,FreqMapSerialiser
,GroupedPropertiesSerialiser
,HllSketchSerialiser
,HllUnionSerialiser
,HyperLogLogPlusSerialiser
,JavaSerialiser
,KllFloatsSketchSerialiser
,LongsSketchSerialiser
,MapSerialiser
,MultiSerialiser
,NullSerialiser
,OrderedDateSerialiser
,OrderedDoubleSerialiser
,OrderedFloatSerialiser
,OrderedIntegerSerialiser
,OrderedLongSerialiser
,PropertiesSerialiser
,RBMBackedTimestampSetSerialiser
,ReservoirItemsSketchSerialiser
,ReservoirLongsSketchSerialiser
,ReservoirLongsUnionSerialiser
,ReservoirNumbersSketchSerialiser
,ReservoirNumbersUnionSerialiser
,ReservoirStringsSketchSerialiser
,ReservoirStringsUnionSerialiser
,RoaringBitmapSerialiser
,SetSerialiser
,SketchSerialiser
,StringSerialiser
,StringsSketchSerialiser
,StringsSketchSerialiser
,StringsUnionSerialiser
,ToBytesViaStringDeserialiser
,TreeSetStringSerialiser
,TypeSubTypeValueSerialiser
,TypeValueSerialiser
,UnionSerialiser
public interface ToBytesSerialiser<T> extends Serialiser<T,byte[]>
A class that implements this interface is responsible for serialising an object of class T to a byte array, and for deserialising it back again. It must also be able to deal with serialising null values.
-
-
Field Summary
Fields Modifier and Type Field Description static byte[]
EMPTY_BYTES
Handle an incoming null value and generate an appropriatebyte[]
representation.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description T
deserialise(byte[] bytes)
Deprecated.default T
deserialise(byte[] allBytes, int offset, int length)
T
deserialiseEmpty()
Handle an empty byte array and reconstruct an appropriate representation in T form.boolean
preservesObjectOrdering()
Indicates whether the serialisation process preserves the ordering of the T, i.e.byte[]
serialise(T object)
Serialise some object and returns the raw bytes of the serialised form.default byte[]
serialiseNull()
Handle an incoming null value and generate an appropriate byte array representation.-
Methods inherited from interface uk.gov.gchq.gaffer.serialisation.Serialiser
canHandle, isConsistent
-
-
-
-
Method Detail
-
serialiseNull
default byte[] serialiseNull()
Handle an incoming null value and generate an appropriate byte array representation.- Specified by:
serialiseNull
in interfaceSerialiser<T,byte[]>
- Returns:
- byte[] the serialised bytes
-
serialise
byte[] serialise(T object) throws SerialisationException
Serialise some object and returns the raw bytes of the serialised form.- Specified by:
serialise
in interfaceSerialiser<T,byte[]>
- Parameters:
object
- the object to be serialised- Returns:
- byte[] the serialised bytes
- Throws:
SerialisationException
- if the object fails to serialise
-
deserialise
default T deserialise(byte[] allBytes, int offset, int length) throws SerialisationException
- Parameters:
allBytes
- The bytes to be decoded into charactersoffset
- The index of the first byte to decodelength
- The number of bytes to decode- Returns:
- T the deserialised object
- Throws:
SerialisationException
- issues during deserialisation
-
deserialise
@Deprecated T deserialise(byte[] bytes) throws SerialisationException
Deprecated.Deserialise an array of bytes into the original object.- Specified by:
deserialise
in interfaceSerialiser<T,byte[]>
- Parameters:
bytes
- the bytes to deserialise- Returns:
- T the deserialised object
- Throws:
SerialisationException
- if the object fails to deserialiseNote that this implementation is less efficient than using deserialise with an offset and a length, but may still be used if necessary. It has been marked deprecated but will not be removed as it is needed in the Serialiser interface.
- See Also:
deserialise(byte[], int, int)
-
deserialiseEmpty
T deserialiseEmpty() throws SerialisationException
Handle an empty byte array and reconstruct an appropriate representation in T form.- Specified by:
deserialiseEmpty
in interfaceSerialiser<T,byte[]>
- Returns:
- T the deserialised object
- Throws:
SerialisationException
- if the object fails to deserialise
-
preservesObjectOrdering
boolean preservesObjectOrdering()
Indicates whether the serialisation process preserves the ordering of the T, i.e. if x and y are objects of class T, and x is less than y, then this method should return true if the serialised form of x is guaranteed to be less than the serialised form of y (using the standard ordering of byte arrays). If T is not Comparable then this test makes no sense and false should be returned.- Specified by:
preservesObjectOrdering
in interfaceSerialiser<T,byte[]>
- Returns:
- true if the serialisation will preserve the order of the T, otherwise false.
-
-