0
votes

The have checked this and i can't understand why this error has been encountered.

Mapper

public class movieMapper extends Mapper<LongWritable, Text, IntWritable, Text> {

public void map(LongWritable key, Text value, Context context ) throws IOException,InterruptedException {

    String token[]= value.toString().trim().split("::");

    int movieID=Integer.parseInt(token[0].trim());

    context.write(new IntWritable(movieID), new Text(token[1].trim()));

}

}

Reducer

public class joinReducer extends Reducer<IntWritable, Text, Text, Text> {

public void reduce(IntWritable key, Iterable<Text> values, Context context) throws IOException,InterruptedException {
    float avgRating=0.0f;
    int tokenCount = 0;
    float ratingSum=0.0f;
    int count=0;

    String movieName="";

    for(Text val:values) {
        tokenCount+=1;
    }

    //If we have more than 40 views/ratings
    if(tokenCount-1>40) {

        for(Text val:values) {

            String temp = val.toString();


            if(val.equals("1")||val.equals("2")||val.equals("3")||val.equals("4")||val.equals("5")) {

                float tempRating= Float.parseFloat(val.toString().trim());
                ratingSum += tempRating;
                count++;


            }

            else {

                movieName=val.toString().trim();
            }

        }

        avgRating = ratingSum/ (float)count;

        context.write(new Text(Float.toString(avgRating)), new Text(movieName));
    }

}

}

Driver configuration

Configuration conf= new Configuration();
    String parameter[]= new GenericOptionsParser(conf,args).getRemainingArgs();

    if(parameter.length!=3) {

        System.err.println("Three arguments needed  <File1> <File2> <Out>");
        System.exit(2);
    }


    //set Driver class

    Job job1 = Job.getInstance(conf, "Join");
    job1.setJarByClass(MyDriver.class);
    job1.setReducerClass(joinReducer.class);

    MultipleInputs.addInputPath(job1,  new Path(parameter[0]), TextInputFormat.class, movieMapper.class);
    MultipleInputs.addInputPath(job1,  new Path(parameter[1]), TextInputFormat.class, ratingMapper.class);

    job1.setMapOutputKeyClass(IntWritable.class);
    job1.setMapOutputValueClass(Text.class);


    job1.setOutputKeyClass(Text.class);
    job1.setOutputValueClass(Text.class);


    FileOutputFormat.setOutputPath(job1, new Path(parameter[2] + "/temp"));

    job1.waitForCompletion(true);

18/06/13 09:47:20 INFO mapreduce.Job: Job job_1528823320386_0018 running in uber mode : false 18/06/13 09:47:20 INFO mapreduce.Job: map 0% reduce 0% 18/06/13 09:47:24 INFO mapreduce.Job: Task Id : attempt_1528823320386_0018_m_000000_0, Status : FAILED Error: java.io.IOException: Type mismatch in key from map: expected org.apache.hadoop.io.IntWritable, received org.apache.hadoop.io.LongWritable at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.collect(MapTask.java:1069) at org.apache.hadoop.mapred.MapTask$NewOutputCollector.write(MapTask.java:712) at org.apache.hadoop.mapreduce.task.TaskInputOutputContextImpl.write(TaskInputOutputContextImpl.java:89) at org.apache.hadoop.mapreduce.lib.map.WrappedMapper$Context.write(WrappedMapper.java:112) at org.apache.hadoop.mapreduce.Mapper.map(Mapper.java:124) at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:145) at org.apache.hadoop.mapreduce.lib.input.DelegatingMapper.run(DelegatingMapper.java:55) at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:784) at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341) at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:168) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:422) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1642) at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:163)

18/06/13 09:47:25 INFO mapreduce.Job: map 50% reduce 0% 18/06/13 09:47:29 INFO mapreduce.Job: Task Id : attempt_1528823320386_0018_m_000000_1, Status : FAILED Error: java.io.IOException: Type mismatch in key from map: expected org.apache.hadoop.io.IntWritable, received org.apache.hadoop.io.LongWritable at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.collect(MapTask.java:1069) at org.apache.hadoop.mapred.MapTask$NewOutputCollector.write(MapTask.java:712) at org.apache.hadoop.mapreduce.task.TaskInputOutputContextImpl.write(TaskInputOutputContextImpl.java:89) at org.apache.hadoop.mapreduce.lib.map.WrappedMapper$Context.write(WrappedMapper.java:112) at org.apache.hadoop.mapreduce.Mapper.map(Mapper.java:124) at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:145) at org.apache.hadoop.mapreduce.lib.input.DelegatingMapper.run(DelegatingMapper.java:55) at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:784) at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341) at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:168) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:422) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1642) at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:163)

1
It's sorted out , stupid mistake.Shashank Yadav
please write the "stupid mistake" to help others who come across this question in the future.Ben Watson

1 Answers

0
votes

There are two mappers running in this job, the movieMapper and the ratingMapper. The ratingMapper had a keyword spelled incorrectly in the function declaration and the name of the map function, 'map', was mistakenly written as 'reduce'.

The reducer, according to out config, was supposed to accept key of type IntWritable, but was getting LongWritable, hence the error. ( The TextInputFormat generates the key of type LongWritable and value of type Text)