






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







So far, we've been protected from the full complexity of hadoop by using Pig. Let's see what we've been missing! Yahoo's open-source MapReduce implementation Reference: Hadoop A distributed file system (HDFS) that can store large amounts of data A Map/Reduce programming model that enables scalable data processing. Two main parts Using Raw Hadoop Docsity.com
A distributed filesystem that makes data available to multiple compute nodes. A driver that institutes the MapReduce operation. A mapper that reads data and maps it. A combiner that reduces the size of mapped data. A reducer that summarizes and stores results in the HDFS filesystem. Components of a hadoop application Note: the output is not a stream , but rather, a distributed file. Components of a hadoop application Docsity.com
we describe a typical hadoop example in which mapper workers are also reducer workers. For simplicity, Trackers that start a job and finish it. Mappers that contain HDFS and do the operation. Reducers that don't contain HDFS and find final results. In fact, in a real Hadoop implementation, you need to declare three kinds of nodes: For simplicity Docsity.com
put map shuffle reduce get Often, the same nodes are mappers and reducers. This picture is a bit deceptive, because phases begin asynchronously. If one mapper gets done mapping early, it will start shuffling before the others. Combiner can reduce data during the shuffle; reducer is called after shuffling is complete. Worker 1 Worker 4 Worker 2 Worker 3 A picture of Hadoop MapReduce Processing Docsity.com
Number processors 0-n. Map each key to hash h(k) between 0 and n. if k is at processor p and h(k) differs from p in the sth bit, send <k,v> to processor p^(1<<s) (^=xor). At step s (from 0 to log2(n)), Understanding butterfly sort Suppose key k is at worker 0=000 2 and needs to be at worker 5=h(k)=101 2 in binary First worker 0=000 2 sends it to worker 1 = 001 2. Then worker 1=001 2 sends it to worker 5 = 101 2. Theorem: a key always gets to its intended destination in O(log(N)) steps, where N is the number of workers. Example of shuffle sort Docsity.com
Input: a set of text files, concatenated into a big text file Mapper : for each word w, generate pairs <word, 1>, where w is a key. Reducer : for each w, sum up 1's to get count of that word. Driver : orchestrate calling mapper/reducer. An example application: word count An example application Docsity.com
Input: shards (fragments) of the text to be counted. Output: a list of <w,1> pairs for w a word. The mapper // a value of 1 of the appropriate type for reducing private final IntWritable one = new IntWritable(1); public void map(WritableComparable key, Writable value, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException { // WritableComparable means one can apply >, =, < to it. // Writable means that one can write it, // but might not be able to compare it. // WritableComparable is a subinterface of Writable. // each line is a shard, as a string. String line = value.toString(); // break line into a sequence of tokens StringTokenizer itr = new StringTokenizer(line.toLowerCase()); // iterate over tokens. while(itr.hasMoreTokens()) { word.set(itr.nextToken()); output.collect(word, one); // add one! } } The mapper Docsity.com