Weitere ähnliche Inhalte
Ähnlich wie Rakuten tech conf (20)
Kürzlich hochgeladen (12)
Rakuten tech conf
- 1. Jrubyで実現する
分散並列処理フレームワーク
Hadoop Papyrus
and more...
2010/10/16
楽天テクノロジーカンファレンス2010
日本JRubyユーザ会/ハピルス株式会社
藤川幸一 FUJIKAWA Koichi @fujibee
- 4. Hadoopとは?
大規模データ並列分散処理フレームワーク
Google MapReduceのオープンソースク
ローン
テラバイトレベルのデータ処理に必要
標準的なHDDがRead 50MB/sとして
400TB(Webスケール)のReadだけで2000時間
分散ファイルシステムと分散処理フレームワー
クが必要
- 9. package org.apache.hadoop.examples; Java
import java.io.IOException;
import java.util.StringTokenizer;
同様な処理がJavaでは70行必要だが、
import org.apache.hadoop.conf.Configuration ;
HadoopPapyrusだと10行に!
import org.apache.hadoop.fs.Path ;
import org.apache.hadoop.io.IntWritable ;
import org.apache.hadoop.io.Text ;
import org.apache.hadoop.mapreduce.Job ;
import org.apache.hadoop.mapreduce.Mapper ;
public static class IntSumReducer extends
import org.apache.hadoop.mapreduce.Reducer ;
Reducer<Text, IntWritable, Text, IntWritable> {
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat ;
private IntWritable result = new IntWritable();
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat ;
import org.apache.hadoop.util.GenericOptionsParser ;
public void reduce(Text key, Iterable<IntWritable> values,
Context context) throws IOException, InterruptedException {
public class WordCountint sum = 0;
{
for (IntWritable val : values) {
sum += val.get();
public static class TokenizerMapper extends
}
Mapper<Object, Text, Text, IntWritable> {
result.set(sum);
Hadoop Papyrus
context.write(key, result);
}
private final static IntWritable one = new IntWritable(1);
dsl 'LogAnalysis‘
}
private Text word = new Text();
public static void main(String[] args) throws Exception {
public void map(Object key, Text value,conf = new Configuration();
Configuration Context context)
from ‘test/in‘
throws IOException, InterruptedException { = new GenericOptionsParser(conf, args)
String[] otherArgs
StringTokenizer itr = new StringTokenizer(value.toString());
.getRemainingArgs();
to ‘test/out’
while (itr.hasMoreTokens()) {(otherArgs.length != 2) {
if
word.set(itr.nextToken()); System.err.println("Usage: wordcount <in> <out>");
context.write(word, one); System.exit(2);
}
}
} pattern /[[([^|]:]+)[^]:]*]]/
Job job = new Job(conf, "word count");
} job.setJarByClass(WordCount.class);
job.setMapperClass(TokenizerMapper.class);
column_name :link
job.setCombinerClass(IntSumReducer.class);
job.setReducerClass(IntSumReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class); topic "link num", :label => 'n' do
FileInputFormat.addInputPath(job, new Path(otherArgs[0]));
FileOutputFormat.setOutputPath(job, new Path(otherArgs[1]));
System.exit(job.waitForCompletion(true) ? 0 : 1);
count_uniq column[:link]
}
}
end
- 11. Hadoop Papyrus 詳細 (続き)
さらに、処理したい内容(ログ分析など)を記述したDSLを用意して
おき、Map処理、Reduce処理でそれぞれ異なる動きをさせることで1
枚のDSL記述でMapReduce処理を行うことができる。
- 14. JRubyでHadoopにアクセス
Hadoop
Hadoop
Hadoop IPC
Client
Client JobTracker
JobTracker
<JRuby>
<JRuby> <Java>
<Java>
Hadoop内のオブジェクトデータに
直接アクセス可能!