Skip to content

Commit 3fb98de

Browse files
author
Tod Jiang
committed
update
1 parent 4272670 commit 3fb98de

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

_posts/2014-08-06-hadoop.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,20 @@ A MapReduce program is composed of a Map() procedure that performs filtering and
3232
Map is the name of a higher-order function that applies a given function to each element of a list, returning a list of results. It is often called apply-to-all when considered in functional form. This is an example of functoriality.
3333

3434
For example, if we define a function square as follows:
35-
35+
```
3636
square x = x * x
37+
```
3738
Then calling map square [1,2,3,4,5] will return [1,4,9,16,25], as map will go through the list and apply the function square to each element.
3839

39-
###Python
40-
map(func, list1, list2, ...)
41-
42-
Returns a list in Python 2 and an iterator in Python 3.
43-
44-
###Scala
45-
map: list.map(func)
46-
map n list: (list1, list2, list3).zipped.map(func)
47-
48-
###Java 8+
49-
stream.map(func)
40+
|Language|Map |Map 2 lists |Map n lists |Note|
41+
|---|---|---|---|---|
42+
|Python|map(func,list)|map(func,list1,list2)|map(func,list1,list2,...)|Returns a list in Python 2 and an iterator in Python 3.|
43+
|Scala|list.map(func)|(list1,list2).zipped.map(func)|(list1,list2,list3).zipped.map(func)|note: more than 3 not possible.|
44+
|Java8|stream.map(func)| | ||
5045

5146

5247
## [Reduce][Reduce_]
53-
48+
fold – also known variously as reduce, accumulate, aggregate, compress, or inject – refers to a family of higher-order functions that analyze a recursive data structure and recombine through use of a given combining operation the results of recursively processing its constituent parts, building up a return value. Typically, a fold is presented with a combining function, a top node of a data structure, and possibly some default values to be used under certain conditions. The fold then proceeds to combine elements of the data structure's hierarchy, using the function in a systematic way
5449

5550
|Language|Left fold |Right fold| Left fold without initial value | Right fold Right fold |
5651
|---|---|---|---|---|
@@ -69,6 +64,8 @@ stream.map(func)
6964
* outputs a function
7065

7166

67+
-----------------------------
68+
7269
## Use case scenario
7370
[Hadoop Spark Hbase Redis ][hadoop_spark_hbase_redis]
7471

0 commit comments

Comments
 (0)