LuciferYang opened a new pull request #33556:
URL: https://github.com/apache/spark/pull/33556


   ### What changes were proposed in this pull request?
   `ExternalAppendOnlyMap.spill` and `ExternalSorter.spill` callĀ  
`revertPartialWritesAndClose` method when `objectsWritten == 0` as follows:
   
   ``` scala
   try {
         while (inMemoryIterator.hasNext) {
           ...
   
           if (objectsWritten == serializerBatchSize) {
             flush()
           }
         }
         if (objectsWritten > 0) {
           flush()
           writer.close()
         } else {
           writer.revertPartialWritesAndClose()
         }
         success = true
       } finally {
         ...
       }
   ```
   
   When `objectsWritten` is 0,  all data has been `flush()` and nothing needs 
to be revert,  `revertPartialWritesAndClose()`  will add some unnecessary file 
operations like file reopen and truncate.
   
   
   ### Why are the changes needed?
   Replace `revertPartialWritesAndClose` with `close` in `ExternalSorter.spill` 
and `ExternalAppendOnlyMap.spill` to reduce some unnecessary file operations 
like file reopen and truncate.
   
   ### Does this PR introduce _any_ user-facing change?
   No
   
   
   ### How was this patch tested?
   1. Pass the Jenkins or GitHub Action
   2. Add new Test cases to verify `spill behavior not change`
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



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

Reply via email to