나는 내 코드에서 틀린 것이 틀림 없다고 생각했지만 그걸 찾지 못했습니다. 내 프로그램에서Mapreduce를 사용할 때 왜 장애가 발생했는지
내가 가진 :
public static class BrowserReduce extends
Reducer<Text, IntWritable, IntWritable, Text> {
private IntWritable result = new IntWritable();
public void reduce(Text key, Iterable<IntWritable> values,
Context context) throws IOException, InterruptedException {
int sum = 0;
for (IntWritable val : values) {
sum += val.get();
}
result.set(sum);
context.write(result, key);
}
}
내 일
public static class BrowserMapper extends
Mapper<LongWritable, Text, Text, IntWritable>
및
은 다음과 같이 구성 :이 작업을 실행할 때 이public int run(String[] args) throws Exception {
Job job = Job.getInstance();
job.setMapOutputKeyClass(Text.class);
job.setMapOutputValueClass(IntWritable.class);
job.setOutputKeyClass(IntWritable.class);
job.setOutputValueClass(Text.class);
job.setMapperClass(BrowserMapper.class);
job.setReducerClass(BrowserReduce.class);
job.setInputFormatClass(TextInputFormat.class);
job.setOutputFormatClass(TextOutputFormat.class);
FileInputFormat.setInputPaths(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
job.setJarByClass(LogAnalysis.class);
job.waitForCompletion(true);
return 0;
}
, 나는이 같은 결과를 얻었다 :
175394 IE
1475014 chrome
508390 firefox
23566 opera
421729 other
1266627 safari
,
하지만이 같은 예상 된 결과 :
1475014 chrome
1266627 safari
508390 firefox
421729 other
175394 IE
23566 opera
어떤 생각? 많은 감사