How to solve error caused due to output types of mapper and reducer not matching?

0 votes
job.setOutputValueClass(IntWritable.class);  

sets the o/p value of Mapper or Reducer? When o/p types of mapper and reducer do not match, it gives me an error.

Code:

public static class Map extends Mapper<LongWritable, Text, IntWritable ,Text>

public static class Reduce extends Reducer<IntWritable, Text,IntWritable , IntWritable>

job.setOutputValueClass(IntWritable.class);
Jul 9 in Big Data Hadoop by Karan
26 views

1 answer to this question.

0 votes

job.setOutputValueClass will set the types expected as output from both the map and reduce phases. In your code,

public static class Map extends Mapper<LongWritable, Text, IntWritable ,Text>
public static class Reduce extends Reducer<IntWritable, Text,IntWritable , IntWritable>
job.setOutputValueClass(IntWritable.class);

The mapper output value that is Text does not match with the outputValueClass that is IntWritable.Class  since you are setting the property as job.setOutputValueClass(IntWritable.class); That is the reason it might give you Type mismatch error.

If your Mapper emits different types than the Reducer, you can set the types emitted by the mapper with the JobConf's setMapOutputKeyClass() and setMapOutputValueClass() methods. These implicitly sets the input types expected by the Reducer.

answered Jul 9 by Rishab

Related Questions In Big Data Hadoop

0 votes
1 answer

Output types of mapper and reducer does not match

job.setOutputValueClass will set the types expected as ...READ MORE

answered Jul 22 in Big Data Hadoop by Reena
33 views
0 votes
1 answer
0 votes
1 answer

How to concatenate hdfs files and store in output file?

You can use a combination of cat and put command. Something ...READ MORE

answered Dec 5, 2018 in Big Data Hadoop by Omkar
• 67,480 points
430 views
0 votes
1 answer

How to compress output of the mapreduce output in Hive?

To compress the output of the MapReduce ...READ MORE

answered May 20 in Big Data Hadoop by Hiran
23 views
0 votes
1 answer

Hadoop Mapreduce word count Program

Firstly you need to understand the concept ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,670 points
2,735 views
0 votes
1 answer

hadoop.mapred vs hadoop.mapreduce?

org.apache.hadoop.mapred is the Old API  org.apache.hadoop.mapreduce is the ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,670 points
289 views
0 votes
10 answers

hadoop fs -put command?

put syntax: put <localSrc> <dest> copy syntax: copyFr ...READ MORE

answered Dec 7, 2018 in Big Data Hadoop by Aditya
13,553 views
0 votes
1 answer

Hadoop dfs -ls command?

In your case there is no difference ...READ MORE

answered Mar 16, 2018 in Big Data Hadoop by kurt_cobain
• 9,240 points
992 views
0 votes
1 answer

How to set the number of Map & Reduce tasks?

The map tasks created for a job ...READ MORE

answered Apr 18, 2018 in Big Data Hadoop by Shubham
• 13,290 points
68 views
0 votes
11 answers

How to check size of HDFS directory?

It is the same syntax. Use the ...READ MORE

answered Jun 6 in Big Data Hadoop by Sowmya
7,933 views