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 <[email protected]>
To: [email protected]
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: [email protected] [mailto:[email protected]] 
Sent: Thursday, July 09, 2009 11:05 AM
To: [email protected]
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/

Reply via email to