Skip to content

Instantly share code, notes, and snippets.

@michaelfairley
Created September 12, 2010 16:45
Show Gist options
  • Save michaelfairley/576229 to your computer and use it in GitHub Desktop.
Save michaelfairley/576229 to your computer and use it in GitHub Desktop.
#!/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