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

    https://github.com/apache/spark/pull/18684#discussion_r128575547
  
    --- Diff: 
core/src/main/java/org/apache/spark/shuffle/sort/BypassMergeSortShuffleWriter.java
 ---
    @@ -188,17 +189,20 @@ public void write(Iterator<Product2<K, V>> records) 
throws IOException {
           return lengths;
         }
     
    -    final FileOutputStream out = new FileOutputStream(outputFile, true);
    +    final FileChannel out = FileChannel.open(outputFile.toPath(),
    +      ImmutableSet.of(WRITE, APPEND, CREATE));
         final long writeStartTime = System.nanoTime();
         boolean threwException = true;
         try {
           for (int i = 0; i < numPartitions; i++) {
             final File file = partitionWriterSegments[i].file();
             if (file.exists()) {
    -          final FileInputStream in = new FileInputStream(file);
    +          final FileChannel in = FileChannel.open(file.toPath(), 
ImmutableSet.of(READ));
               boolean copyThrewException = true;
               try {
    -            lengths[i] = Utils.copyStream(in, out, false, 
transferToEnabled);
    +            long size = in.size();
    +            Utils.copyFileStreamNIO(in, out, 0, size);
    +            lengths[i] = size;
    --- End diff --
    
    There're lot of other places using `Utils#copyStream`, it would be better 
not to change this API.


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