cloud-fan commented on a change in pull request #25295: [SPARK-28560][SQL]
Optimize shuffle reader to local shuffle reader when smj converted to bhj in
adaptive execution
URL: https://github.com/apache/spark/pull/25295#discussion_r334369858
##########
File path: core/src/main/scala/org/apache/spark/MapOutputTracker.scala
##########
@@ -893,31 +979,59 @@ private[spark] object MapOutputTracker extends Logging {
startPartition: Int,
endPartition: Int,
statuses: Array[MapStatus],
- useOldFetchProtocol: Boolean): Iterator[(BlockManagerId, Seq[(BlockId,
Long, Int)])] = {
+ useOldFetchProtocol: Boolean,
+ mapId : Option[Int] = None): Iterator[(BlockManagerId, Seq[(BlockId,
Long, Int)])] = {
assert (statuses != null)
val splitsByAddress = new HashMap[BlockManagerId, ListBuffer[(BlockId,
Long, Int)]]
- for ((status, mapIndex) <- statuses.iterator.zipWithIndex) {
- if (status == null) {
- val errorMessage = s"Missing an output location for shuffle $shuffleId"
- logError(errorMessage)
- throw new MetadataFetchFailedException(shuffleId, startPartition,
errorMessage)
- } else {
- for (part <- startPartition until endPartition) {
- val size = status.getSizeForBlock(part)
- if (size != 0) {
- if (useOldFetchProtocol) {
- // While we use the old shuffle fetch protocol, we use mapIndex
as mapId in the
- // ShuffleBlockId.
- splitsByAddress.getOrElseUpdate(status.location, ListBuffer()) +=
- ((ShuffleBlockId(shuffleId, mapIndex, part), size, mapIndex))
- } else {
- splitsByAddress.getOrElseUpdate(status.location, ListBuffer()) +=
- ((ShuffleBlockId(shuffleId, status.mapTaskId, part), size,
mapIndex))
+ mapId match {
+ case (Some(mapId)) =>
+ for ((status, mapIndex) <- statuses.iterator.zipWithIndex.filter(_._2
== mapId)) {
Review comment:
nit:
```
val iter = statuses.iterator.zipWithIndex
for ((status, mapIndex) <- mapId.map(id => iter.filter(_._2 ==
id)).getOrElse(iter))
```
Then we can save a lot of duplicated 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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]