cloud-fan commented on a change in pull request #19788: [SPARK-9853][Core] 
Optimize shuffle fetch of contiguous partition IDs
URL: https://github.com/apache/spark/pull/19788#discussion_r249473311
 
 

 ##########
 File path: 
common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/ExternalShuffleBlockResolver.java
 ##########
 @@ -161,22 +161,69 @@ public void registerExecutor(
     executors.put(fullId, executorInfo);
   }
 
+  // For testing
+  public ManagedBuffer getBlockData(
+      String appId,
+      String execId,
+      int shuffleId,
+      int mapId,
+      int reduceId) {
+    return getBlockData(appId, execId, shuffleId, mapId, reduceId, 1);
+  }
+
   /**
-   * Obtains a FileSegmentManagedBuffer from (shuffleId, mapId, reduceId). We 
make assumptions
-   * about how the hash and sort based shuffles store their data.
+   * Obtains a FileSegmentManagedBuffer from (shuffleId, mapId, reduceId, 
numBlocks). We make
+   * assumptions about how the hash and sort based shuffles store their data.
    */
   public ManagedBuffer getBlockData(
       String appId,
       String execId,
       int shuffleId,
       int mapId,
-      int reduceId) {
+      int reduceId,
+      int numBlocks) {
     ExecutorShuffleInfo executor = executors.get(new AppExecId(appId, execId));
     if (executor == null) {
       throw new RuntimeException(
         String.format("Executor is not registered (appId=%s, execId=%s)", 
appId, execId));
     }
-    return getSortBasedShuffleBlockData(executor, shuffleId, mapId, reduceId);
+    return getSortBasedShuffleBlockData(executor, shuffleId, mapId, reduceId, 
numBlocks);
+  }
+
+  static public boolean isShuffleBlock(String[] blockIdParts) {
+    // length == 4: ShuffleBlockId
+    // length == 5: ShuffleBlockBatchId
+    return (blockIdParts.length == 4 || blockIdParts.length == 5) &&
+      blockIdParts[0].equals("shuffle");
+  }
+
+  static public int[] getBlockIdParts(String blockId) {
+    String[] blockIdParts = blockId.split("_");
+    if (!isShuffleBlock(blockIdParts)) {
+      throw new IllegalArgumentException("Unexpected shuffle block id format: 
" + blockId);
+    }
+    return new int[] { Integer.parseInt(blockIdParts[2]), 
Integer.parseInt(blockIdParts[3]) };
+  }
+
+  static public ArrayList<ArrayList<int[]>> 
mergeContinuousShuffleBlockIds(String[] blockIds) {
 
 Review comment:
   we should add doc to explain the assumption: block ids of same mapper id are 
consecutive in the input `blockIds`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to