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

    https://github.com/apache/spark/pull/18541#discussion_r125631249
  
    --- Diff: 
core/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorter.java
 ---
    @@ -596,17 +600,37 @@ public long getKeyPrefix() {
        *
        * 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();
    +      for (int i = 0; i < startIndex && iter.hasNext(); i++) {
    +        iter.loadNext();
    +      }
    +      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();
    +          continue;
    --- End diff --
    
    Nit: remove continue. It is useless and confusing.


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