0
我有一個簡單的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並且不成功。我無法弄清楚這個問題。有人可以幫忙嗎?
你有解決方案嗎? – Sachin 2015-03-04 06:38:18