Class SortedMapSerializer<K,​V>

  • Type Parameters:
    K - The type of the keys in the map.
    V - The type of the values in the map.
    All Implemented Interfaces:
    Serializable

    public final class SortedMapSerializer<K,​V>
    extends org.apache.flink.api.common.typeutils.TypeSerializer<M>
    A serializer for SortedMap. The serializer relies on a key serializer and a value serializer for the serialization of the map's key-value pairs. It also deploys a comparator to ensure the order of the keys.

    The serialization format for the map is as follows: four bytes for the length of the map, followed by the serialized representation of each key-value pair. To allow null values, each value is prefixed by a null flag.

    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      SortedMapSerializer​(Comparator<K> comparator, org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer, org.apache.flink.api.common.typeutils.TypeSerializer<V> valueSerializer)
      Constructor with given comparator, and the serializers for the keys and values in the map.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      M copy​(M from)  
      M copy​(M from, M reuse)  
      void copy​(org.apache.flink.core.memory.DataInputView source, org.apache.flink.core.memory.DataOutputView target)  
      SortedMap<K,​V> createInstance()  
      M deserialize​(M reuse, org.apache.flink.core.memory.DataInputView source)  
      M deserialize​(org.apache.flink.core.memory.DataInputView source)  
      org.apache.flink.api.common.typeutils.TypeSerializer<SortedMap<K,​V>> duplicate()  
      boolean equals​(Object o)  
      Comparator<K> getComparator()
      Returns the comparator for the keys in the map.
      org.apache.flink.api.common.typeutils.TypeSerializer<K> getKeySerializer()
      Returns the serializer for the keys in the map.
      int getLength()  
      org.apache.flink.api.common.typeutils.TypeSerializer<V> getValueSerializer()
      Returns the serializer for the values in the map.
      int hashCode()  
      boolean isImmutableType()  
      void serialize​(M map, org.apache.flink.core.memory.DataOutputView target)  
      org.apache.flink.api.common.typeutils.TypeSerializerSnapshot<SortedMap<K,​V>> snapshotConfiguration()  
      String toString()  
    • Constructor Detail

      • SortedMapSerializer

        public SortedMapSerializer​(Comparator<K> comparator,
                                   org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer,
                                   org.apache.flink.api.common.typeutils.TypeSerializer<V> valueSerializer)
        Constructor with given comparator, and the serializers for the keys and values in the map.
        Parameters:
        comparator - The comparator for the keys in the map.
        keySerializer - The serializer for the keys in the map.
        valueSerializer - The serializer for the values in the map.
    • Method Detail

      • getComparator

        public Comparator<K> getComparator()
        Returns the comparator for the keys in the map.
        Returns:
        The comparator for the keys in the map.
      • duplicate

        public org.apache.flink.api.common.typeutils.TypeSerializer<SortedMap<K,​V>> duplicate()
        Specified by:
        duplicate in class org.apache.flink.api.common.typeutils.TypeSerializer<SortedMap<K,​V>>
      • createInstance

        public SortedMap<K,​V> createInstance()
        Specified by:
        createInstance in class org.apache.flink.api.common.typeutils.TypeSerializer<SortedMap<K,​V>>
      • equals

        public boolean equals​(Object o)
      • hashCode

        public int hashCode()
      • snapshotConfiguration

        public org.apache.flink.api.common.typeutils.TypeSerializerSnapshot<SortedMap<K,​V>> snapshotConfiguration()
        Specified by:
        snapshotConfiguration in class org.apache.flink.api.common.typeutils.TypeSerializer<SortedMap<K,​V>>
      • getKeySerializer

        public org.apache.flink.api.common.typeutils.TypeSerializer<K> getKeySerializer()
        Returns the serializer for the keys in the map.
        Returns:
        The serializer for the keys in the map.
      • getValueSerializer

        public org.apache.flink.api.common.typeutils.TypeSerializer<V> getValueSerializer()
        Returns the serializer for the values in the map.
        Returns:
        The serializer for the values in the map.
      • isImmutableType

        public boolean isImmutableType()
        Specified by:
        isImmutableType in class org.apache.flink.api.common.typeutils.TypeSerializer<M extends Map<K,​V>>
      • copy

        public M copy​(M from)
        Specified by:
        copy in class org.apache.flink.api.common.typeutils.TypeSerializer<M extends Map<K,​V>>
      • copy

        public M copy​(M from,
                      M reuse)
        Specified by:
        copy in class org.apache.flink.api.common.typeutils.TypeSerializer<M extends Map<K,​V>>
      • getLength

        public int getLength()
        Specified by:
        getLength in class org.apache.flink.api.common.typeutils.TypeSerializer<M extends Map<K,​V>>
      • serialize

        public void serialize​(M map,
                              org.apache.flink.core.memory.DataOutputView target)
                       throws IOException
        Specified by:
        serialize in class org.apache.flink.api.common.typeutils.TypeSerializer<M extends Map<K,​V>>
        Throws:
        IOException
      • deserialize

        public M deserialize​(org.apache.flink.core.memory.DataInputView source)
                      throws IOException
        Specified by:
        deserialize in class org.apache.flink.api.common.typeutils.TypeSerializer<M extends Map<K,​V>>
        Throws:
        IOException
      • deserialize

        public M deserialize​(M reuse,
                             org.apache.flink.core.memory.DataInputView source)
                      throws IOException
        Specified by:
        deserialize in class org.apache.flink.api.common.typeutils.TypeSerializer<M extends Map<K,​V>>
        Throws:
        IOException
      • copy

        public void copy​(org.apache.flink.core.memory.DataInputView source,
                         org.apache.flink.core.memory.DataOutputView target)
                  throws IOException
        Specified by:
        copy in class org.apache.flink.api.common.typeutils.TypeSerializer<M extends Map<K,​V>>
        Throws:
        IOException