Contenu connexe Similaire à クラウド時代の並列分散処理技術 (20) クラウド時代の並列分散処理技術22. Step.2 Ruby による DSL で MapReduce を シンプルに Map Reduce Job Description Log Analysis DSL 24. package org . apache . hadoop . examples ; import java.io.IOException ; import java.util.StringTokenizer ; import org.apache.hadoop.conf.Configuration ; 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 ; import org.apache.hadoop.mapreduce.Reducer ; import org.apache.hadoop.mapreduce.lib.input.FileInputFormat ; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat ; import org.apache.hadoop.util.GenericOptionsParser ; public class WordCount { public static class TokenizerMapper extends Mapper < Object , Text , Text , IntWritable > { private final static IntWritable one = new IntWritable ( 1 ); private Text word = new Text (); public void map( Object key , Text value , Context context ) throws IOException , InterruptedException { StringTokenizer itr = new StringTokenizer ( value . toString ()); while ( itr . hasMoreTokens ()) { word . set ( itr . nextToken ()); context . write ( word , one ); } } } public static class IntSumReducer extends Reducer < Text , IntWritable , Text , IntWritable > { private IntWritable result = new IntWritable (); public void reduce( Text key , Iterable < IntWritable > values , Context context ) throws IOException , InterruptedException { int sum = 0 ; for ( IntWritable val : values ) { sum += val . get (); } result . set ( sum ); context . write ( key , result ); } } public static void main( String [] args ) throws Exception { Configuration conf = new Configuration (); String [] otherArgs = new GenericOptionsParser ( conf , args ) . getRemainingArgs (); if ( otherArgs . length != 2 ) { System . err . println ( "Usage: wordcount <in> <out>" ); System . exit ( 2 ); } Job job = new Job ( conf , "word count" ); job . setJarByClass ( WordCount . class ); job . setMapperClass ( TokenizerMapper . class ); job . setCombinerClass ( IntSumReducer . class ); job . setReducerClass ( IntSumReducer . class ); job . setOutputKeyClass ( Text . class ); job . setOutputValueClass ( IntWritable . class ); FileInputFormat . addInputPath ( job , new Path ( otherArgs [ 0 ])); FileOutputFormat . setOutputPath ( job , new Path ( otherArgs [ 1 ])); System . exit ( job . waitForCompletion (true) ? 0 : 1 ); } } 同様な処理が Java では 70 行必要だが、 HadoopPapyrus だと 10 行に! dsl 'LogAnalysis‘ from ‘test/in‘ to ‘test/out’ pattern /([^|:]+)[^:]*/ column_name :link topic "link num", :label => 'n' do count_uniq column[:link] end Java Hadoop Papyrus Notes de l'éditeur We are involved the problem. This is the IDC study. In 2009, we have 0.8 Zetta byte digital data. Zetta bytes means million times of Peta bytes, You know, Mega bytes, Giga, Tera, Peta. Exa, Zetta. We are in “Cloud Era”. Data we have to process get bigger and bigger. In 2020, it will grow by 35 zetta bytes, it’s huge! We all should tackle this “Information Explosion” like this. バズワードは消えていくものだが、クラウドは残る。 ガートナーのハイプサイクル クラウドの向こう側には、データが集約される かつて、世界に5台のコンピュータがあればいいと IBM 初代社長のトーマス・ワトソン・シニアが言ったといわれる クラウドは向こう側で処理をするということなので、集約するほうが費用対効果が高い。ハード・ソフトとも となると、データはますます集約されて大きくなる Ruby はインターネットサービス開発と親和性が高い。開発効率や言語としての柔軟性が高い。 Java と Ruby をつなぐ JRuby という技術を用いる。 ドメイン毎に DSL( ドメイン特化言語 ) という形でフレームワーク化し、開発者に MapReduce を意識しない形で処理を書くことができるようにする。 そのフレームワークはオープンソース化していろいろな分野の DSL が開発できるようにする。 Hudson という継続的ビルドツールを Hadoop 処理サーバ環境として利用。その上で DSL が実行できるようにする。