Skip to content

Instantly share code, notes, and snippets.

@benguillet benguillet/mapper.js
Created Jun 26, 2013

Embed
What would you like to do?
Word count in Javascript with WebMapReduce (http://webmapreduce.sourceforge.net/).
// Javascript Mapper
function mapper(key, value) {
var words = key.split(' ');
for (var i = 0; i < words.length; ++i) {
Wmr.emit(words[i], '1');
}
}
// Javascript Reducer
function reducer(key, values) {
var count = 0;
for (var i = 0; i < values.length; ++i) {
count += parseInt(values[i], 10);
}
Wmr.emit(key, count.toString());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.