On Mon, May 4, 2009 at 2:59 PM, Rajarshi Guha <[email protected]> wrote:

> So my question is: if I need to use an argument, specified on the command
> line, do I need to do anything special to the variable holding it? In other
> words, the simple assignment
>
>        pattern = otherArgs[2];
>
> seems to lead to an NPE when run in distributed mode.
>

Hi Rajarshi,

The issue here is that your mapper and reducer classes are being
instantiated in a different JVM from your main() function. In order to pass
data to them, you need to use the Configuration object.

Since you have a simple String here, this should be pretty simple. Something
like:

conf.set("com.example.tool.pattern", otherArgs[2]);

then in the configure() function of your Mapper/Reducer, simply retrieve it
using conf.get("com.example.tool.pattern");

Hope that helps,
-Todd

Reply via email to