Created
October 27, 2008 02:02
-
-
Save markchadwick/20001 to your computer and use it in GitHub Desktop.
This file contains 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
/* | |
* Silly Word Count example -- Mappers each get 1k input, 15 reducers, combiners currently broken | |
*/ | |
/* | |
* Mapper | |
*/ | |
function(key, value) { | |
var tokens = value.split(' '); | |
for(var i=0; i<tokens.length; i++) { | |
emit(tokens[i], 1); | |
} | |
} | |
/* | |
* Reducer | |
*/ | |
function(key, values) { | |
var sum = 0; | |
for(var i=0; i<values.length; i++) { | |
sum += parseInt(values[i]); | |
} | |
emit(key, sum); | |
} | |
/* | |
* Really. That's it. Input can be hosted on any server that understand HEAD requests and | |
* the Range header. IE: Everything. Clients viewing /jobs/compute/JOB_ID will slowly | |
* compute the count. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment