James,

I think you can put those variables inside the mapper or reducer
without creating a separate public class.

untested code follows...

public static class R extends MapReduceBase implements Reducer
   {
   private static Set s=new HashSet();

   public void reduce(WritableComparable wc,Iterator it,
      OutputCollector o,Reporter r)throws IOException
      {
      while(it.hasNext())
         {
         if(...)
            ...;
         else                                   
            s.add(((IntWritable)it.next()).get());
         }
         // loop, append then add set values to output collector (wc key)

Bye,

Peter W.


On Oct 12, 2007, at 5:09 AM, Dennis Kubes wrote:

You can also use a MapRunnable implementation but that would allow "global" only to each Map task.

Dennis Kubes

James Yu wrote:
For example:
I put all user global variables in a class I called MyGlobals
public class MyGlobals {
    static public int var1;
    ...
}
Then, in whatever map function I have, I can refer to my globals like this:
public void map(LongWritable key, Text value, OutputCollector output,
Reporter reporter) throws IOException {
....
 int i = MyGlobals.var1;
...
}
Sorry about the stupid question and answer.
On 10/11/07, Bob Futrelle <[EMAIL PROTECTED]> wrote:
Yeah, but what's the answer?

- rpf

On 10/11/07, James Yu <[EMAIL PROTECTED]> wrote:
A very basic question: where to store my personal global variables
such
that the map and/or reduce functions can see it?

Thanks,
James

Reply via email to