godfreyhe commented on a change in pull request #14729:
URL: https://github.com/apache/flink/pull/14729#discussion_r564643450



##########
File path: 
flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/ExecNodeBase.java
##########
@@ -36,46 +46,97 @@
  *
  * @param <T> The type of the elements that result from this node.
  */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, 
property = "class")
 public abstract class ExecNodeBase<T> implements ExecNode<T> {
 
-    private final String description;
-    private final List<ExecEdge> inputEdges;
-    private final LogicalType outputType;
+    public static final String FIELD_NAME_ID = "id";
+    public static final String FIELD_NAME_CLASS = "class";
+    public static final String FIELD_NAME_DESCRIPTION = "description";
+    public static final String FIELD_NAME_INPUT_EDGES = "inputEdges";
+    public static final String FIELD_NAME_OUTPUT_TYPE = "outputType";
+    public static final String FILED_NAME_INPUTS = "inputs";
+
+    /** The unique identifier for each ExecNode in the json plan. */
+    @JsonIgnore private final int id;
+
+    @JsonIgnore private final String description;
+
+    @JsonIgnore private final List<ExecEdge> inputEdges;
+
+    @JsonIgnore private final LogicalType outputType;
+
     // TODO remove this field once edge support `source` and `target`,
     //  and then we can get/set `inputNodes` through `inputEdges`.
-    private List<ExecNode<?>> inputNodes;
+    @JsonIgnore private List<ExecNode<?>> inputNodes;
 
-    private transient Transformation<T> transformation;
+    @JsonIgnore private transient Transformation<T> transformation;
 
-    protected ExecNodeBase(List<ExecEdge> inputEdges, LogicalType outputType, 
String description) {
+    /** This is used to assign a unique ID to every ExecNode. */
+    private static Integer idCounter = 0;
+
+    /** Generate an unique ID for ExecNode. */
+    public static int getNewNodeId() {
+        idCounter++;
+        return idCounter;
+    }
+
+    // used for json creator
+    protected ExecNodeBase(
+            int id, List<ExecEdge> inputEdges, LogicalType outputType, String 
description) {
+        this.id = id;
         this.inputEdges = new ArrayList<>(checkNotNull(inputEdges));
         this.outputType = checkNotNull(outputType);
         this.description = checkNotNull(description);
     }
 
+    protected ExecNodeBase(List<ExecEdge> inputEdges, LogicalType outputType, 
String description) {
+        this(getNewNodeId(), inputEdges, outputType, description);
+    }
+
+    @JsonProperty(value = FIELD_NAME_ID)
+    @Override
+    public final int getId() {
+        return id;
+    }
+
+    /** The name used to identify each sub-class in the json plan. */
+    @JsonProperty(value = FIELD_NAME_CLASS, access = 
JsonProperty.Access.READ_ONLY)
+    public final String getClassName() {
+        return getClass().getCanonicalName();
+    }
+
+    @JsonProperty(value = FIELD_NAME_DESCRIPTION)

Review comment:
       there are no fields for `getClassName` and `getInputNodes`(`inputNodes` 
will be removed later), putting `JsonProperty` all on `get` method will more 
unified style.




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to