UK
- The type of the keys that can be added to the map state.@PublicEvolving public class MapStateDescriptor<UK,UV> extends StateDescriptor<MapState<UK,UV>,Map<UK,UV>>
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.
StateDescriptor.Type
defaultValue, name
Constructor and Description |
---|
MapStateDescriptor(String name,
Class<UK> keyClass,
Class<UV> valueClass)
Create a new
MapStateDescriptor with the given name and the given type information. |
MapStateDescriptor(String name,
TypeInformation<UK> keyTypeInfo,
TypeInformation<UV> valueTypeInfo)
Create a new
MapStateDescriptor with the given name and the given type information. |
MapStateDescriptor(String name,
TypeSerializer<UK> keySerializer,
TypeSerializer<UV> valueSerializer)
Create a new
MapStateDescriptor with the given name and the given type serializers. |
Modifier and Type | Method and 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.
|
enableTimeToLive, equals, getDefaultValue, getName, getQueryableStateName, getSerializer, getTtlConfig, hashCode, initializeSerializerUnlessSet, initializeSerializerUnlessSet, isQueryable, isSerializerInitialized, setQueryable, toString
public MapStateDescriptor(String name, TypeSerializer<UK> keySerializer, TypeSerializer<UV> valueSerializer)
MapStateDescriptor
with the given name and the given type serializers.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.public MapStateDescriptor(String name, TypeInformation<UK> keyTypeInfo, TypeInformation<UV> valueTypeInfo)
MapStateDescriptor
with the given name and the given type information.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.public MapStateDescriptor(String name, Class<UK> keyClass, Class<UV> valueClass)
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.
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.public StateDescriptor.Type getType()
public TypeSerializer<UK> getKeySerializer()
public TypeSerializer<UV> getValueSerializer()
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.