- + - - [UCB CS169] C1L1: Introduction to SaaS, Agile, Cloud Computing + + MapReduce
- UCB CS169 Software Engineering Course 1 Module 1: Introduction to SaaS, Agile, Cloud Computing + MapReduce: Simplified Data Processing on Large Clusters
MapReduce
+ + + +MapReduce: Simplified Data Processing on Large Clusters
MapReduce is a programming model and an associated implementation for processing and generating large data sets.
- map function: processes a key/value pair to generate a set of intermediate key/value pairs
- reduce function: merges all intermediate values associated with the same intermediate key
partitioning the input data, scheduling the program’s execution across a set of machines, handling machine failures, and managing the required inter-machine communication
1 Introduction
The issues of how to parallelize the computation, distribute the data, and handle failures conspire to obscure the original simple computation with large amounts of complex code to deal with these issues.
new abstraction:
- map operation to each logical “record” in our input in order to compute a set of intermediate key/value pairs
- reduce operation to all the values that shared the same key, in order to combine the derived data appropriately
(inspired by the map and reduce primitives present in Lisp and many other functional languages)
2 Programming Model
input: key/value pairs
output: key/value pairs
- Map: written by the user, take an input pair and produces a set of intermediate key/value pairs. The MapReduce library groups together all intermediate values associated with the same intermediate key I and passes them to the Reduce function.
- Reduce: also written by the user, accepts an intermediate key I and a set of values for that key. It merges together these values to form a possibly smaller set of values. Typically just zero or one output value is produced per Reduce invocation. The intermediate values are supplied to the user’s reduce function via an iterator. (to handle lists of values that are too large to fit in memory)
2.1 Example
Counting the number of occurrences of each word in a large collection of documents. The user would write code similar to the following pseudo-code:
map(String key, String value):
+ // key: document name
+ // value: document contents
+ for each word w in value:
+ EmitIntermediate(w, "1");
+
+reduce(String key, Iterator values):
+ // key: a word
+ // values: a list of counts
+ int result = 0;
+ for each v in values:
+ result += ParseInt(v);
+ Emit(AsString(result));
In addition, the user writes code to fill in a mapreduce specification object with the names of the input and output files, and optional tuning parameters. The user then invokes the MapReduce function, passing it the specification object.
2.2 Types
Conceptually the map and reduce functions supplied by the user have associated types:
map (k1, v1) -> list(k2, v2)
+reduce (k2, list(v2)) -> list(v2)
The input keys and values are drawn from a different domain than the output keys and values. The intermediate keys and values are from the same domain as the output keys and values.
2.3 More Examples
- Distributed Grep
The map function emits a line if it matches a supplied pattern.
The reduce function is an identity function that just copies the supplied intermediate data to the output.
- Count of URL Access Frequency
The map function processes logs of web page requests and outputs
<URL, 1>
.The reduce function adds together all values for the same URL and emits a
<URL, total count>
pair. - Reverse Web-Link Graph
The map function outputs
<target, source>
pairs for each link to atarget
URL found in a page namedsource
.The reduce function concatenates the list of all source URLs associated with a given target URL and emits the pair:
<target, list(source)>
. - Term-Vector per Host
A term vector summarizes the most important words that occur in a document or a set of documents as a list of pairs.
The map function emits a
<hostname, term vector>
pair for each input document (where the hostname is extracted from the URL of the document).The reduce function is passed all per-document term vectors for a given host. It adds these term vectors together, throwing away infrequent terms, and then emits a final
<hostname, term vector>
pair. - Inverted Index
The map function parses each document, and emits a sequence of
<word, document ID>
pairs.The reduce function accepts all pairs for a given word, sorts the corresponding document IDs and emits a
<word, list(document ID)>
pair.The set of all output pairs forms a simple inverted index. It is easy to augment this computation to keep track of word position.
- Distributed Sort
The map function extracts the key from each record, and emits a
<key, record>
pair.The reduce function emits all pairs unchanged.
This computation depends on the partitioning facilities described in Section 4.1 and the ordering properties described in Section 4.2.
3 Implementation
This section describes an implementation targeted to the computing environment: large clusters of commodity PCs connected together with switched Ethernet.
- A cluster consists of hundreds of thousands of machines, and therefore machine failures are common.
- A distributed file system (GFS) is used to manage the data stored on the disks attached directly to individual machines. The file system uses replication to provide availability and reliability on top of unreliable hardware.
- Users submit jobs to a scheduling system. Each job consists of a set of tasks, and is mapped by the scheduler to a set of available machines within a cluster.
3.1 Execution Overview
The Map invocations are distributed across multiple machines by automatically partitioning the input data into a set of M splits.
#Distributed
+ + + + + MapReduce + +
+ ++ MapReduce: Simplified Data Processing on Large Clusters +
+ + +
diff --git a/tag/MIT 6.824.html b/tag/MIT 6.824.html
index d3bfc0d..dd7f9e4 100644
--- a/tag/MIT 6.824.html
+++ b/tag/MIT 6.824.html
@@ -65,6 +65,8 @@
+
+
diff --git a/tag/ML.html b/tag/ML.html
index 67af3bb..3d5de50 100644
--- a/tag/ML.html
+++ b/tag/ML.html
@@ -65,6 +65,8 @@
+
+
diff --git a/tag/Software.html b/tag/Software.html
index a9b1ee0..76a133f 100644
--- a/tag/Software.html
+++ b/tag/Software.html
@@ -65,6 +65,8 @@
+
+
diff --git a/tag/UCB CS169.html b/tag/UCB CS169.html
index 4d10567..ef6e80f 100644
--- a/tag/UCB CS169.html
+++ b/tag/UCB CS169.html
@@ -65,6 +65,8 @@
+
+
diff --git "a/tag/\360\237\223\226Note.html" "b/tag/\360\237\223\226Note.html"
index 1732517..a4971d4 100644
--- "a/tag/\360\237\223\226Note.html"
+++ "b/tag/\360\237\223\226Note.html"
@@ -65,6 +65,8 @@
+
+
@@ -98,6 +100,36 @@ #📖Note
+
+
+
+
+
+
+ MapReduce
+
+
+
+
+ MapReduce: Simplified Data Processing on Large Clusters
+
+
+
+
+
diff --git "a/tag/\360\237\232\236Memory.html" "b/tag/\360\237\232\236Memory.html"
index e93d861..59293f0 100644
--- "a/tag/\360\237\232\236Memory.html"
+++ "b/tag/\360\237\232\236Memory.html"
@@ -65,6 +65,8 @@
+
+
+ + + + + MapReduce + +
+ ++ MapReduce: Simplified Data Processing on Large Clusters +
+ + +