public class SketchSerialiser extends Object implements ToBytesSerialiser<com.yahoo.sketches.theta.Sketch>
SketchSerialiser serialises a Sketch using its
toByteArray().EMPTY_BYTES| Constructor and Description |
|---|
SketchSerialiser() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canHandle(Class clazz)
Check whether the serialiser can serialise a particular class.
|
com.yahoo.sketches.theta.Sketch |
deserialise(byte[] bytes)
Deserialise an array of bytes into the original object.
|
com.yahoo.sketches.theta.Sketch |
deserialiseEmpty()
Handle an empty byte array and reconstruct an appropriate representation in T form.
|
boolean |
equals(Object obj) |
int |
hashCode() |
boolean |
isConsistent()
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.
|
boolean |
preservesObjectOrdering()
Indicates whether the serialisation process preserves the ordering of the T,
i.e.
|
byte[] |
serialise(com.yahoo.sketches.theta.Sketch sketch)
Serialise some object and returns the raw bytes of the serialised form.
|
getClass, notify, notifyAll, toString, wait, wait, waitdeserialise, serialiseNullpublic boolean canHandle(Class clazz)
Serialiser//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>
canHandle in interface Serialiser<com.yahoo.sketches.theta.Sketch,byte[]>clazz - the object class to serialisepublic byte[] serialise(com.yahoo.sketches.theta.Sketch sketch)
throws SerialisationException
ToBytesSerialiserserialise in interface Serialiser<com.yahoo.sketches.theta.Sketch,byte[]>serialise in interface ToBytesSerialiser<com.yahoo.sketches.theta.Sketch>sketch - the object to be serialisedSerialisationException - if the object fails to serialisepublic com.yahoo.sketches.theta.Sketch deserialise(byte[] bytes)
throws SerialisationException
ToBytesSerialiserdeserialise in interface Serialiser<com.yahoo.sketches.theta.Sketch,byte[]>deserialise in interface ToBytesSerialiser<com.yahoo.sketches.theta.Sketch>bytes - the bytes to deserialiseSerialisationException - if the object fails to deserialise
Note that this implementation is less efficient than using deserialise with an offset and a length, but may still be used if necessary.
ToBytesSerialiser.deserialise(byte[], int, int)public com.yahoo.sketches.theta.Sketch deserialiseEmpty()
throws SerialisationException
ToBytesSerialiserdeserialiseEmpty in interface Serialiser<com.yahoo.sketches.theta.Sketch,byte[]>deserialiseEmpty in interface ToBytesSerialiser<com.yahoo.sketches.theta.Sketch>SerialisationException - if the object fails to deserialisepublic boolean preservesObjectOrdering()
ToBytesSerialiserpreservesObjectOrdering in interface Serialiser<com.yahoo.sketches.theta.Sketch,byte[]>preservesObjectOrdering in interface ToBytesSerialiser<com.yahoo.sketches.theta.Sketch>public boolean isConsistent()
SerialiserisConsistent in interface Serialiser<com.yahoo.sketches.theta.Sketch,byte[]>Copyright © 2022. All rights reserved.