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

    https://github.com/apache/spark/pull/18541#discussion_r126342950
  
    --- Diff: 
core/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorter.java
 ---
    @@ -589,29 +589,51 @@ public long getKeyPrefix() {
       }
     
       /**
    -   * Returns a iterator, which will return the rows in the order as 
inserted.
    +   * Returns an iterator starts from startIndex, which will return the 
rows in the order as
    +   * inserted.
        *
        * It is the caller's responsibility to call `cleanupResources()`
        * after consuming this iterator.
        *
        * TODO: support forced spilling
        */
    -  public UnsafeSorterIterator getIterator() throws IOException {
    +  public UnsafeSorterIterator getIterator(int startIndex) throws 
IOException {
         if (spillWriters.isEmpty()) {
           assert(inMemSorter != null);
    -      return inMemSorter.getSortedIterator();
    +      UnsafeSorterIterator iter = inMemSorter.getSortedIterator();
    +      moveOver(iter, startIndex);
    +      return iter;
         } else {
           LinkedList<UnsafeSorterIterator> queue = new LinkedList<>();
    +      int i = 0;
           for (UnsafeSorterSpillWriter spillWriter : spillWriters) {
    -        queue.add(spillWriter.getReader(serializerManager));
    +        if (i + spillWriter.recordsSpilled() <= startIndex) {
    +          i += spillWriter.recordsSpilled();
    --- End diff --
    
    Sure


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