lab13 - CS 61A Week 13 Lab Solutions 1. We make two...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 61A Week 13 Lab Solutions 1. We make two changes: First, change the mapper function so that the intermediate pairs use the play names as keys. This will result in a separate reduce instance for each play. Then, we do an ordinary non-parallel stream-accumulate to combine those results into a single count. (Shakespeare didn't write so many plays that we can't accumulate the results of the different plays on a single processor.) (STREAM-ACCUMULATE (LAMBDA (NEW OLD) (+ (KV-VALUE NEW) OLD)) 0 (mapreduce (lambda (kv-pair) (list (make-kv-pair (KV-KEY KV-PAIR) 1))) + 0 "/gutenberg/shakespeare")) 2(a). The mapper gets a line as input, but wants to output a separate key-value pair for each word in the line. (define gutenberg-wordcounts (mapreduce (lambda (line-pair) (map (lambda (wd) (make-kv-pair wd 1)) (kv-value line-pair))) + 0 "/gutenberg/shakespeare")) 2(b). We want to reduce gutenberg-wordcounts by comparing the counts of two words at a time, keeping the one with the larger count. But there are a
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/12/2010 for the course CS 61A taught by Professor Harvey during the Spring '08 term at University of California, Berkeley.

Page1 / 2

lab13 - CS 61A Week 13 Lab Solutions 1. We make two...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online