# notes26 - roughly like this(define(mapreduce mapper reducer...

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: roughly like this: (define (mapreduce mapper reducer base-case data) ; handwavy approximation (groupreduce groupreduce groupreduce reducer base-case (sort-into-buckets sort-into-buckets sort-into-buckets (map map map mapper data)))) (define (groupreduce reducer base-case buckets) (map (lambda (subset) (make-kv-pair (kv-key (car subset)) (reduce reducer base-case (map kv-value subset)))) buckets)) As a first example, we’ll take some grades from various exams and add up the grades for each student. This example doesn’t require map . Here’s the raw data: (define mt1 ’((cs61a-xc . 27) (cs61a-ya . 40) (cs61a-xw . 35) (cs61a-xd . 38) (cs61a-yb . 29) (cs61a-xf . 32))) (define mt2 ’((cs61a-yc . 32) (cs61a-xc . 25) (cs61a-xb . 40) (cs61a-xw . 27) (cs61a-yb . 30) (cs61a-ya . 40))) (define mt3 ’((cs61a-xb . 32) (cs61a-xk . 34) (cs61a-yb . 30) (cs61a-ya . 40) (cs61a-xc . 28) (cs61a-xf . 33))) Each midterm in this toy problem corresponds to the output of a parallel map operation in a real problem.operation in a real problem....
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online