빅데이터 하둡 프로그래밍 교육과정 ]MyReducer.reduce




빅데이터 하둡 프로그래밍 교육과정 ]MyReducer.reduce

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

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


MyReducer.reduce


public void reduce(Text key, Iterable<Text> valueIter, final Context context) throws IOException, InterruptedException {

        String title = null;

        String frequency = null;

        int count = 0;

        for(Text t: valueIter) {

          String str = t.toString();

          String []tokens = str.split("\\t");

          if (tokens[1].equals("1"))

            title = tokens[0];

          else 

            frequency = tokens[0];

          count++;

        }

        if (count == 2 && title != null                              frequency != null)

            context.write(key, new Text(title + "\t" + frequency));

      }



+ Recent posts