Interface Serializer

  • All Known Implementing Classes:
    DefaultSerializer

    public interface Serializer
    A contract for serialization and deserialization.
    • Method Detail

      • serialize

        <T> java.lang.Iterable<Buffer> serialize​(java.lang.Iterable<T> source,
                                                 BufferAllocator allocator,
                                                 java.lang.Class<T> type)
        Transforms the passed Iterable such that each contained element of type Serializer is serialized into a Buffer.
        Type Parameters:
        T - The data type to serialize.
        Parameters:
        source - Iterable containing objects to serialize.
        allocator - The BufferAllocator used to allocate Buffers.
        type - The class for Serializer, the object to be serialized.
        Returns:
        A transformed Iterable such that each contained element in the original Iterable is transformed from type Serializer to a Buffer.
      • serialize

        <T> Publisher<Buffer> serialize​(Publisher<T> source,
                                        BufferAllocator allocator,
                                        java.lang.Class<T> type,
                                        java.util.function.IntUnaryOperator bytesEstimator)
        Transforms the passed Publisher such that each contained element of type Serializer is serialized into a Buffer.
        Type Parameters:
        T - The data type to serialize.
        Parameters:
        source - Publisher containing objects to serialize.
        allocator - The BufferAllocator used to allocate Buffers.
        type - The class for Serializer, the object to be serialized.
        bytesEstimator - An IntUnaryOperator that given the last serialized size in bytes, estimates the size of the next object to be serialized in bytes.
        Returns:
        A transformed Publisher such that each contained element in the original Publisher is transformed from type Serializer to a Buffer.
      • serialize

        <T> java.lang.Iterable<Buffer> serialize​(java.lang.Iterable<T> source,
                                                 BufferAllocator allocator,
                                                 java.lang.Class<T> type,
                                                 java.util.function.IntUnaryOperator bytesEstimator)
        Transforms the passed Iterable such that each contained element of type Serializer is serialized into a Buffer.
        Type Parameters:
        T - The data type to serialize.
        Parameters:
        source - Iterable containing objects to serialize.
        allocator - The BufferAllocator used to allocate Buffers.
        type - The class for Serializer, the object to be serialized.
        bytesEstimator - An IntUnaryOperator that given the last serialized size in bytes, estimates the size of the next object to be serialized in bytes.
        Returns:
        A transformed Iterable such that each contained element in the original Iterable is transformed from type Serializer to a Buffer.
      • serialize

        <T> java.lang.Iterable<Buffer> serialize​(java.lang.Iterable<T> source,
                                                 BufferAllocator allocator,
                                                 TypeHolder<T> typeHolder)
        Transforms the passed Iterable such that each contained element of type Serializer is serialized into a Buffer.
        Type Parameters:
        T - The data type to serialize.
        Parameters:
        source - Iterable containing objects to serialize.
        allocator - The BufferAllocator used to allocate Buffers.
        typeHolder - TypeHolder holding the ParameterizedType to be serialized.
        Returns:
        A transformed Iterable such that each contained element in the original Iterable is transformed from type Serializer to a Buffer.
      • serialize

        <T> Publisher<Buffer> serialize​(Publisher<T> source,
                                        BufferAllocator allocator,
                                        TypeHolder<T> typeHolder,
                                        java.util.function.IntUnaryOperator bytesEstimator)
        Transforms the passed Publisher such that each contained element of type Serializer is serialized into a Buffer.
        Type Parameters:
        T - The data type to serialize.
        Parameters:
        source - Publisher containing objects to serialize.
        allocator - The BufferAllocator used to allocate Buffers.
        typeHolder - TypeHolder holding the ParameterizedType to be serialized.
        bytesEstimator - An IntUnaryOperator that given the last serialized size in bytes, estimates the size of the next object to be serialized in bytes.
        Returns:
        A transformed Publisher such that each contained element in the original Publisher is transformed from type Serializer to a Buffer.
      • serialize

        <T> java.lang.Iterable<Buffer> serialize​(java.lang.Iterable<T> source,
                                                 BufferAllocator allocator,
                                                 TypeHolder<T> typeHolder,
                                                 java.util.function.IntUnaryOperator bytesEstimator)
        Transforms the passed Iterable such that each contained element of type Serializer is serialized into a Buffer.
        Type Parameters:
        T - The data type to serialize.
        Parameters:
        source - Iterable containing objects to serialize.
        allocator - The BufferAllocator used to allocate Buffers.
        typeHolder - TypeHolder holding the ParameterizedType to be serialized.
        bytesEstimator - An IntUnaryOperator that given the last serialized size in bytes, estimates the size of the next object to be serialized in bytes.
        Returns:
        A transformed Iterable such that each contained element in the original Iterable is transformed from type Serializer to a Buffer.
      • serialize

        <T> Buffer serialize​(T toSerialize,
                             BufferAllocator allocator)
        Serializes the passed object toSerialize to the returned Buffer.
        Type Parameters:
        T - The data type to serialize.
        Parameters:
        toSerialize - Object to serialize.
        allocator - BufferAllocator to allocate the returned Buffer.
        Returns:
        Buffer containing the serialized representation of toSerialize.
      • serialize

        <T> Buffer serialize​(T toSerialize,
                             BufferAllocator allocator,
                             int bytesEstimate)
        Serializes the passed object toSerialize to the returned Buffer.
        Type Parameters:
        T - The data type to serialize.
        Parameters:
        toSerialize - Object to serialize.
        allocator - BufferAllocator to allocate the returned Buffer.
        bytesEstimate - An estimate for the size in bytes of the serialized representation of toSerialize.
        Returns:
        Buffer containing the serialized representation of toSerialize.
      • serialize

        <T> void serialize​(T toSerialize,
                           Buffer destination)
        Serializes the passed object toSerialize to the passed Buffer.
        Type Parameters:
        T - The data type to serialize.
        Parameters:
        toSerialize - Object to serialize.
        destination - The Buffer to which the serialized representation of toSerialize is written.
      • deserialize

        <T> CloseableIterable<T> deserialize​(java.lang.Iterable<Buffer> source,
                                             TypeHolder<T> typeHolder)
        Applies a deserializer on the passed Iterable to convert into a Iterable of deserialized instances of Serializer. If the source Iterable completes with some left over data in a previously emitted Buffer but not deserialized in an object, then Iterator from the returned Iterable will throw an SerializationException from Iterator.hasNext() after all deserialized instances are emitted.

        If all content has been aggregated into a single Buffer, deserializeAggregated(Buffer, TypeHolder) can be used.

        Type Parameters:
        T - The data type to deserialize.
        Parameters:
        source - Iterable containing Buffers to deserialize.
        typeHolder - TypeHolder holding the ParameterizedType to be deserialized.
        Returns:
        A transformed CloseableIterable such that each contained element in the original Iterable is transformed from type Buffer to an instance of Serializer.
      • deserializeAggregatedSingle

        <T> T deserializeAggregatedSingle​(Buffer serializedData,
                                          java.lang.Class<T> type)
        Deserializes the passed encoded Buffer to a single instance of Serializer.
        Type Parameters:
        T - The data type to deserialize.
        Parameters:
        serializedData - A Buffer containing serialized representation of a single instance of Serializer.
        type - The class for Serializer, the object to be deserialized.
        Returns:
        The deserialized object.
        Throws:
        SerializationException - If the passed Buffer contains an incomplete object or if there is any left over data in the Buffer after the deserialization is complete.
      • deserializeAggregatedSingle

        <T> T deserializeAggregatedSingle​(Buffer serializedData,
                                          TypeHolder<T> typeHolder)
        Deserializes the passed encoded Buffer to a single instance of Serializer.
        Type Parameters:
        T - The data type to deserialize.
        Parameters:
        serializedData - A Buffer containing serialized representation of a single instance of Serializer.
        typeHolder - TypeHolder holding the ParameterizedType to be deserialized.
        Returns:
        The deserialized object.
        Throws:
        SerializationException - If the passed Buffer contains an incomplete object or if there is any left over data in the Buffer after the deserialization is complete.