Github user JoshRosen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/4708#discussion_r25145518
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/DAGScheduler.scala 
---
    @@ -830,39 +836,39 @@ class DAGScheduler(
         try {
           // For ShuffleMapTask, serialize and broadcast (rdd, shuffleDep).
           // For ResultTask, serialize and broadcast (rdd, func).
    -      val taskBinaryBytes: Array[Byte] =
    -        if (stage.isShuffleMap) {
    -          closureSerializer.serialize((stage.rdd, stage.shuffleDep.get) : 
AnyRef).array()
    -        } else {
    -          closureSerializer.serialize((stage.rdd, 
stage.resultOfJob.get.func) : AnyRef).array()
    -        }
    +      val taskBinaryBytes: Array[Byte] = stage match {
    +        case a: ShuffleMapStage =>
    +          closureSerializer.serialize((a.rdd, a.shuffleDep): 
AnyRef).array()
    +        case b: ResultStage =>
    +          closureSerializer.serialize((b.rdd, b.resultOfJob.get.func): 
AnyRef).array()
    +      }
    +
           taskBinary = sc.broadcast(taskBinaryBytes)
         } catch {
           // In the case of a failure during serialization, abort the stage.
           case e: NotSerializableException =>
             abortStage(stage, "Task not serializable: " + e.toString)
             runningStages -= stage
    -        return
           case NonFatal(e) =>
             abortStage(stage, s"Task serialization failed: 
$e\n${e.getStackTraceString}")
             runningStages -= stage
    -        return
         }
     
    -    val tasks: Seq[Task[_]] = if (stage.isShuffleMap) {
    -      partitionsToCompute.map { id =>
    -        val locs = getPreferredLocs(stage.rdd, id)
    -        val part = stage.rdd.partitions(id)
    -        new ShuffleMapTask(stage.id, taskBinary, part, locs)
    -      }
    -    } else {
    -      val job = stage.resultOfJob.get
    -      partitionsToCompute.map { id =>
    -        val p: Int = job.partitions(id)
    -        val part = stage.rdd.partitions(p)
    -        val locs = getPreferredLocs(stage.rdd, p)
    -        new ResultTask(stage.id, taskBinary, part, locs, id)
    -      }
    +    val tasks: Seq[Task[_]] = stage match {
    +      case a: ShuffleMapStage =>
    --- End diff --
    
    It's legal to have a case statement where multiple branches use the same 
variable name (because there's no fall-through):
    
    ```scala
    scala> def foo(x: Any) = x match {
         | case y: String => y
         | case y: Int => y * 2
         | }
    foo: (x: Any)Any
    
    scala> foo(1)
    res1: Any = 2
    
    scala> foo("hello")
    res2: Any = hello
    ```
    
    Therefore, I think it would be clearer to replace `a` and `b` with `stage` 
(this will also reduce the size of the diff).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to