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)
.
StateDescriptor.Type
defaultValue, name, serializer
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 |
---|---|
MapState<UK,UV> |
bind(StateBinder stateBinder)
Creates a new
State on the given StateBinder . |
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.
|
equals, getDefaultValue, getName, getQueryableStateName, getSerializer, hashCode, 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 MapState<UK,UV> bind(StateBinder stateBinder) throws Exception
StateDescriptor
State
on the given StateBinder
.public StateDescriptor.Type getType()
public TypeSerializer<UK> getKeySerializer()
public TypeSerializer<UV> getValueSerializer()
Copyright © 2014–2019 The Apache Software Foundation. All rights reserved.