davidradl commented on code in PR #27446: URL: https://github.com/apache/flink/pull/27446#discussion_r2747042379
########## flink-runtime/src/main/java/org/apache/flink/runtime/io/network/api/writer/AdaptiveLoadBasedRecordWriter.java: ########## @@ -0,0 +1,107 @@ +/* + * 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.io.network.api.writer; + +import org.apache.flink.annotation.Internal; +import org.apache.flink.annotation.VisibleForTesting; +import org.apache.flink.core.io.IOReadableWritable; + +import java.io.IOException; +import java.nio.ByteBuffer; + +/** A record writer based on load of downstream tasks. */ +@Internal +public final class AdaptiveLoadBasedRecordWriter<T extends IOReadableWritable> + extends RecordWriter<T> { + + private final int maxTraverseSize; + + private int currentChannel = -1; + + private final int numberOfSubpartitions; + + AdaptiveLoadBasedRecordWriter( + ResultPartitionWriter writer, long timeout, String taskName, int maxTraverseSize) { + super(writer, timeout, taskName); + this.numberOfSubpartitions = writer.getNumberOfSubpartitions(); + this.maxTraverseSize = Math.min(maxTraverseSize, numberOfSubpartitions); Review Comment: I am wondering why we need `numberOfSubpartitions `and the `maxTraverseSize.` why not set `numberOfSubpartitions to Math.min(maxTraverseSize, numberOfSubpartitions)` and remove `private final int maxTraverseSize;`. then you do not need to check the `maxTraverseSize.` in the logic as the numberOfSubpartitions will always be the minimum, accounting for the maxTraverseSize. Also on a previous response to a review comment you said maxTraverseSize could not be 1, but it could end as one if `numberOfSubpartitions == 1 `due this `Math.min`. We should probably check for the `numberOfSubpartitions == 1` case and not do adaptive processing. -- 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]
