WordCount 의사코드

 

 

 

 

 

 public static void main(String[] args) throws Exception {

 

    Configuration conf = new Configuration();

    Job job = new Job(conf, "wordcount");

     // Configuration과 Job

 

    job.setJarByClass(WordCount.class);

    job.setMapperClass(Map.class);

    job.setReducerClass(Reduce.class);

// Mapper와 Reducer 클래스와 이들이 들어있는 메인클래스 지정 

 

    job.setOutputKeyClass(Text.class);

    job.setOutputValueClass(LongWritable.class);

// 잡의 최종출력레코드의 키와 밸류 타입을 지정(결국 리듀서의 출력타입) 

 

    job.setInputFormatClass(TextInputFormat.class);

    job.setOutputFormatClass(TextOutputFormat.class);

// 입력파일의 포맷과 출력파일에 사용할 포맷지정 

 

    FileInputFormat.addInputPath(job, new Path(args[0]));

    FileOutputFormat.setOutputPath(job, new Path(args[1]));

// 입력파일의 위치와 출력디렉토리 지정

 

    job.waitForCompletion(true);

// 최종적으로 수행시작

 }

 

 

 

 

 

 

 

+ Recent posts