edu05 commented on a change in pull request #11952: URL: https://github.com/apache/flink/pull/11952#discussion_r418310429
########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/jobgraph/OperatorIdPairList.java ########## @@ -0,0 +1,69 @@ +/* + * 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.runtime.jobgraph; + +import org.apache.flink.runtime.OperatorIdPair; + +import java.io.Serializable; +import java.util.AbstractList; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * Convenience class to encapsulate the operator ID pairs of a job vertex. It is convenient because it hides + * away the creation of a new list for only operator IDs or user defined operator IDs. + * It also hides the iteration over operator ID pairs. + */ +public class OperatorIdPairList extends AbstractList<OperatorIdPair> implements Serializable { Review comment: done ########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/jobgraph/JobVertex.java ########## @@ -143,27 +145,27 @@ public JobVertex(String name) { public JobVertex(String name, JobVertexID id) { this.name = name == null ? DEFAULT_NAME : name; this.id = id == null ? new JobVertexID() : id; - // the id lists must have the same size - this.operatorIDs.add(OperatorID.fromJobVertexID(this.id)); - this.operatorIdsAlternatives.add(null); + OperatorIdPair operatorIdPair = new OperatorIdPair(OperatorID.fromJobVertexID(this.id), null); + this.operatorIdPairList = new OperatorIdPairList(Collections.singletonList(operatorIdPair)); } /** * Constructs a new job vertex and assigns it with the given name. * * @param name The name of the new job vertex. * @param primaryId The id of the job vertex. - * @param alternativeIds The alternative ids of the job vertex. * @param operatorIds The ids of all operators contained in this job vertex. * @param alternativeOperatorIds The alternative ids of all operators contained in this job vertex- */ - public JobVertex(String name, JobVertexID primaryId, List<JobVertexID> alternativeIds, List<OperatorID> operatorIds, List<OperatorID> alternativeOperatorIds) { + public JobVertex(String name, JobVertexID primaryId, List<OperatorID> operatorIds, List<OperatorID> alternativeOperatorIds) { Preconditions.checkArgument(operatorIds.size() == alternativeOperatorIds.size()); this.name = name == null ? DEFAULT_NAME : name; this.id = primaryId == null ? new JobVertexID() : primaryId; - this.idAlternatives.addAll(alternativeIds); - this.operatorIDs.addAll(operatorIds); - this.operatorIdsAlternatives.addAll(alternativeOperatorIds); + List<OperatorIdPair> operatorIdPairs = new ArrayList<>(); + for (int i = 0; i < operatorIds.size(); i++) { + operatorIdPairs.add(new OperatorIdPair(operatorIds.get(i), alternativeOperatorIds.get(i))); + } + this.operatorIdPairList = new OperatorIdPairList(operatorIdPairs); Review comment: done ---------------------------------------------------------------- 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: us...@infra.apache.org