spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davies <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-11425] [SPARK-11486] Improve hybrid agg...
Date Wed, 04 Nov 2015 06:23:49 GMT
Github user davies commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9383#discussion_r43846549
  
    --- Diff: core/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorter.java
---
    @@ -386,24 +388,37 @@ public void insertKVRecord(Object keyBase, long keyOffset, int keyLen,
       }
     
       /**
    +   * Merges another UnsafeExternalSorters into this one, the other one will be emptied.
    +   *
    +   * @throws IOException
    +   */
    +  public void merge(UnsafeExternalSorter other) throws IOException {
    +    other.spill();
    +    spillWriters.addAll(other.spillWriters);
    +    // remove them from `spillWriters`, or the files will be deleted in `cleanupResources`.
    +    other.spillWriters.clear();
    +    other.cleanupResources();
    +  }
    +
    +  /**
        * Returns a sorted iterator. It is the caller's responsibility to call `cleanupResources()`
        * after consuming this iterator.
        */
       public UnsafeSorterIterator getSortedIterator() throws IOException {
    -    assert(inMemSorter != null);
    -    readingIterator = new SpillableIterator(inMemSorter.getSortedIterator());
    -    int numIteratorsToMerge = spillWriters.size() + (readingIterator.hasNext() ? 1 :
0);
         if (spillWriters.isEmpty()) {
    +      assert(inMemSorter != null);
    +      readingIterator = new SpillableIterator(inMemSorter.getSortedIterator());
           return readingIterator;
         } else {
           final UnsafeSorterSpillMerger spillMerger =
    -        new UnsafeSorterSpillMerger(recordComparator, prefixComparator, numIteratorsToMerge);
    +        new UnsafeSorterSpillMerger(recordComparator, prefixComparator, spillWriters.size());
           for (UnsafeSorterSpillWriter spillWriter : spillWriters) {
             spillMerger.addSpillIfNotEmpty(spillWriter.getReader(blockManager));
           }
    -      spillWriters.clear();
    --- End diff --
    
    @JoshRosen Do you remember why we need to clear this? Once cleared, how to delete the
spilled files?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message