hadoop-common-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Amandeep Khurana <ama...@gmail.com>
Subject Re: Accessing static variables in map function
Date Thu, 09 Jul 2009 18:48:45 GMT
The only way to do it as of now is through the conf object.


On Thu, Jul 9, 2009 at 11:35 AM, <smarthrish@yahoo.co.in> wrote:

>
> Hey Ram.
> The problem is i initialize these variables in the run function after
>  receiving the cmd line arguments .
> I want to access the same vars  in the mpa function.
> Is there a diff way other than passing the variables through a Conf object
>  ?
>
> -Hrishi
>
>
> ----- Original Message ----
> From: Ramakishore Yelamanchilli <kyelaman@cisco.com>
> To: common-user@hadoop.apache.org
> Sent: Thursday, July 9, 2009 11:30:24 AM
> Subject: RE: Accessing static variables in map function
>
> As per my understanding declaring static variables within the map class
> rather than the outer class should be fine. Otherwise it may be a problem
> as
> map function will be replicated in all the nodes.
>
> -----Original Message-----
> From: smarthrish@yahoo.co.in [mailto:smarthrish@yahoo.co.in]
> Sent: Thursday, July 09, 2009 11:05 AM
> To: common-user@hadoop.apache.org
> Subject: Accessing static variables in map function
>
>
> Hi .
> I am a beginner to the Hadoop Map/Reduce Framework.
> Is there a way I can access the static variables declared in my class in
> the
> map function  ?
>
> It goes like :
>
> public class test extends Configured implements Tool {
>  static String storyVersion = null;
>  static String storySize = null;
>  static String storyTimestamp = null;
>
>  public static class MapClass extends MapReduceBase
>    implements Mapper<LongWritable, Text, Text, Text> { // LongWritable
>
>      private Text keytext = new Text();
>
>      @SuppressWarnings("unchecked")
>        public void map(LongWritable key, Text value,
>                        OutputCollector<Text, Text> output,
>                        Reporter reporter) throws IOException {
>
>        // Access the static variables here
>
>        }
>
>     :
>     :
>     :
>  }
>
>
> - Hrishi
>
>
>      __________________________________________________________________
> Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your
> favourite sites. Download it now
> http://ca.toolbar.yahoo.com.
>
>
>       __________________________________________________________________
> Looking for the perfect gift? Give the gift of Flickr!
>
> http://www.flickr.com/gift/
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message