PrepAway - Latest Free Exam Questions & Answers

What is the preferred way to pass a small number of configuration parameters to a mapper or reducer?

What is the preferred way to pass a small number of configuration parameters to a mapper or
reducer?

PrepAway - Latest Free Exam Questions & Answers

A.
As key-value pairs in the jobconf object.

B.
As a custom input key-value pair passed to each mapper or reducer.

C.
Using a plain text file via the Distributedcache, which each mapper or reducer reads.

D.
Through a static variable in the MapReduce driver class (i.e., the class that submits the
MapReduce job).

Explanation:
In Hadoop, it is sometimes difficult to pass arguments to mappers and reducers. If
the number of arguments is huge (e.g., big arrays), DistributedCache might be a good choice.
However, here, we’re discussing small arguments, usually a hand of configuration parameters.
In fact, the way to configure these parameters is simple. When you initialize“JobConf”object to
launch a mapreduce job, you can set the parameter by using“set”method like:
1JobConf job = (JobConf)getConf();
2job.set(“NumberOfDocuments”, args[0]);
Here,“NumberOfDocuments”is the name of parameter and its value is read from“args[0]“, a
command line argument.
Reference:Passing Parameters and Arguments to Mapper and Reducer in Hadoop

5 Comments on “What is the preferred way to pass a small number of configuration parameters to a mapper or reducer?


Leave a Reply to Haresh Cancel reply

Your email address will not be published. Required fields are marked *