Class RoaringBitmapSerialiser
- java.lang.Object
-
- uk.gov.gchq.gaffer.bitmap.serialisation.RoaringBitmapSerialiser
-
- All Implemented Interfaces:
Serializable,Serialiser<org.roaringbitmap.RoaringBitmap,byte[]>,ToBytesSerialiser<org.roaringbitmap.RoaringBitmap>
public class RoaringBitmapSerialiser extends Object implements ToBytesSerialiser<org.roaringbitmap.RoaringBitmap>
ASerialiserimplementation forRoaringBitmapinstances.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface uk.gov.gchq.gaffer.serialisation.ToBytesSerialiser
EMPTY_BYTES
-
-
Constructor Summary
Constructors Constructor Description RoaringBitmapSerialiser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanHandle(Class clazz)Check whether the serialiser can serialise a particular class.org.roaringbitmap.RoaringBitmapdeserialise(byte[] bytes)Deserialise an array of bytes into the original object.org.roaringbitmap.RoaringBitmapdeserialise(byte[] allBytes, int offset, int length)org.roaringbitmap.RoaringBitmapdeserialiseEmpty()Handle an empty byte array and reconstruct an appropriate representation in T form.booleanequals(Object obj)inthashCode()booleanisConsistent()Indicates whether the serialisation process produces a predictable, consistent OUTPUT, from a given INPUT, ie the same object should always serialise in the same way for this to be true.booleanpreservesObjectOrdering()Indicates whether the serialisation process preserves the ordering of the T, i.e.byte[]serialise(org.roaringbitmap.RoaringBitmap object)Serialise some object and returns the raw bytes of the serialised form.byte[]serialiseNull()Handle an incoming null value and generate an appropriate byte array representation.
-
-
-
Method Detail
-
canHandle
public boolean canHandle(Class clazz)
Description copied from interface:SerialiserCheck whether the serialiser can serialise a particular class.//Warning: Due to erasure you may get false positives. e.g.
Set<Foo> set = Sets.newHashSet(); boolean b = new Serialiser<Set<Bar>, byte[]>().canHandle(set.getClass()); b will incorrectly be true because of type erasure between Set<Foo> Set<Bar>- Specified by:
canHandlein interfaceSerialiser<org.roaringbitmap.RoaringBitmap,byte[]>- Parameters:
clazz- the object class to serialise- Returns:
- boolean true if it can be handled
-
serialise
public byte[] serialise(org.roaringbitmap.RoaringBitmap object) throws SerialisationExceptionDescription copied from interface:ToBytesSerialiserSerialise some object and returns the raw bytes of the serialised form.- Specified by:
serialisein interfaceSerialiser<org.roaringbitmap.RoaringBitmap,byte[]>- Specified by:
serialisein interfaceToBytesSerialiser<org.roaringbitmap.RoaringBitmap>- Parameters:
object- the object to be serialised- Returns:
- byte[] the serialised bytes
- Throws:
SerialisationException- if the object fails to serialise
-
deserialise
public org.roaringbitmap.RoaringBitmap deserialise(byte[] allBytes, int offset, int length) throws SerialisationException- Specified by:
deserialisein interfaceToBytesSerialiser<org.roaringbitmap.RoaringBitmap>- 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
public org.roaringbitmap.RoaringBitmap deserialise(byte[] bytes) throws SerialisationExceptionDescription copied from interface:ToBytesSerialiserDeserialise an array of bytes into the original object.- Specified by:
deserialisein interfaceSerialiser<org.roaringbitmap.RoaringBitmap,byte[]>- Specified by:
deserialisein interfaceToBytesSerialiser<org.roaringbitmap.RoaringBitmap>- 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:
ToBytesSerialiser.deserialise(byte[], int, int)
-
preservesObjectOrdering
public boolean preservesObjectOrdering()
Description copied from interface:ToBytesSerialiserIndicates 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:
preservesObjectOrderingin interfaceSerialiser<org.roaringbitmap.RoaringBitmap,byte[]>- Specified by:
preservesObjectOrderingin interfaceToBytesSerialiser<org.roaringbitmap.RoaringBitmap>- Returns:
- true if the serialisation will preserve the order of the T, otherwise false.
-
isConsistent
public boolean isConsistent()
Description copied from interface:SerialiserIndicates whether the serialisation process produces a predictable, consistent OUTPUT, from a given INPUT, ie the same object should always serialise in the same way for this to be true.- Specified by:
isConsistentin interfaceSerialiser<org.roaringbitmap.RoaringBitmap,byte[]>- Returns:
- true if serialisation is consistent for a given object, otherwise false.
-
deserialiseEmpty
public org.roaringbitmap.RoaringBitmap deserialiseEmpty()
Description copied from interface:ToBytesSerialiserHandle an empty byte array and reconstruct an appropriate representation in T form.- Specified by:
deserialiseEmptyin interfaceSerialiser<org.roaringbitmap.RoaringBitmap,byte[]>- Specified by:
deserialiseEmptyin interfaceToBytesSerialiser<org.roaringbitmap.RoaringBitmap>- Returns:
- T the deserialised object
-
serialiseNull
public byte[] serialiseNull()
Description copied from interface:ToBytesSerialiserHandle an incoming null value and generate an appropriate byte array representation.- Specified by:
serialiseNullin interfaceSerialiser<org.roaringbitmap.RoaringBitmap,byte[]>- Specified by:
serialiseNullin interfaceToBytesSerialiser<org.roaringbitmap.RoaringBitmap>- Returns:
- byte[] the serialised bytes
-
-