1 / 7

Sort in MapReduce

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

teneil
Download Presentation

Sort in MapReduce

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Sort in MapReduce

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

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

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

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

  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) • publicvoid map(Object key, Text value, Context context) throwsException • { • //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) • publicvoid reduce(Text key, Iterable<Text> values, Context context) throwsIOException, InterruptedException • { • while(values.iterator().hasNext()) • { • context.write(key, values.iterator().next()); • } • }

More Related