reswqa commented on code in PR #21560: URL: https://github.com/apache/flink/pull/21560#discussion_r1060267262
########## flink-runtime/src/main/java/org/apache/flink/runtime/deployment/CachedShuffleDescriptors.java: ########## @@ -0,0 +1,106 @@ +/* + * 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.deployment; + +import org.apache.flink.runtime.deployment.TaskDeploymentDescriptor.MaybeOffloaded; +import org.apache.flink.runtime.executiongraph.IntermediateResultPartition; +import org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID; +import org.apache.flink.runtime.scheduler.strategy.ConsumedPartitionGroup; +import org.apache.flink.runtime.shuffle.ShuffleDescriptor; +import org.apache.flink.util.function.FunctionWithException; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import static org.apache.flink.util.Preconditions.checkArgument; +import static org.apache.flink.util.Preconditions.checkNotNull; + +/** {@link ShuffleDescriptor}s cache for a {@link ConsumedPartitionGroup} */ +public class CachedShuffleDescriptors { + /** + * Stores all serialized shuffle descriptors. For unknown shuffle descriptor, it will be + * replaced by real shuffle descriptor after upstream task finished. + */ + private final List<MaybeOffloaded<ShuffleDescriptor>> serializedShuffleDescriptors; + + /** + * Stores all to be serialized shuffle descriptors, They will be serialized and replace + * corresponding value(unknown shuffle descriptor) in serializedShuffleDescriptors during the + * next time TDD is generated. + */ + private final Map<ShuffleDescriptor, Integer> toBeSerialized; Review Comment: > Why do we need a map? Would it be better to use a queue of tuples? Yes, queue is better than map. > And why not eagerly serialize the descriptor and replace the previous unknown descriptor in `markPartitionFinished`? Because we can not get the serializer during mark partition finished. This is also the reason why `serializeShuffleDescriptors` has param of `shuffleDescriptorSerializer`. -- 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]
