I had the same issue with getting a static member filled out, so I used the JobConf object to get variables I had stored in the run() method from the command line. With the 0.19 api, the MapReduceBase class has a "public void configure( JobConf job )" method to override that will be called before the map function does, which seems like a good place to do some setup work.
Josh Patterson TVA -----Original Message----- From: Amandeep Khurana [mailto:[email protected]] Sent: Thursday, July 09, 2009 2:49 PM To: [email protected] Subject: Re: Accessing static variables in map function The only way to do it as of now is through the conf object. On Thu, Jul 9, 2009 at 11:35 AM, <[email protected]> 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 <[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/ >
