availability-of-community-technology-preview-ctp-of-hadoop-based-service-on-windows-azure.aspx
http://developer.yahoo.com/hadoop/tutorial/module4.html
http://wiki.apache.org/hadoop/WordCount
http://hadoop.apache.org/common/docs/r0.20.2/mapred_tutorial.html
package com.benjguin.hadoopSamples; import java.io.IOException; import java.util.*; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.*; import org.apache.hadoop.mapred.*; public class WordCount { public static class Map extends MapReduceBase implements 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, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException { String line = value.toString(); StringTokenizer tokenizer = new StringTokenizer(line); while (tokenizer.hasMoreTokens()) { String[] wordsToCount = Utils.wordsToCount(tokenizer.nextToken()); for (int i=0; i<wordsToCount.length; i++) { if (Utils.countThisWord(wordsToCount[i])) { word.set(wordsToCount[i]); output.collect(word, one); } } } } } public static class Reduce extends MapReduceBase implements Reducer<Text, IntWritable, Text, IntWritable> { public void reduce(Text key, Iterator<IntWritable> values, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException { int sum = 0; while (values.hasNext()) { sum += values.next().get(); } output.collect(key, new IntWritable(sum)); } } public static void main(String[] args) throws Exception { JobConf conf = new JobConf(WordCount.class); conf.setJobName("wordcount"); conf.setOutputKeyClass(Text.class); conf.setOutputValueClass(IntWritable.class); conf.setMapperClass(Map.class); conf.setCombinerClass(Reduce.class); conf.setReducerClass(Reduce.class); conf.setInputFormat(TextInputFormat.class); conf.setOutputFormat(TextOutputFormat.class); FileInputFormat.setInputPaths(conf, new Path(args[0])); FileOutputFormat.setOutputPath(conf, new Path(args[1])); JobClient.runJob(conf); } }
et
package com.benjguin.hadoopSamples; public class Utils { public static String[] wordsToCount(String word) { return word.toLowerCase().split("[^a-zA-Z]"); } public static boolean countThisWord(String word) { return word.length() > 3; } }
http://social.technet.microsoft.com/wiki/contents/articles/6225.aspx
11/12/19 17:51:27 INFO mapred.FileInputFormat: Total input paths to process : 3 11/12/19 17:51:27 INFO mapred.JobClient: Running job: job_201112190923_0004 11/12/19 17:51:28 INFO mapred.JobClient: map 0% reduce 0% 11/12/19 17:51:53 INFO mapred.JobClient: map 25% reduce 0% 11/12/19 17:51:54 INFO mapred.JobClient: map 75% reduce 0% 11/12/19 17:51:55 INFO mapred.JobClient: map 100% reduce 0% 11/12/19 17:52:14 INFO mapred.JobClient: map 100% reduce 100% 11/12/19 17:52:25 INFO mapred.JobClient: Job complete: job_201112190923_0004 11/12/19 17:52:25 INFO mapred.JobClient: Counters: 26 11/12/19 17:52:25 INFO mapred.JobClient: Job Counters 11/12/19 17:52:25 INFO mapred.JobClient: Launched reduce tasks=1 11/12/19 17:52:25 INFO mapred.JobClient: SLOTS_MILLIS_MAPS=57703 11/12/19 17:52:25 INFO mapred.JobClient: Total time spent by all reduces waiting after reserving slots (ms)=0 11/12/19 17:52:25 INFO mapred.JobClient: Total time spent by all maps waiting after reserving slots (ms)=0 11/12/19 17:52:25 INFO mapred.JobClient: Launched map tasks=4 11/12/19 17:52:25 INFO mapred.JobClient: Data-local map tasks=4 11/12/19 17:52:25 INFO mapred.JobClient: SLOTS_MILLIS_REDUCES=18672 11/12/19 17:52:25 INFO mapred.JobClient: File Input Format Counters 11/12/19 17:52:25 INFO mapred.JobClient: Bytes Read=1554158 11/12/19 17:52:25 INFO mapred.JobClient: File Output Format Counters 11/12/19 17:52:25 INFO mapred.JobClient: Bytes Written=186556 11/12/19 17:52:25 INFO mapred.JobClient: FileSystemCounters 11/12/19 17:52:25 INFO mapred.JobClient: FILE_BYTES_READ=427145 11/12/19 17:52:25 INFO mapred.JobClient: HDFS_BYTES_READ=1554642 11/12/19 17:52:25 INFO mapred.JobClient: FILE_BYTES_WRITTEN=964132 11/12/19 17:52:25 INFO mapred.JobClient: HDFS_BYTES_WRITTEN=186556 11/12/19 17:52:25 INFO mapred.JobClient: Map-Reduce Framework 11/12/19 17:52:25 INFO mapred.JobClient: Map output materialized bytes=426253 11/12/19 17:52:25 INFO mapred.JobClient: Map input records=19114 11/12/19 17:52:25 INFO mapred.JobClient: Reduce shuffle bytes=426253 11/12/19 17:52:25 INFO mapred.JobClient: Spilled Records=60442 11/12/19 17:52:25 INFO mapred.JobClient: Map output bytes=1482365 11/12/19 17:52:25 INFO mapred.JobClient: Map input bytes=1535450 11/12/19 17:52:25 INFO mapred.JobClient: Combine input records=135431 11/12/19 17:52:25 INFO mapred.JobClient: SPLIT_RAW_BYTES=484 11/12/19 17:52:25 INFO mapred.JobClient: Reduce input records=30221 11/12/19 17:52:25 INFO mapred.JobClient: Reduce input groups=17618 11/12/19 17:52:25 INFO mapred.JobClient: Combine output records=30221 11/12/19 17:52:25 INFO mapred.JobClient: Reduce output records=17618 11/12/19 17:52:25 INFO mapred.JobClient: Map output records=135431
(…)
Benjamin