9. 모든 일을 MapReduce화 하라!
근데 이런 SQL을 어떻
게 MapReduce로 만들
지?
SELECT LAT_N, CITY,
TEMP_F
FROM STATS, STATION
WHERE MONTH = 7
AND STATS.ID =
STATION.ID
ORDER BY TEMP_F;
10. 모든 일을 MapReduce화 하라!
이런 Machine
learning/Data 분석 업
무는?
“지난 2007년부터 매월 나
오는 전국 부동산 실거래가
정보에서 영향을 미칠 수 있
는 변수 140개중에 의미있
는 변수 5개만 뽑아.”
“아, 마감은 내일이다.”
11. 코드도 이정도면 뭐? (단순히 단어 세는 코드가…)
package org.myorg;
import java.io.IOException;
import java.util.*;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapreduce.*;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
public class WordCount {
public static class Map extends Mapper<LongWritable, Text, Text, IntWritable> {
private final static IntWritable one = new IntWritable(1);
private Text word = new Text();
public void map(LongWritable key, Text value, Context context) throws IOException,
InterruptedException {
String line = value.toString();
StringTokenizer tokenizer = new StringTokenizer(line);
while (tokenizer.hasMoreTokens()) {
word.set(tokenizer.nextToken());
context.write(word, one);
}
}
}
public static class Reduce extends Reducer<Text, IntWritable, Text, IntWritable> {
public void reduce(Text key, Iterable<IntWritable> values, Context context)
throws IOException, InterruptedException {
int sum = 0;
for (IntWritable val : values) {
sum += val.get();
}
context.write(key, new IntWritable(sum));
}
}
public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
Job job = new Job(conf, "wordcount");
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
job.setMapperClass(Map.class);
job.setReducerClass(Reduce.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);
}
26. Spark 설치하기
● 일일이 말하기 귀찮아요. 아래 보세요.
o 설치방법
http://bcho.tistory.com/1024
o 아예 Vagrant로 만들어 놨어요. 빌드도 다
해요.
https://bitbucket.org/JinhoYoo_Nomad
Connection/spark_test_vm
27. 근데 이거 가지고 뭐할라고?
이런거 만들게요.
http://engineering.vcnc.co.kr
/2015/05/data-analysis-with-
spark/