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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]