MapReduce using V8 JavaScript and Node.js
/* Harnesses the prowess of V8 and the versatility of Node.js to setup MapReduce system in JavaScript. */
/* Find the number of occurrences of every word in a bunch of files. */

var fs = require('fs');
var mapjs = require('../mapjs');
var map = require('../lib/map');
var reduce = require('../lib/reduce');
var input = require('../lib/input');
var OutputCollector = mapjs.OutputCollector;
var JobConf = require('../lib/jobconf').JobConf;
var JobClient = require('../lib/jobclient').JobClient;
var InputSplit = input.InputSplit;

var mapper = map.createMapper(function(key, value, outputCollector, reporter) {
    outputCollector.collect(key, 1); // here we mark every word we encounter.
var reducer = reduce.createReducer(function(key, values, outputCollector, reporter) {
    console.log(key + " has occurred " + values.length.toString() + " times.");

var inputFormat = input.createInputFormat(function(fileName) {
    var inputSplits = [];

    var data = fs.readFileSync(fileName, 'ascii');
        if(data) {
            var chunks = data.toString().split( ' ');
            for(var i = 0; i < chunks.length; ++i) {
            inputSplits.push(new InputSplit(chunks[i]));

    return inputSplits;

var jobconf = new JobConf();
var jobclient = new JobClient();
jobconf.mapper = mapper;
jobconf.reducer = reducer;
jobconf.inputFormat = inputFormat;
jobconf.inputPath = "./tests/data/input/";
jobconf.outputPath = "./tests/data/output/";;
Map.js is a MapReduce framework in JavaScript based on V8 JavaScript Engine and Node.js. The goal is to provide an easy solution for developers to build any MapReduce system easily using nothing but JavaScript. Map.js uses Node.js as the underlying framework to achieve functionalities that are not present in the language, and V8 as the underlying JavaScript engine for additional functionalities needed within the framework.

The interfaces and inner workings of the Map.js greatly resembles those other popular MapReduce frameworks such as Hadoop. This introduces the least amount of learning curves for people to get started with the framework.