GitHub user davies opened a pull request:

    https://github.com/apache/spark/pull/12114

    [SPARK-14334] [SQL] add toLocalIterator for Dataset/DataFrame

    ## What changes were proposed in this pull request?
    
    RDD.toLocalIterator() could be used to fetch one partition at a time to 
reduce the memory usage. Right now, for Dataset/Dataframe we have to use 
df.rdd.toLocalIterator, which is super slow also requires lots of memory 
(because of the Java serializer or even Kyro serializer).
    
    This PR introduce an optimized toLocalIterator for Dataset/DataFrame, which 
is much faster and requires much less memory. For a partition with 5 millions 
rows, `df.rdd.toIterator` took about 100 seconds, but df.toIterator took less 
than 7 seconds. For 10 millions row, rdd.toIterator will crash (not enough 
memory) with 4G heap, but df.toLocalIterator could finished in 12 seconds.
    
    The JDBC server has been updated to use DataFrame.toIterator.
    
    ## How was this patch tested?
    
    Existing tests.
    


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/davies/spark local_iterator

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/12114.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #12114
    
----
commit 52d752031f8502cc383efe4ed57f2677db1a2905
Author: Davies Liu <[email protected]>
Date:   2016-04-01T20:28:43Z

    add toLocalIterator for Dataset

----


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