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

    https://github.com/apache/spark/pull/10815#discussion_r50056614
  
    --- Diff: core/src/main/scala/org/apache/spark/rdd/PairRDDFunctions.scala 
---
    @@ -1196,28 +1198,40 @@ class PairRDDFunctions[K, V](self: RDD[(K, V)])
             writer.close()
           }
           writer.commit()
    -      bytesWrittenCallback.foreach { fn => 
outputMetrics.setBytesWritten(fn()) }
    -      outputMetrics.setRecordsWritten(recordsWritten)
    +      outputMetrics.foreach { om =>
    +        bytesWrittenCallback.foreach { fn => om.setBytesWritten(fn()) }
    +        om.setRecordsWritten(recordsWritten)
    +      }
         }
     
         self.context.runJob(self, writeToFile)
         writer.commitJob()
       }
     
    -  private def initHadoopOutputMetrics(context: TaskContext): 
(OutputMetrics, Option[() => Long]) = {
    +  // TODO: these don't seem like the right abstractions.
    +  // We should abstract the duplicate code in a less awkward way.
    +
    +  private def initHadoopOutputMetrics(
    +      context: TaskContext): (Option[OutputMetrics], Option[() => Long]) = 
{
    --- End diff --
    
    Question RE: return type: as far as I can tell, either both return fields 
will be defined or neither will. To make this more obvious, what about changing 
the return type to `Option[(OutputMetrics, () => Long)]` instead?


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