wanglijie95 commented on code in PR #21111:
URL: https://github.com/apache/flink/pull/21111#discussion_r1005243287


##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/adaptivebatch/AllToAllBlockingResultInfo.java:
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.scheduler.adaptivebatch;
+
+import org.apache.flink.runtime.executiongraph.ResultPartitionBytes;
+import org.apache.flink.runtime.jobgraph.IntermediateDataSetID;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+import static org.apache.flink.util.Preconditions.checkState;
+
+/** Information of All-To-All result. */
+public class AllToAllBlockingResultInfo implements BlockingResultInfo {
+
+    private final IntermediateDataSetID resultId;
+
+    private final int numOfSubpartitions;
+
+    private final boolean isBroadcast;
+
+    /**
+     * Aggregated subpartition bytes, which aggregates the subpartition bytes 
with the same
+     * subpartition index in different partitions. Note that We can aggregate 
them because they will
+     * be consumed by the same downstream task.
+     */
+    private final long[] aggregatedSubpartitionBytes;
+
+    AllToAllBlockingResultInfo(
+            IntermediateDataSetID resultId, int numOfSubpartitions, boolean 
isBroadcast) {
+        this.resultId = checkNotNull(resultId);
+        this.numOfSubpartitions = numOfSubpartitions;
+        this.isBroadcast = isBroadcast;
+        this.aggregatedSubpartitionBytes = new long[numOfSubpartitions];
+        Arrays.fill(this.aggregatedSubpartitionBytes, 0L);
+    }
+
+    @Override
+    public IntermediateDataSetID getResultId() {
+        return resultId;
+    }
+
+    @Override
+    public boolean isBroadcast() {
+        return isBroadcast;
+    }
+
+    @Override
+    public boolean isPointwise() {
+        return false;
+    }
+
+    @Override
+    public long getNumBytesProduced() {
+        if (isBroadcast) {
+            return aggregatedSubpartitionBytes[0];
+        } else {
+            return Arrays.stream(aggregatedSubpartitionBytes).sum();
+        }
+    }
+
+    @Override
+    public void partitionFinished(int partitionIndex, ResultPartitionBytes 
partitionBytes) {

Review Comment:
   Replied above



-- 
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]

Reply via email to