Interface Serializer<T>

  • All Known Implementing Classes:
    DoubleSerializer, IdentifierSerializer, LongSerializer

    public interface Serializer<T>
    Interface used by the BackgroundMemoryList to serialise the elements of the list into bytestreams and vice versa. The elements serialised form has to have a constant memory footprint. Otherwise using the BackgroundMemoryList will not work as it relies on the constant sizes to seek in the background storage and calculate the number of elements.
    • Method Detail

      • getElementLength

        long getElementLength()
        Returns:
        The size of each element in serialised form, e.g., for doubles it could be 8 bytes (IEEE format). The result is not allowed to change at runtime
      • serialise

        byte[] serialise​(Object[] objects,
                         int count)
        Convert the given array of elements into their serialised form. Attention: Due to a flaw in Java Generics, this signature cannot be serialise(T[] objects, int count) as this leads to a class cast exception despite the fact that you pass the right array. We kept the Type parameter to get at least a type save deserialise.
        Parameters:
        objects - The array of elements to serialise
        count - The number of elements to serialise
        Returns:
        The elements in their serialised form
      • deserialise

        T[] deserialise​(byte[] bytes)
        Convert a serialised form into an array of elements of the serialiser's type
        Parameters:
        bytes - The byte array to deserialise
        Returns:
        An array of elements deserialised from the given byte array