|
In Map Reduce if we pass command line arguments it goes to driver class . However, if want to use it in Mapper class , it can be done as follows: In Driver class , set the command line argument's value in the configuration object as follows:
public class TestDriver { public static void main(String[] args) throws IOException,InterruptedException,ClassNotFoundException { Configuration conf = new Configuration(); conf.set("val1", args[0]); conf.set("val2", args[1]); } } Now , in Mapper , you can get these values as follows:
public class TestMapper extends Mapper { public void map(Object key,Text value,Context context) throws IOException,InterruptedException { val1=context.getConfiguration().get("val1"); val2=context.getConfiguration().get("val2"); } }
Click here for Other topics of BigData Technologies
|