GJL commented on a change in pull request #8804: [FLINK-12883][WIP][runtime] Add elaborated partition release logic URL: https://github.com/apache/flink/pull/8804#discussion_r298231318
########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/failover/flip1/PipelinedRegionComputeUtil.java ########## @@ -0,0 +1,133 @@ +/* + * 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.executiongraph.failover.flip1; + +import org.apache.flink.runtime.executiongraph.failover.flip1.partitionrelease.PipelinedRegion; +import org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Collections; +import java.util.HashSet; +import java.util.IdentityHashMap; +import java.util.Map; +import java.util.Set; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * Utility for computing pipelined regions. + */ +public final class PipelinedRegionComputeUtil { + + private static final Logger LOG = LoggerFactory.getLogger(PipelinedRegionComputeUtil.class); + + public static Set<PipelinedRegion> toPipelinedRegionsSet(final Set<Set<FailoverVertex>> distinctRegions) { + return distinctRegions.stream() + .map(toExecutionVertexIdSet()) + .map(PipelinedRegion::from) + .collect(Collectors.toSet()); + } + + private static Function<Set<FailoverVertex>, Set<ExecutionVertexID>> toExecutionVertexIdSet() { + return failoverVertices -> failoverVertices.stream() + .map(FailoverVertex::getExecutionVertexID) + .collect(Collectors.toSet()); + } + + public static Set<Set<FailoverVertex>> computePipelinedRegions(final FailoverTopology topology) { + // currently we let a job with co-location constraints fail as one region + // putting co-located vertices in the same region with each other can be a future improvement + if (topology.containsCoLocationConstraints()) { + return uniqueRegions(buildOneRegionForAllVertices(topology)); + } + + // we use the map (list -> null) to imitate an IdentityHashSet (which does not exist) + // this helps to optimize the building performance as it uses reference equality Review comment: good catch, fixed ---------------------------------------------------------------- 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] With regards, Apache Git Services
