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 2020/06/15 19:55:40 UTC

[GitHub] [spark] attilapiros commented on a change in pull request #28618: [SPARK-31801][WIP][API][SHUFFLE] Register map output metadata

attilapiros commented on a change in pull request #28618:
URL: https://github.com/apache/spark/pull/28618#discussion_r440411508



##########
File path: core/src/main/java/org/apache/spark/shuffle/sort/BypassMergeSortShuffleWriter.java
##########
@@ -130,9 +132,13 @@ public void write(Iterator<Product2<K, V>> records) throws IOException {
         .createMapOutputWriter(shuffleId, mapId, numPartitions);
     try {
       if (!records.hasNext()) {
-        partitionLengths = mapOutputWriter.commitAllPartitions();
-        mapStatus = MapStatus$.MODULE$.apply(
-          blockManager.shuffleServerId(), partitionLengths, mapId);
+        mapOutputCommitMessage = mapOutputWriter.commitAllPartitions();
+        taskResult = new MapTaskResult(

Review comment:
       As these lines are repeating you could extract them into a new `def`, like:
   
   ```scala
     protected void setTaskResult(MapOutputCommitMessage mapOutputCommitMessage) {
       taskResult = new MapTaskResult(
           MapStatus$.MODULE$.apply(
               blockManager.shuffleServerId(),
               mapOutputCommitMessage.getPartitionLengths(),
               mapId),
           OptionConverters.toScala(mapOutputCommitMessage.getMapOutputMetadata()));
     }
   ```
   
   With the help of this new `def` and Mockito's spy you can even get rid of the  storing the `mapOutputCommitMessage` for testing purposes only but it has a price (this class cannot be final) for details you can check:
   https://github.com/attilapiros/spark/commit/f4578a31beccca58e8b55120847db014a30159d6
   




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