You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/03/01 02:12:55 UTC

[GitHub] [spark] seayoun commented on a change in pull request #31643: [SPARK-34534] Fix blockIds order when use FetchShuffleBlocks to fetch blocks

seayoun commented on a change in pull request #31643:
URL: https://github.com/apache/spark/pull/31643#discussion_r584406925



##########
File path: common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/OneForOneBlockFetcher.java
##########
@@ -117,30 +117,40 @@ private FetchShuffleBlocks createFetchShuffleBlocksMsg(
     boolean batchFetchEnabled = firstBlock.length == 5;
 
     HashMap<Long, ArrayList<Integer>> mapIdToReduceIds = new HashMap<>();
+    // The mapIds and reducesIds must be same order with blockIds because the shuffle data's
+    // return order should match the `blockIds` order to ensure blockId and data match.
+    ArrayList<Long> orderedMapId = new ArrayList<>();
     for (String blockId : blockIds) {
       String[] blockIdParts = splitBlockId(blockId);
       if (Integer.parseInt(blockIdParts[1]) != shuffleId) {
         throw new IllegalArgumentException("Expected shuffleId=" + shuffleId +
           ", got:" + blockId);
       }
       long mapId = Long.parseLong(blockIdParts[2]);
+      assert(orderedMapId.isEmpty() || mapId >= orderedMapId.get(orderedMapId.size() - 1));
       if (!mapIdToReduceIds.containsKey(mapId)) {
         mapIdToReduceIds.put(mapId, new ArrayList<>());
+        orderedMapId.add(mapId);
       }
-      mapIdToReduceIds.get(mapId).add(Integer.parseInt(blockIdParts[3]));
+      ArrayList<Integer> reduceIdsByMapId = mapIdToReduceIds.get(mapId);
+      int reduceId = Integer.parseInt(blockIdParts[3]);
+      assert(reduceIdsByMapId.isEmpty()
+              || reduceId > reduceIdsByMapId.get(reduceIdsByMapId.size() - 1));

Review comment:
       done




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org