Class MapSerializer<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 MapSerializer<K,​V>
    extends org.apache.flink.api.common.typeutils.TypeSerializer<Map<K,​V>>
    A serializer for Map. The serializer relies on a key serializer and a value serializer for the serialization of the map's key-value pairs.

    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 marker.

    See Also:
    Serialized Form
    • Constructor Detail

      • MapSerializer

        public MapSerializer​(org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer,
                             org.apache.flink.api.common.typeutils.TypeSerializer<V> valueSerializer)
        Creates a map serializer that uses the given serializers to serialize the key-value pairs in the map.
        Parameters:
        keySerializer - The serializer for the keys in the map
        valueSerializer - The serializer for the values in the map
    • Method Detail

      • getKeySerializer

        public org.apache.flink.api.common.typeutils.TypeSerializer<K> getKeySerializer()
      • getValueSerializer

        public org.apache.flink.api.common.typeutils.TypeSerializer<V> getValueSerializer()
      • isImmutableType

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

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

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

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

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

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

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

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

        public Map<K,​V> deserialize​(Map<K,​V> reuse,
                                          org.apache.flink.core.memory.DataInputView source)
                                   throws IOException
        Specified by:
        deserialize in class org.apache.flink.api.common.typeutils.TypeSerializer<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<Map<K,​V>>
        Throws:
        IOException
      • equals

        public boolean equals​(Object obj)
        Specified by:
        equals in class org.apache.flink.api.common.typeutils.TypeSerializer<Map<K,​V>>
      • hashCode

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

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