Class MapStateDescriptor<UK,UV>
- java.lang.Object
-
- org.apache.flink.api.common.state.StateDescriptor<MapState<UK,UV>,Map<UK,UV>>
-
- org.apache.flink.api.common.state.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>>
AStateDescriptor
forMapState
. 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 aValueState
, 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 handlenull
values. If the serializer does not supportnull
values, it can be wrapped withNullableSerializer
at the cost of an extra byte in the serialized form.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.flink.api.common.state.StateDescriptor
StateDescriptor.Type
-
-
Field Summary
-
Fields inherited from class org.apache.flink.api.common.state.StateDescriptor
defaultValue, name
-
-
Constructor Summary
Constructors Constructor Description MapStateDescriptor(String name, Class<UK> keyClass, Class<UV> valueClass)
Create a newMapStateDescriptor
with the given name and the given type information.MapStateDescriptor(String name, TypeInformation<UK> keyTypeInfo, TypeInformation<UV> valueTypeInfo)
Create a newMapStateDescriptor
with the given name and the given type information.MapStateDescriptor(String name, TypeSerializer<UK> keySerializer, TypeSerializer<UV> valueSerializer)
Create a newMapStateDescriptor
with the given name and the given type serializers.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TypeSerializer<UK>
getKeySerializer()
Gets the serializer for the keys in the state.StateDescriptor.Type
getType()
TypeSerializer<UV>
getValueSerializer()
Gets the serializer for the values in the state.-
Methods inherited from class org.apache.flink.api.common.state.StateDescriptor
enableTimeToLive, equals, getDefaultValue, getName, getQueryableStateName, getSerializer, getTtlConfig, hashCode, initializeSerializerUnlessSet, initializeSerializerUnlessSet, isQueryable, isSerializerInitialized, setQueryable, toString
-
-
-
-
Constructor Detail
-
MapStateDescriptor
public MapStateDescriptor(String name, TypeSerializer<UK> keySerializer, TypeSerializer<UV> valueSerializer)
Create a newMapStateDescriptor
with the given name and the given type serializers.- Parameters:
name
- The name of theMapStateDescriptor
.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 newMapStateDescriptor
with the given name and the given type information.- Parameters:
name
- The name of theMapStateDescriptor
.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 newMapStateDescriptor
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 theMapStateDescriptor
.keyClass
- The class of the type of keys in the state.valueClass
- The class of the type of values in the state.
-
-
Method Detail
-
getType
public StateDescriptor.Type getType()
-
getKeySerializer
public TypeSerializer<UK> getKeySerializer()
Gets the serializer for the keys in the state.- Returns:
- The serializer for the keys in the state.
-
getValueSerializer
public TypeSerializer<UV> getValueSerializer()
Gets the serializer for the values in the state.- Returns:
- The serializer for the values in the state.
-
-