You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Guoqiang Li (JIRA)" <ji...@apache.org> on 2014/09/10 09:18:29 UTC

[jira] [Resolved] (SPARK-3326) can't access a static variable after init in mapper

     [ https://issues.apache.org/jira/browse/SPARK-3326?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Guoqiang Li resolved SPARK-3326.
--------------------------------
    Resolution: Not a Problem

> can't access a static variable after init in mapper
> ---------------------------------------------------
>
>                 Key: SPARK-3326
>                 URL: https://issues.apache.org/jira/browse/SPARK-3326
>             Project: Spark
>          Issue Type: Bug
>         Environment: CDH5.1.0
> Spark1.0.0
>            Reporter: Gavin Zhang
>
> I wrote a object like:
> object Foo {
>    private Bar bar = null
>    def init(Bar bar){
>    this.bar = bar
>    }
>    def getSome(){
>    bar.someDef()
>    }
> }
> In Spark main def, I read some text from HDFS and init this object. And after then calling getSome().
> I was successful with this code:
> sc.textFile(args(0)).take(10).map(println(Foo.getSome()))
> However, when I changed it for write output to HDFS, I found the bar variable in Foo object is null:
> sc.textFile(args(0)).map(line=>Foo.getSome()).saveAsTextFile(args(1))
> WHY?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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