빅데이터 하둡 프로그래밍 교육과정 ]MyMapper.setup (2)
빅데이터 하둡 프로그래밍 교육과정 ]MyMapper.setup (2)
실무개발자를위한 실무교육 전문교육센터학원
www.oraclejava.co.kr에 오시면 보다 다양한 강좌를 보실 수 있습니다.
MyMapper.setup (2)
private HashMap<String, String> id_freq_map = new HashMap<String, String>();
private Path[] localFiles;
@Override
public void setup(Context context) {
try {
localFiles = DistributedCache.getLocalCacheFiles(context.getConfiguration());
FileInputStream fstream = new FileInputStream(localFiles[0].toString());
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
// Read File Line By Line
while ((strLine = br.readLine()) != null) {
System.out.println(strLine);
String []tokens = strLine.split("\\t");
id_freq_map.put(tokens[0], tokens[1]); // ID and Frequency
}
// Close the input stream
in.close();
}
■ 실행결과
JoinIDTitle과 같은 결과를 내겠지만 속도라는 측면에서 훨씬 더 빠르게 수행된다.
'빅데이터 > 빅데이터Hadoop' 카테고리의 다른 글
빅데이터 하둡 프로그래밍 교육과정 ]Version 1 (0) | 2017.02.10 |
---|---|
빅데이터 하둡 프로그래밍 교육과정 ]Inverted index v1, v2 and v3 개요 (0) | 2017.02.10 |
빅데이터 하둡 프로그래밍 교육과정 ]MyMapper.setup (1) (0) | 2017.02.09 |
빅데이터 하둡 프로그래밍 교육과정 ]main 함수 (0) | 2017.02.09 |
빅데이터 하둡 프로그래밍 교육과정 ]사용전략 (0) | 2017.02.09 |