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

    https://github.com/apache/spark/pull/5622#discussion_r28836457
  
    --- Diff: 
core/src/main/scala/org/apache/spark/util/collection/ExternalSorter.scala ---
    @@ -732,19 +730,24 @@ private[spark] class ExternalSorter[K, V, C](
           // this simple we spill out the current in-memory collection so that 
everything is in files.
           spillToPartitionFiles(if (aggregator.isDefined) map else buffer)
           partitionWriters.foreach(_.commitAndClose())
    -      val out = new FileOutputStream(outputFile, true)
           val writeStartTime = System.nanoTime
           util.Utils.tryWithSafeFinally {
             for (i <- 0 until numPartitions) {
    -          val in = new 
FileInputStream(partitionWriters(i).fileSegment().file)
    -          util.Utils.tryWithSafeFinally {
    -            lengths(i) = org.apache.spark.util.Utils.copyStream(in, out, 
false, transferToEnabled)
    -          } {
    -            in.close()
    +          val file = partitionWriters(i).fileSegment().file
    +          if (!file.exists()) {
    +            lengths(i) = 0
    +          } else {
    +            val out = new FileOutputStream(outputFile, true)
    --- End diff --
    
    this should be opened only once not once per partition


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