빅데이터 하둡 프로그래밍 교육과정 ] Version 2 – map 




빅데이터 하둡 프로그래밍 교육과정 ]Version 2 – map 

실무개발자를위한 실무교육 전문교육센터학원

www.oraclejava.co.kr에 오시면 보다 다양한 강좌를 보실 수 있습니다.


Version 2 – map 



HashSet<String> words = new HashSet<String>();

public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        String line = value.toString();

        StringTokenizer tokenizer = new StringTokenizer(line, "\t\r\n\f |,!#\"$.'%&=+-_^@`~:?<>(){}[];*/");

        String docID = "";

….

        words.clear();

        while (tokenizer.hasMoreTokens()) {

          words.add(tokenizer.nextToken().toLowerCase());

        }

        Iterator it = words.iterator();

        while(it.hasNext()) {

          String v =(String)it.next();

          word.set(v);

          context.write(word, new Text(docID));

        }

}



+ Recent posts