Class MapStateDescriptor<UK,​UV>

  • Type Parameters:
    UK - The type of the keys that can be added to the map state.
    All Implemented Interfaces:
    Serializable

    @PublicEvolving
    public class MapStateDescriptor<UK,​UV>
    extends StateDescriptor<MapState<UK,​UV>,​Map<UK,​UV>>
    A StateDescriptor for MapState. This can be used to create state where the type is a map that can be updated and iterated over.

    Using MapState is typically more efficient than manually maintaining a map in a ValueState, because the backing implementation can support efficient updates, rather then replacing the full map on write.

    To create keyed map state (on a KeyedStream), use RuntimeContext.getMapState(MapStateDescriptor).

    Note: The map state with TTL currently supports null user values only if the user value serializer can handle null values. If the serializer does not support null values, it can be wrapped with NullableSerializer at the cost of an extra byte in the serialized form.

    See Also:
    Serialized Form
    • Constructor Detail

      • MapStateDescriptor

        public MapStateDescriptor​(String name,
                                  TypeSerializer<UK> keySerializer,
                                  TypeSerializer<UV> valueSerializer)
        Create a new MapStateDescriptor with the given name and the given type serializers.
        Parameters:
        name - The name of the MapStateDescriptor.
        keySerializer - The type serializer for the keys in the state.
        valueSerializer - The type serializer for the values in the state.
      • MapStateDescriptor

        public MapStateDescriptor​(String name,
                                  TypeInformation<UK> keyTypeInfo,
                                  TypeInformation<UV> valueTypeInfo)
        Create a new MapStateDescriptor with the given name and the given type information.
        Parameters:
        name - The name of the MapStateDescriptor.
        keyTypeInfo - The type information for the keys in the state.
        valueTypeInfo - The type information for the values in the state.
      • MapStateDescriptor

        public MapStateDescriptor​(String name,
                                  Class<UK> keyClass,
                                  Class<UV> valueClass)
        Create a new MapStateDescriptor with the given name and the given type information.

        If this constructor fails (because it is not possible to describe the type via a class), consider using the MapStateDescriptor(String, TypeInformation, TypeInformation) constructor.

        Parameters:
        name - The name of the MapStateDescriptor.
        keyClass - The class of the type of keys in the state.
        valueClass - The class of the type of values in the state.