Class StateDescriptor<T>
- java.lang.Object
-
- org.apache.flink.api.common.state.v2.StateDescriptor<T>
-
- Type Parameters:
T- The type of the value of the state object described by this state descriptor.
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AggregatingStateDescriptor,ListStateDescriptor,MapStateDescriptor,ReducingStateDescriptor,ValueStateDescriptor
@Experimental public abstract class StateDescriptor<T> extends Object implements Serializable
Base class for state descriptors. AStateDescriptoris used for creating partitioned State in stateful operations internally.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classStateDescriptor.TypeAn enumeration of the types of supported states.
-
Constructor Summary
Constructors Modifier Constructor Description protectedStateDescriptor(String name, Class<T> type)Create a newStateDescriptorwith the given name and the given type information.protectedStateDescriptor(String stateId, TypeInformation<T> typeInfo)Create a newStateDescriptorwith the given stateId and the given type information.protectedStateDescriptor(String stateId, TypeSerializer<T> serializer)Create a newStateDescriptorwith the given stateId and the given type serializer.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidenableTimeToLive(StateTtlConfig ttlConfig)Configures optional activation of state time-to-live (TTL).booleanequals(Object o)TypeSerializer<T>getSerializer()StringgetStateId()StateTtlConfiggetTtlConfig()abstract StateDescriptor.TypegetType()Return the specificTypeof described state.TypeInformation<T>getTypeInformation()inthashCode()voidinitializeSerializerUnlessSet(ExecutionConfig executionConfig)Initializes the serializer, unless it has been initialized before.voidinitializeSerializerUnlessSet(SerializerFactory serializerFactory)booleanisSerializerInitialized()Checks whether the serializer has been initialized.StringtoString()
-
-
-
Constructor Detail
-
StateDescriptor
protected StateDescriptor(@Nonnull String stateId, @Nonnull TypeInformation<T> typeInfo)Create a newStateDescriptorwith the given stateId and the given type information.- Parameters:
stateId- The stateId of theStateDescriptor.typeInfo- The type information for the values in the state.
-
StateDescriptor
protected StateDescriptor(@Nonnull String stateId, TypeSerializer<T> serializer)Create a newStateDescriptorwith the given stateId and the given type serializer.- Parameters:
stateId- The stateId of theStateDescriptor.serializer- The type serializer for the values in the state.
-
StateDescriptor
protected StateDescriptor(String name, Class<T> type)
Create a newStateDescriptorwith 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
StateDescriptor(String, TypeInformation)constructor.- Parameters:
name- The name of theStateDescriptor.type- The class of the type of values in the state.
-
-
Method Detail
-
enableTimeToLive
public void enableTimeToLive(StateTtlConfig ttlConfig)
Configures optional activation of state time-to-live (TTL).State user value will expire, become unavailable and be cleaned up in storage depending on configured
StateTtlConfig.- Parameters:
ttlConfig- configuration of state TTL
-
getTtlConfig
@Nonnull public StateTtlConfig getTtlConfig()
-
getStateId
@Nonnull public String getStateId()
-
getSerializer
@Nonnull public TypeSerializer<T> getSerializer()
-
getTypeInformation
@Internal @Nullable public TypeInformation<T> getTypeInformation()
-
isSerializerInitialized
public boolean isSerializerInitialized()
Checks whether the serializer has been initialized. Serializer initialization is lazy, to allow parametrization of serializers with anExecutionConfigviainitializeSerializerUnlessSet(ExecutionConfig).- Returns:
- True if the serializers have been initialized, false otherwise.
-
initializeSerializerUnlessSet
public void initializeSerializerUnlessSet(ExecutionConfig executionConfig)
Initializes the serializer, unless it has been initialized before.- Parameters:
executionConfig- The execution config to use when creating the serializer.
-
initializeSerializerUnlessSet
@Internal public void initializeSerializerUnlessSet(SerializerFactory serializerFactory)
-
getType
@Internal public abstract StateDescriptor.Type getType()
Return the specificTypeof described state.
-
-