Class SortedMapSerializer<K,V>

java.lang.Object
org.apache.flink.api.common.typeutils.TypeSerializer<M>
org.apache.flink.table.runtime.typeutils.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:
  • Constructor Details

    • 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 Details

    • 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()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • 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 SortedMap<K,V> copy(SortedMap<K,V> from)
      Specified by:
      copy in class org.apache.flink.api.common.typeutils.TypeSerializer<M extends Map<K,V>>
    • copy

      public SortedMap<K,V> copy(SortedMap<K,V> from, SortedMap<K,V> 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(SortedMap<K,V> 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 SortedMap<K,V> 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 SortedMap<K,V> deserialize(SortedMap<K,V> 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