Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we pass List<Text> as Mapper output?

I am working on a problem of Map-Reduce. But I stuck at one point that how can I pass List<Text> as Mapper output? Is it possible or not? If yes, then how can we tell the configuration about the Mapper output class?

like image 630
neel Avatar asked May 14 '15 03:05

neel


People also ask

What is the output of mapper?

The output of the mapper is the full collection of key-value pairs. Before writing the output for each mapper task, partitioning of output take place on the basis of the key. Thus partitioning itemizes that all the values for each key are grouped together. Hadoop MapReduce generates one map task for each InputSplit.

Can write output from mapper directly to HDFS?

Can we configure mappers to write output on HDFS ? The output of Mapper is not written on HDFS because, the Block of data are replicated in the datanode based on the replication factor and namenode should hold the metadata of blocks.

Which phase takes the output of mappers as its input?

Mapper task is the first phase of processing that processes each input record (from RecordReader) and generates an intermediate key-value pair. Hadoop Mapper store intermediate-output on the local disk.

Which part of the file data will be considered as the key of the Mapper input?

Mapper is a function which process the input data. The mapper processes the data and creates several small chunks of data. The input to the mapper function is in the form of (key, value) pairs, even though the input to a MapReduce program is a file or directory (which is stored in the HDFS).


1 Answers

You may use the ArrayWritable class as value object from your mapper class. Please refer the below code snippet for your mapper class,

ArrayWritable arrayWritable = new ArrayWritable(Text.class);

Text [] textValues = new Text[2];
textValues[0] = new Text("value1");
textValues[1] = new Text("value1");

arrayWritable.set(textValues );
context.write(key , arrayWritable );

set the value class as following in your driver class,

job.setMapOutputValueClass(ArrayWritable.class);
like image 91
suresiva Avatar answered Nov 15 '22 05:11

suresiva