GitHub user andrewor14 opened a pull request:

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

    [SPARK-7120][SPARK-7121][WIP] Closure cleaner nesting + documentation

    For instance, in SparkContext, I tried to do the following:
    {code}
    def scope[T](body: => T): T = body // no-op
    def myCoolMethod(path: String): RDD[String] = scope {
      parallelize(1 to 10).map { _ => path }
    }
    {code}
    and I got an exception complaining that SparkContext is not serializable. 
The issue here is that the inner closure is getting its path from the outer 
closure (the scope), but the outer closure actually references the SparkContext 
object itself to get the `parallelize` method.
    
    Note, however, that the inner closure doesn't actually need the 
SparkContext; it just needs a field from the outer closure. If we modify 
ClosureCleaner to clean the outer closure recursively while using the fields 
accessed by the inner closure, then we can serialize the inner closure.
    
    This is blocking my effort on a separate task. This is WIP because I plan 
to add tests for this later.

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

    $ git pull https://github.com/andrewor14/spark closure-cleaner

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

    https://github.com/apache/spark/pull/5685.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 #5685
    
----
commit 86f78237b7623e4efa06c5feb053e0c304979c73
Author: Andrew Or <and...@databricks.com>
Date:   2015-04-24T10:05:58Z

    Implement transitive cleaning + add missing documentation
    
    See in-code comments for more detail on what this means.

commit 2390a608ed74a9703d3763d040421dccb51242ec
Author: Andrew Or <and...@databricks.com>
Date:   2015-04-24T10:08:11Z

    Feature flag this new behavior
    
    ... in case anything breaks, we should be able to resort to old
    behavior.

----


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