LadyForest commented on code in PR #22593:
URL: https://github.com/apache/flink/pull/22593#discussion_r1215346477


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/StateMetadata.java:
##########
@@ -84,22 +84,23 @@ public StateMetadata(
                 stateIndex,
                 TimeUtils.parseDuration(
                         Preconditions.checkNotNull(stateTtl, "state ttl should 
not be null")),
-                Preconditions.checkNotNull(stateName, "state name should not 
be null"));
+                stateName);
     }
 
-    public StateMetadata(int stateIndex, @Nonnull Duration stateTtl, @Nonnull 
String stateName) {
+    public StateMetadata(int stateIndex, Duration stateTtl, String stateName) {
         Preconditions.checkArgument(stateIndex >= 0, "state index should start 
from 0");
         this.stateIndex = stateIndex;
-        this.stateTtl = stateTtl;
-        this.stateName = stateName;
+        this.stateTtl = Preconditions.checkNotNull(stateTtl, "state ttl should 
not be null");
+        this.stateName = Preconditions.checkNotNull(stateName, "state name 
should not be null");
     }
 
     public int getStateIndex() {
         return stateIndex;
     }
 
-    public long getStateTtl() {
-        return stateTtl.toMillis();
+    @JsonGetter(value = "ttl")
+    public String getStateTtl() {
+        return TimeUtils.formatWithHighestUnit(stateTtl);
     }
 
     public String getStateName() {

Review Comment:
   > Can this method removed?
   
   The reason to add this method is that `stateTtl` is a type of `Duration,` 
and if we don't provide a customized `JsonGetter,` it'll be serialized with 
`Duration#toString` by default. So the output will be like "PT24H". 
   
   E.g.
   
   ```java
   Duration time = Duration.ofDays(1);
   System.out.println(time.toString());
   ```



-- 
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]

Reply via email to