godfreyhe commented on code in PR #22492:
URL: https://github.com/apache/flink/pull/22492#discussion_r1193258928


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/StateMetadata.java:
##########
@@ -0,0 +1,207 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.plan.nodes.exec;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.configuration.ReadableConfig;
+import org.apache.flink.table.api.config.ExecutionConfigOptions;
+import org.apache.flink.util.CollectionUtil;
+import org.apache.flink.util.Preconditions;
+import org.apache.flink.util.TimeUtils;
+
+import 
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator;
+import 
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import 
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import java.time.Duration;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import java.util.stream.Stream;
+
+/**
+ * It is used to describe the state metadata of a stateful operator, which is
+ * serialized/deserialized into/from those {@link
+ * org.apache.flink.table.planner.plan.nodes.exec.stream.StreamExecNode}s that 
can generate stateful
+ * operators. For ExecNodes that generates {@link
+ * org.apache.flink.streaming.api.operators.TwoInputStreamOperator} or {@link
+ * org.apache.flink.streaming.api.operators.MultipleInputStreamOperator}, 
there will be multiple
+ * metadata describing information about each input's state.
+ *
+ * <p>The metadata describes the following attributes.
+ *
+ * <ul>
+ *   <li>{@code stateIndex}: annotates the state is from the i-th input, index 
based on zero
+ *   <li>{@code ttl}: annotates the state retention time for the i-th input's 
state, the time unit
+ *       is ms.
+ *   <li>{@code name}: annotates the state description, such as 
deduplicate-state, join-left-state.
+ * </ul>
+ */
+@Internal
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class StateMetadata {
+    public static final String FIELD_NAME_STATE_INDEX = "index";
+    public static final String FIELD_NAME_STATE_TTL = "ttl";
+    public static final String FIELD_NAME_STATE_NAME = "name";
+
+    @JsonProperty(value = FIELD_NAME_STATE_INDEX, index = 0)
+    private final int stateIndex;
+
+    @JsonProperty(value = FIELD_NAME_STATE_TTL, index = 1)
+    private final Duration stateTtl;
+
+    @JsonProperty(value = FIELD_NAME_STATE_NAME, index = 2)
+    private final String stateName;
+
+    @JsonCreator
+    public StateMetadata(
+            @JsonProperty(FIELD_NAME_STATE_INDEX) int stateIndex,
+            @JsonProperty(FIELD_NAME_STATE_TTL) String stateTtl,
+            @JsonProperty(FIELD_NAME_STATE_NAME) String stateName) {
+        this(
+                stateIndex,
+                TimeUtils.parseDuration(
+                        Preconditions.checkNotNull(stateTtl, "state ttl should 
not be null")),
+                Preconditions.checkNotNull(stateName, "state name should not 
be null"));
+    }
+
+    public StateMetadata(int stateIndex, @Nonnull Duration stateTtl, @Nonnull 
String stateName) {

Review Comment:
   nit: `@Nonnull` will check null value when running, you can improve it in 
the following prs



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