Presentation is loading. Please wait.

Presentation is loading. Please wait.

Sort in MapReduce. MapReduce Block 1 Block 2 Block 3 Block 4 Block 5 Map Reduce Output 1 Output 2 Shuffle/Sort.

Similar presentations


Presentation on theme: "Sort in MapReduce. MapReduce Block 1 Block 2 Block 3 Block 4 Block 5 Map Reduce Output 1 Output 2 Shuffle/Sort."— Presentation transcript:

1 Sort in MapReduce

2 MapReduce Block 1 Block 2 Block 3 Block 4 Block 5 Map Reduce Output 1 Output 2 Shuffle/Sort

3 How to Sort in MapReduce? Block 1 Block 2 Block 3 Block 4 Block 5 Map Reduce Output 1 Output 2 Use the Built-In Mechanism to Sort Data Shuffle/Sort

4 Mapper 1337 1103 1242 0932 0432 1690 1324 0232 (1,1337) (2,1103) (3,1242) (4,0932) (5,0432) (6,1690) (7,1324) (8,0232) Mapper (1337,null) (1103,null) (1242,null) (0932,null) (0432,null) (1690,null) (1324,null) (0232,null) Input Input Key- Value Pairs Intermediate Key-Value Pairs Block 1 Block 2

5 Reducer (1337,null) (1103,null) (1242,null) (0932,null) (0432,null) (1690,null) (1324,null) (0232,null) Reducer 0232 0432 0932 1103 1242 1324 1337 1690 Shuffle and Sort Sorted Outputs Output 1 Output 2 Intermediate Key-Value Pairs

6 The MapReduce Program Mapper: Input Key-Value Pairs: (k, v) Output Key-Value Pairs: (v, null) Reducer: Input Key-Value Pairs: (v, null) Output Key-Value Pairs: (v, null) public void map(Object key, Text value, Context context) throws Exception { //Parse the value, if required. context.write(value, null); }

7 The MapReduce Program Mapper: Input Key-Value Pairs: (k, v) Output Key-Value Pairs: (v, null) Reducer: Input Key-Value Pairs: (v, null) Output Key-Value Pairs: (v, null) public void reduce(Text key, Iterable values, Context context) throws IOException, InterruptedException { while(values.iterator().hasNext()) { context.write(key, values.iterator().next()); }


Download ppt "Sort in MapReduce. MapReduce Block 1 Block 2 Block 3 Block 4 Block 5 Map Reduce Output 1 Output 2 Shuffle/Sort."

Similar presentations


Ads by Google