noorall commented on code in PR #25366:
URL: https://github.com/apache/flink/pull/25366#discussion_r1772511782


##########
flink-runtime/src/main/java/org/apache/flink/streaming/api/graph/util/JobVertexBuildContext.java:
##########
@@ -0,0 +1,138 @@
+/*
+ * 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.streaming.api.graph.util;
+
+import org.apache.flink.runtime.jobgraph.JobVertex;
+import org.apache.flink.runtime.jobgraph.JobVertexID;
+import org.apache.flink.runtime.operators.coordination.OperatorCoordinator;
+import org.apache.flink.streaming.api.graph.StreamEdge;
+import org.apache.flink.streaming.api.graph.StreamGraph;
+import org.apache.flink.util.SerializedValue;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+public class JobVertexBuildContext {
+
+    private final StreamGraph streamGraph;
+
+    /** The {@link OperatorChainInfo}s, key is the start node id of the chain. 
*/
+    private final Map<Integer, OperatorChainInfo> chainInfos;
+
+    /** The {@link OperatorInfo}s, key is the id of the stream node. */
+    private final Map<Integer, OperatorInfo> operatorInfosInorder;
+
+    // The created JobVertex, the key is start node id
+    private final Map<Integer, JobVertex> jobVerticesInorder;
+
+    // Futures for the serialization of operator coordinators
+    private final Map<
+                    JobVertexID,
+                    
List<CompletableFuture<SerializedValue<OperatorCoordinator.Provider>>>>
+            coordinatorSerializationFuturesPerJobVertex;
+
+    // The order of StreamEdge connected to other vertices should be 
consistent with the order in
+    // which JobEdge was created
+    private final List<StreamEdge> physicalEdgesInOrder;
+
+    private final AtomicBoolean hasHybridResultPartition;
+
+    public JobVertexBuildContext(StreamGraph streamGraph, AtomicBoolean 
hasHybridResultPartition) {
+        this.streamGraph = streamGraph;
+        this.chainInfos = new LinkedHashMap<>();
+        this.operatorInfosInorder = new LinkedHashMap<>();
+        this.jobVerticesInorder = new LinkedHashMap<>();
+        this.physicalEdgesInOrder = new ArrayList<>();
+        this.hasHybridResultPartition = hasHybridResultPartition;
+        this.coordinatorSerializationFuturesPerJobVertex = new HashMap<>();
+    }
+
+    public void addChainInfo(Integer startNodeId, OperatorChainInfo chainInfo) 
{
+        chainInfos.put(startNodeId, chainInfo);
+    }
+
+    public OperatorChainInfo getChainInfo(Integer startNodeId) {
+        return chainInfos.get(startNodeId);
+    }
+
+    public Map<Integer, OperatorChainInfo> getChainInfos() {
+        return chainInfos;
+    }
+
+    public OperatorInfo getOperatorInfo(Integer nodeId) {
+        return operatorInfosInorder.get(nodeId);
+    }
+
+    public OperatorInfo getOrCreateOperatorInfo(Integer nodeId) {
+        return operatorInfosInorder.computeIfAbsent(nodeId, key -> new 
OperatorInfo());
+    }

Review Comment:
   You are right, getOrCreateOperatorInfo seems unnecessary.



##########
flink-runtime/src/main/java/org/apache/flink/streaming/api/graph/util/JobVertexBuildContext.java:
##########
@@ -0,0 +1,138 @@
+/*
+ * 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.streaming.api.graph.util;
+
+import org.apache.flink.runtime.jobgraph.JobVertex;
+import org.apache.flink.runtime.jobgraph.JobVertexID;
+import org.apache.flink.runtime.operators.coordination.OperatorCoordinator;
+import org.apache.flink.streaming.api.graph.StreamEdge;
+import org.apache.flink.streaming.api.graph.StreamGraph;
+import org.apache.flink.util.SerializedValue;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+public class JobVertexBuildContext {
+
+    private final StreamGraph streamGraph;
+
+    /** The {@link OperatorChainInfo}s, key is the start node id of the chain. 
*/
+    private final Map<Integer, OperatorChainInfo> chainInfos;
+
+    /** The {@link OperatorInfo}s, key is the id of the stream node. */
+    private final Map<Integer, OperatorInfo> operatorInfosInorder;
+
+    // The created JobVertex, the key is start node id
+    private final Map<Integer, JobVertex> jobVerticesInorder;
+
+    // Futures for the serialization of operator coordinators
+    private final Map<
+                    JobVertexID,
+                    
List<CompletableFuture<SerializedValue<OperatorCoordinator.Provider>>>>
+            coordinatorSerializationFuturesPerJobVertex;
+
+    // The order of StreamEdge connected to other vertices should be 
consistent with the order in
+    // which JobEdge was created
+    private final List<StreamEdge> physicalEdgesInOrder;
+
+    private final AtomicBoolean hasHybridResultPartition;
+
+    public JobVertexBuildContext(StreamGraph streamGraph, AtomicBoolean 
hasHybridResultPartition) {
+        this.streamGraph = streamGraph;
+        this.chainInfos = new LinkedHashMap<>();
+        this.operatorInfosInorder = new LinkedHashMap<>();
+        this.jobVerticesInorder = new LinkedHashMap<>();
+        this.physicalEdgesInOrder = new ArrayList<>();
+        this.hasHybridResultPartition = hasHybridResultPartition;
+        this.coordinatorSerializationFuturesPerJobVertex = new HashMap<>();
+    }
+
+    public void addChainInfo(Integer startNodeId, OperatorChainInfo chainInfo) 
{
+        chainInfos.put(startNodeId, chainInfo);
+    }
+
+    public OperatorChainInfo getChainInfo(Integer startNodeId) {
+        return chainInfos.get(startNodeId);
+    }
+
+    public Map<Integer, OperatorChainInfo> getChainInfos() {
+        return chainInfos;
+    }
+
+    public OperatorInfo getOperatorInfo(Integer nodeId) {
+        return operatorInfosInorder.get(nodeId);
+    }
+
+    public OperatorInfo getOrCreateOperatorInfo(Integer nodeId) {
+        return operatorInfosInorder.computeIfAbsent(nodeId, key -> new 
OperatorInfo());
+    }

Review Comment:
   You are right, getOrCreateOperatorInfo seems unnecessary.



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