나는 Reducer Class의 기본 실행 방법과 동일한이 간단한 코드를 작성했지만 완전히 이상한 일이 발생합니다. 여기 이상한 HashMap 결과 - Java, Hadoop
은 기본 실행 방법 :public void More ...run(Context context) throws IOException, InterruptedException {
setup(context);
while (context.nextKey()) {
reduce(context.getCurrentKey(), context.getValues(), context);
}
cleanup(context);
}
출력 :
New reducer: 0
Reducer: 0:9,2:5
end of this reducer
Reducer: 0:9,5:7
end of this reducer
(키 많이)
Reducer: 7:7,6:7
end of this reducer
Reducer: 7:7,7:6
end of this reducer
여기 내 오버라이드 (override) 방법 :
@Override
public void run(Context context) throws IOException, InterruptedException {
setup(context);
HashMap<Text,HashSet<Text>> map = new HashMap<Text,HashSet<Text>>();
while (context.nextKey()) {
//reduce(context.getCurrentKey(),context.getValues(),context);
Text key = context.getCurrentKey();
map.put(key, new HashSet<Text>());
for(Text v : context.getValues()){
map.get(key).add(v);
}
}
for(Text k : map.keySet()){
reduce(k,map.get(k),context);
}
cleanup(context);
}
,451,515,
출력 :
New reducer: 0
Reducer: 7:7,7:6
end of this reducer
(키 많이)
Reducer: 7:7,7:6
end of this reducer
내 문제는 내가 해시 맵에 키와 값을 복사 할 경우 첫째 아무것도 제대로 호출을 줄일 작동하지 않는다는 것이다 결국 그것은 동일한 키 (해시 맵에 저장된 첫 번째 키)를 여러 번 반복해서 전달합니다./ 누구든지 도와 줄 수 있습니까? 이 작업을 올바르게 수행하려면 어떻게해야합니까? 열쇠를 감속기에 보내기 전에 열쇠를 전처리하기 때문에이 작업을 수행해야합니다. 미리 감사드립니다.
죄송합니다! 나는 그것이 더 좋아 보이기를 바란다) –