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

    https://github.com/apache/spark/pull/2968#discussion_r19930092
  
    --- Diff: core/src/main/scala/org/apache/spark/rdd/PairRDDFunctions.scala 
---
    @@ -961,30 +962,52 @@ class PairRDDFunctions[K, V](self: RDD[(K, V)])
         }
     
         val writeShard = (context: TaskContext, iter: Iterator[(K,V)]) => {
    +      val config = wrappedConf.value
           // Hadoop wants a 32-bit task attempt ID, so if ours is bigger than 
Int.MaxValue, roll it
           // around by taking a mod. We expect that no task will be attempted 
2 billion times.
           val attemptNumber = (context.attemptId % Int.MaxValue).toInt
           /* "reduce task" <split #> <attempt # = spark task #> */
           val attemptId = newTaskAttemptID(jobtrackerID, stageId, isMap = 
false, context.partitionId,
             attemptNumber)
    -      val hadoopContext = newTaskAttemptContext(wrappedConf.value, 
attemptId)
    +      val hadoopContext = newTaskAttemptContext(config, attemptId)
           val format = outfmt.newInstance
           format match {
    -        case c: Configurable => c.setConf(wrappedConf.value)
    +        case c: Configurable => c.setConf(config)
             case _ => ()
           }
           val committer = format.getOutputCommitter(hadoopContext)
           committer.setupTask(hadoopContext)
    +
    +      val bytesWrittenCallback = 
Option(config.get("mapreduce.output.fileoutputformat.outputdir"))
    +        .map(new Path(_))
    +        .flatMap(SparkHadoopUtil.get.getFSBytesWrittenOnThreadCallback(_, 
config))
    +      val outputMetrics = new OutputMetrics()
    +      if (bytesWrittenCallback.isDefined) {
    +        context.taskMetrics.outputMetrics = Some(outputMetrics)
    +      }
    +
    --- End diff --
    
    Can you move this code and (separately) the code in lines 995 through 1004 
into methods that can be called here and also by saveAsHadoopDataset to avoid 
the code duplication?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to