Created
September 12, 2010 16:45
-
-
Save michaelfairley/576229 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import mincemeat | |
data = ["Humpty Dumpty sat on a wall", | |
"Humpty Dumpty had a great fall", | |
"All the King's horses and all the King's men", | |
"Couldn't put Humpty together again", | |
] | |
def mapfn(k, v): | |
for w in v.split(): | |
yield w, 1 | |
def reducefn(k, v): | |
result = 0 | |
for val in v: | |
result += val | |
return result | |
s = mincemeat.Server() | |
s.datasource = dict((i, data[i]) for i in xrange(len(data))) | |
s.mapfn = mapfn | |
s.reducefn = reducefn | |
results = s.run_server() | |
print results |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment