mapreduce工作没有得到执行

问题描述:

我有一个简单的MapReduce工作,我从avro website借用一些小的修改(我删除了reducer)。它基本上将一个简单的avro文件作为输入。这里是Avro的文件的架构mapreduce工作没有得到执行

Avro的模式:

{ 
"type": "record", 
"name": "User", 
"fields": [ 
{"name": "name", "type": "string"}, 
{"name": "favorite_number", "type": "int"}, 
{"name":"favorite_color", "type": "string"} 
] 
} 

,这里是我的MapReduce工作(映射器和主功能):

public class ColorCountMapper extends Mapper<AvroKey<User>, NullWritable, Text, IntWritable> { 

@Override 
public void map(AvroKey<User> key, NullWritable value, Context context) throws IOException, InterruptedException { 

    CharSequence color = key.datum().getFavoriteColor(); 
    if (color == null) { 
    color = "none"; 
    } 
    context.write(new Text(color.toString()), new IntWritable(1)); 
} 

}

public static void main(String[] args) throws Exception { 


    Configuration conf = new Configuration(); 
    Job job = Job.getInstance(conf, "TestColor"); 
    job.setJarByClass(runClass.class); 
    job.setJobName("Color Count"); 

    FileInputFormat.setInputPaths(job, new Path("in")); 
    FileOutputFormat.setOutputPath(job, new Path("out")); 

    job.setInputFormatClass(AvroKeyInputFormat.class); 
    job.setMapperClass(ColorCountMapper.class); 
    AvroJob.setInputKeySchema(job, User.getClassSchema()); 
    job.setMapOutputKeyClass(Text.class); 
    job.setMapOutputValueClass(IntWritable.class); 


    boolean r = job.waitForCompletion(true); 
    System.out.println(r); 
}  

当我运行该程序时,它返回false并且不成功。我无法弄清楚这个问题。有人可以帮忙吗?

您已将映射器的值类型设置为空写。然后在主/驱动器中,您将Map输出值类设置为IntWritable。你在Mapper中的值类型和main/driver应该是一样的。相应地修改你的程序。如果您有解决方案,请接受我的答案。

+0

你有解决方案吗? – Sachin 2015-03-04 06:38:18