mridulm commented on a change in pull request #32140:
URL: https://github.com/apache/spark/pull/32140#discussion_r646728233
##########
File path:
common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/ExternalBlockHandler.java
##########
@@ -413,6 +466,47 @@ public ManagedBuffer next() {
}
}
+ private class ShuffleChunkManagedBufferIterator implements
Iterator<ManagedBuffer> {
+
+ private int reduceIdx = 0;
+ private int chunkIdx = 0;
+
+ private final String appId;
+ private final int shuffleId;
+ private final int[] reduceIds;
+ private final int[][] chunkIds;
+
+ ShuffleChunkManagedBufferIterator(FetchShuffleBlockChunks msg) {
+ appId = msg.appId;
+ shuffleId = msg.shuffleId;
+ reduceIds = msg.reduceIds;
+ chunkIds = msg.chunkIds;
+ }
+
+ @Override
+ public boolean hasNext() {
+ // reduceIds.length must equal to chunkIds.length, and the passed in
FetchShuffleBlockChunks
+ // must have non-empty reduceIds and chunkIds, see the checking logic in
+ // OneForOneBlockFetcher.
+ assert(reduceIds.length != 0 && reduceIds.length == chunkIds.length);
+ return reduceIdx < reduceIds.length && chunkIdx <
chunkIds[reduceIdx].length;
+ }
+
+ @Override
+ public ManagedBuffer next() {
+ ManagedBuffer block = mergeManager.getMergedBlockData(
+ appId, shuffleId, reduceIds[reduceIdx], chunkIds[reduceIdx][chunkIdx]);
+ if (chunkIdx < chunkIds[reduceIdx].length - 1) {
+ chunkIdx += 1;
+ } else {
+ chunkIdx = 0;
+ reduceIdx += 1;
+ }
+ metrics.blockTransferRateBytes.mark(block != null ? block.size() : 0);
Review comment:
If we dont expect it to be null, make it a precondition and remove the
check then ?
Not sure if this is an artifact of some earlier iteration of the code.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]