Class ReservoirLongsUnionSerialiser

  • All Implemented Interfaces:
    Serializable, Serialiser<org.apache.datasketches.sampling.ReservoirLongsUnion,​byte[]>, ToBytesSerialiser<org.apache.datasketches.sampling.ReservoirLongsUnion>

    public class ReservoirLongsUnionSerialiser
    extends Object
    implements ToBytesSerialiser<org.apache.datasketches.sampling.ReservoirLongsUnion>
    A ReservoirLongsUnionSerialiser serialises a ReservoirLongsUnion using its toByteArray() method.
    See Also:
    Serialized Form
    • Constructor Detail

      • ReservoirLongsUnionSerialiser

        public ReservoirLongsUnionSerialiser()
    • Method Detail

      • canHandle

        public boolean canHandle​(Class clazz)
        Description copied from interface: Serialiser
        Check 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:
        canHandle in interface Serialiser<org.apache.datasketches.sampling.ReservoirLongsUnion,​byte[]>
        Parameters:
        clazz - the object class to serialise
        Returns:
        boolean true if it can be handled
      • serialise

        public byte[] serialise​(org.apache.datasketches.sampling.ReservoirLongsUnion union)
                         throws SerialisationException
        Description copied from interface: ToBytesSerialiser
        Serialise some object and returns the raw bytes of the serialised form.
        Specified by:
        serialise in interface Serialiser<org.apache.datasketches.sampling.ReservoirLongsUnion,​byte[]>
        Specified by:
        serialise in interface ToBytesSerialiser<org.apache.datasketches.sampling.ReservoirLongsUnion>
        Parameters:
        union - the object to be serialised
        Returns:
        byte[] the serialised bytes
        Throws:
        SerialisationException - if the object fails to serialise
      • deserialise

        public org.apache.datasketches.sampling.ReservoirLongsUnion deserialise​(byte[] bytes)
                                                                         throws SerialisationException
        Description copied from interface: ToBytesSerialiser
        Deserialise an array of bytes into the original object.
        Specified by:
        deserialise in interface Serialiser<org.apache.datasketches.sampling.ReservoirLongsUnion,​byte[]>
        Specified by:
        deserialise in interface ToBytesSerialiser<org.apache.datasketches.sampling.ReservoirLongsUnion>
        Parameters:
        bytes - the bytes to deserialise
        Returns:
        T the deserialised object
        Throws:
        SerialisationException - 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. 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)
      • deserialiseEmpty

        public org.apache.datasketches.sampling.ReservoirLongsUnion deserialiseEmpty()
                                                                              throws SerialisationException
        Description copied from interface: ToBytesSerialiser
        Handle an empty byte array and reconstruct an appropriate representation in T form.
        Specified by:
        deserialiseEmpty in interface Serialiser<org.apache.datasketches.sampling.ReservoirLongsUnion,​byte[]>
        Specified by:
        deserialiseEmpty in interface ToBytesSerialiser<org.apache.datasketches.sampling.ReservoirLongsUnion>
        Returns:
        T the deserialised object
        Throws:
        SerialisationException - if the object fails to deserialise
      • preservesObjectOrdering

        public boolean preservesObjectOrdering()
        Description copied from interface: ToBytesSerialiser
        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 interface Serialiser<org.apache.datasketches.sampling.ReservoirLongsUnion,​byte[]>
        Specified by:
        preservesObjectOrdering in interface ToBytesSerialiser<org.apache.datasketches.sampling.ReservoirLongsUnion>
        Returns:
        true if the serialisation will preserve the order of the T, otherwise false.
      • isConsistent

        public boolean isConsistent()
        Description copied from interface: Serialiser
        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.
        Specified by:
        isConsistent in interface Serialiser<org.apache.datasketches.sampling.ReservoirLongsUnion,​byte[]>
        Returns:
        true if serialisation is consistent for a given object, otherwise false.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object