Class StateDescriptor<S extends org.apache.flink.api.common.state.State,​T>

    • Field Detail

      • name

        protected final String name
        Name that uniquely identifies state created from this StateDescriptor.
      • defaultValue

        @Nullable
        @Deprecated
        protected transient T defaultValue
        Deprecated.
        To make the semantics more clear, user should manually manage the default value if the contents of the state is null
        The default value returned by the state when no other value is bound to a key.
    • Constructor Detail

      • StateDescriptor

        protected StateDescriptor​(String name,
                                  TypeSerializer<T> serializer,
                                  @Nullable
                                  T defaultValue)
        Create a new StateDescriptor with the given name and the given type serializer.
        Parameters:
        name - The name of the StateDescriptor.
        serializer - The type serializer for the values in the state.
        defaultValue - The default value that will be set when requesting state without setting a value before.
      • StateDescriptor

        protected StateDescriptor​(String name,
                                  TypeInformation<T> typeInfo,
                                  @Nullable
                                  T defaultValue)
        Create a new StateDescriptor with the given name and the given type information.
        Parameters:
        name - The name of the StateDescriptor.
        typeInfo - The type information for the values in the state.
        defaultValue - The default value that will be set when requesting state without setting a value before.
      • StateDescriptor

        protected StateDescriptor​(String name,
                                  Class<T> type,
                                  @Nullable
                                  T defaultValue)
        Create a new StateDescriptor 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 StateDescriptor(String, TypeInformation, Object) constructor.

        Parameters:
        name - The name of the StateDescriptor.
        type - The class of the type of values in the state.
        defaultValue - The default value that will be set when requesting state without setting a value before.
    • Method Detail

      • getName

        public String getName()
        Returns the name of this StateDescriptor.
      • getDefaultValue

        public T getDefaultValue()
        Returns the default value.
      • setQueryable

        @Deprecated
        public void setQueryable​(String queryableStateName)
        Deprecated.
        The Queryable State feature is deprecated since Flink 1.18, and will be removed in a future Flink major version.
        Sets the name for queries of state created from this descriptor.

        If a name is set, the created state will be published for queries during runtime. The name needs to be unique per job. If there is another state instance published under the same name, the job will fail during runtime.

        Parameters:
        queryableStateName - State name for queries (unique name per job)
        Throws:
        IllegalStateException - If queryable state name already set
      • getQueryableStateName

        @Nullable
        @Deprecated
        public String getQueryableStateName()
        Deprecated.
        The Queryable State feature is deprecated since Flink 1.18, and will be removed in a future Flink major version.
        Returns the queryable state name.
        Returns:
        Queryable state name or null if not set.
      • isQueryable

        @Deprecated
        public boolean isQueryable()
        Deprecated.
        The Queryable State feature is deprecated since Flink 1.18, and will be removed in a future Flink major version.
        Returns whether the state created from this descriptor is queryable.
        Returns:
        true if state is queryable, false otherwise.
      • 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.

        If enabling the TTL configuration, the field defaultValue will be invalid.

        Parameters:
        ttlConfig - configuration of state TTL
      • isSerializerInitialized

        public boolean isSerializerInitialized()
        Checks whether the serializer has been initialized. Serializer initialization is lazy, to allow parametrization of serializers with an ExecutionConfig via initializeSerializerUnlessSet(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)
      • hashCode

        public final int hashCode()
        Overrides:
        hashCode in class Object