This is an automated email from the ASF dual-hosted git repository.

tangyun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/master by this push:
     new 5045f1f  [FLINK-26738][state] Mark StateDescriptor#defaultValue as 
deprecated with clear docs
5045f1f is described below

commit 5045f1f68687785b472536bfa041b09e9e896816
Author: Mulavar <978007...@qq.com>
AuthorDate: Thu Mar 24 21:42:20 2022 +0800

    [FLINK-26738][state] Mark StateDescriptor#defaultValue as deprecated with 
clear docs
    
    This closes #19229.
---
 docs/content.zh/docs/dev/datastream/fault-tolerance/state.md |  2 ++
 docs/content/docs/dev/datastream/fault-tolerance/state.md    |  2 ++
 .../org/apache/flink/api/common/state/StateDescriptor.java   | 12 ++++++++++--
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/docs/content.zh/docs/dev/datastream/fault-tolerance/state.md 
b/docs/content.zh/docs/dev/datastream/fault-tolerance/state.md
index ac260aa..8e20490 100644
--- a/docs/content.zh/docs/dev/datastream/fault-tolerance/state.md
+++ b/docs/content.zh/docs/dev/datastream/fault-tolerance/state.md
@@ -383,6 +383,8 @@ Heap state backend 会额外存储一个包括用户状态以及时间戳的 Jav
 
 - 当前开启 TTL 的 map state 仅在用户值序列化器支持 null 的情况下,才支持用户值为 null。如果用户值序列化器不支持 null,
 可以用 `NullableSerializer` 包装一层。
+  
+- 启用 TTL 配置后,`StateDescriptor` 中的 `defaultValue`(已被标记 
`deprecated`)将会失效。这个设计的目的是为了确保语义更加清晰,在此基础上,用户需要手动管理那些实际值为 null 或已过期的状态默认值。
 
 #### 过期数据的清理
 
diff --git a/docs/content/docs/dev/datastream/fault-tolerance/state.md 
b/docs/content/docs/dev/datastream/fault-tolerance/state.md
index 9cc3e23..5af6e26 100644
--- a/docs/content/docs/dev/datastream/fault-tolerance/state.md
+++ b/docs/content/docs/dev/datastream/fault-tolerance/state.md
@@ -432,6 +432,8 @@ will lead to compatibility failure and 
`StateMigrationException`.
 - 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.
 
+- With TTL enabled configuration, the `defaultValue` in `StateDescriptor`, 
which is atucally already deprecated, will no longer take an effect. This aims 
to make the semantics more clear and let user manually manage the default value 
if the contents of the state is null or expired.
+
 #### Cleanup of Expired State
 
 By default, expired values are explicitly removed on read, such as 
`ValueState#value`, and periodically garbage collected
diff --git 
a/flink-core/src/main/java/org/apache/flink/api/common/state/StateDescriptor.java
 
b/flink-core/src/main/java/org/apache/flink/api/common/state/StateDescriptor.java
index 4af9b44..309abfb 100644
--- 
a/flink-core/src/main/java/org/apache/flink/api/common/state/StateDescriptor.java
+++ 
b/flink-core/src/main/java/org/apache/flink/api/common/state/StateDescriptor.java
@@ -103,8 +103,13 @@ public abstract class StateDescriptor<S extends State, T> 
implements Serializabl
     /** The configuration of state time-to-live(TTL), it is disabled by 
default. */
     @Nonnull private StateTtlConfig ttlConfig = StateTtlConfig.DISABLED;
 
-    /** The default value returned by the state when no other value is bound 
to a key. */
-    @Nullable protected transient T defaultValue;
+    /**
+     * The default value returned by the state when no other value is bound to 
a key.
+     *
+     * @deprecated To make the semantics more clear, user should manually 
manage the default value
+     *     if the contents of the state is {@code null}
+     */
+    @Nullable @Deprecated protected transient T defaultValue;
 
     // ------------------------------------------------------------------------
 
@@ -260,6 +265,9 @@ public abstract class StateDescriptor<S extends State, T> 
implements Serializabl
      * <p>State user value will expire, become unavailable and be cleaned up 
in storage depending on
      * configured {@link StateTtlConfig}.
      *
+     * <p>If enabling the TTL configuration, the field {@link 
StateDescriptor#defaultValue} will be
+     * invalid.
+     *
      * @param ttlConfig configuration of state TTL
      */
     public void enableTimeToLive(StateTtlConfig ttlConfig) {

Reply via email to