Myasuka commented on a change in pull request #19229:
URL: https://github.com/apache/flink/pull/19229#discussion_r837024698
##########
File path: 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` 将会失效,因为如果从 TTL
的状态中拿到了默认值,用户无法判断这个值是尚未过期的状态值还是状态过期后拿到的默认值,从而也无法判断状态是否过期,这将导致语义混乱。
Review comment:
I think we should update the chinese transformation with English part
updated.
##########
File path: 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.
+- If enable state TTL configuration, the default value configuration in
`StateDescriptor` will no longer take an effect, since if we get the value that
equals with the default value from TTL state, we can not judge whether the key
is expired, which make the semantics unclear.
Review comment:
How about change like this?
```suggestion
- 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.
```
##########
File path:
flink-core/src/main/java/org/apache/flink/api/common/state/StateDescriptor.java
##########
@@ -103,8 +103,13 @@
/** 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 since user cannot judge whether the returned default value
is for the real
+ * current state value or just itself, which may make the semantics
unclear.
Review comment:
I think the description might be better:
`To make the semantics more clear, user should manually manage the default
value if the contents of the state is {@code null}.`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]