1
변형의 WordCount 예제를 변형하려고했습니다. Mapper가 텍스트를 키로, 텍스트를 값으로 출력하고 감속기가 텍스트를 키로, NullWritable을 값으로 출력합니다.hadoop mapreduce 작업이 감속기를 실행하지 않습니다
지도 외에,이 같은 주요 방법을 넣어, 서명을 감소 : 디버깅하는
//start a conf
Configuration conf = new Configuration();
conf.set("str",str);
//initialize a job based on the conf
Job job = new Job(conf, "wordcount");
job.setJarByClass(org.myorg.WordCount.class);
//the reduce output
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(NullWritable.class);
//the map output
job.setMapOutputKeyClass(Text.class);
job.setMapOutputValueClass(Text.class);
//Map and Reduce
job.setMapperClass(Map.class);
job.setReducerClass(Reduce.class);
//take hdfs locations as input and output
job.setInputFormatClass(TextInputFormat.class);
job.setOutputFormatClass(TextOutputFormat.class);
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
//run the job
job.waitForCompletion(true);
을, 나는
map(LongWritable key, Text value, Context context){
.........
context.write("1000000","2");
}
으로지도 기능을 넣어
reduce(Text key, Iterable<Text> values, Context context){
.......
context.write("v",NullWritable.get());
}
같은 코드를 감소
그러나 출력에서 보는 모든 것이 맵 출력입니다. 감속기는 컴파일되지만 호출조차되지 않습니다! main() 메서드에서 코드가 설명 된 내용이 누락 된 것일 수 있지만 남은 것은 무엇입니까? 나는 어떤 정보가 작업 구성을 위해 더 필요하다는 것을 알지 못한다.
덕분에, 실제로 동작을 오버라이드 (override)되어 있는지 확인하기 위해 감소 기능에 @override
를 추가
' "v"'또한 텍스트 유형이 아니므로'new Text ("v")'와 같이 작성해야합니다. 그의 매퍼 (mapper)도 '긴'문자열과 혼동하는 동일한 문제를 가지고있다. –
"v"부분은 감속기 실행을위한 제 야생 시도의 두 번째 버전 이었지만, 동의합니다 ... 가리키는 것에 감사드립니다 :) – user2325080
문제가 해결되었습니다 :) 감사합니다. – user2325080