JunRuiLee commented on code in PR #25551: URL: https://github.com/apache/flink/pull/25551#discussion_r1889959234
########## flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/IndexRangeUtilTest.java: ########## @@ -0,0 +1,70 @@ +/* + * 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; + +import org.junit.jupiter.api.Test; + +import java.util.Collection; +import java.util.List; + +import static org.apache.flink.runtime.executiongraph.IndexRangeUtil.mergeIndexRanges; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** Test for {@link IndexRangeUtil}. */ +public class IndexRangeUtilTest { Review Comment: no need be public for junit5 case ########## flink-runtime/src/main/java/org/apache/flink/runtime/deployment/ConsumedSubpartitionContext.java: ########## @@ -0,0 +1,144 @@ +/* + * 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.executiongraph.IndexRange; +import org.apache.flink.runtime.executiongraph.IntermediateResult; +import org.apache.flink.runtime.executiongraph.IntermediateResultPartition; +import org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID; + +import java.io.Serializable; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; + +import static org.apache.flink.util.Preconditions.checkNotNull; +import static org.apache.flink.util.Preconditions.checkState; + +/* + * Helper class used to track and manage the relationships between shuffle descriptors and their + * associated subpartitions. + */ +public class ConsumedSubpartitionContext implements Serializable { + /** The number of consumed shuffle descriptors. */ + private final int numConsumedShuffleDescriptors; + + /** + * A mapping between ranges of consumed shuffle descriptors and their corresponding subpartition + * ranges. + */ + private final Map<IndexRange, IndexRange> consumedShuffleDescriptorToSubpartitionRangeMap; + + ConsumedSubpartitionContext( + int numConsumedShuffleDescriptors, + Map<IndexRange, IndexRange> consumedShuffleDescriptorToSubpartitionRangeMap) { + this.numConsumedShuffleDescriptors = numConsumedShuffleDescriptors; + this.consumedShuffleDescriptorToSubpartitionRangeMap = + checkNotNull(consumedShuffleDescriptorToSubpartitionRangeMap); + } + + public int getNumConsumedShuffleDescriptors() { + return numConsumedShuffleDescriptors; + } + + public Collection<IndexRange> getConsumedShuffleDescriptorRanges() { + return consumedShuffleDescriptorToSubpartitionRangeMap.keySet(); Review Comment: unmodifiableCollection -- 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]
