Coder Social home page Coder Social logo

mapred.io's Introduction

mapreduce based on socket.io
You can use this module, use the browser to easily build mapreduce programming model based on parallel computing platform. On this platform, you can submit the page using javascript mapreduce tasks.

##install

npm install mapred.io

Server

var app = require('http').createServer(handler)
  , fs = require('fs')
  , io = require('mapred.io').listen(app)
  , parse = require('url').parse;
  
  app.listen(80);
  io.set('log level', 2);

function handler (req, res) {
  var info = parse(req.url, true);

  var hander = function (err, data) {
	if (err) {
	  res.writeHead(500);
	  return res.end('Error loading file');
	}

	res.writeHead(200);
	res.end(data);
  }
  if (info.pathname.match(/\/public/))
	fs.readFile(__dirname + info.pathname, hander )
  else if (info.pathname.match(/\/client/))
	fs.readFile(__dirname + '/client.html', hander )
  else fs.readFile(__dirname + '/job.html', hander )
}

Client

<script type="text/javascript" src="/socket.io/socket.io.js"></script>
<script type="text/javascript" src="/socket.io/mapred.io.js"></script>
<script type="text/javascript" >
var socket = io.connect();
var MapredClient = new MapredClient(socket);
</script>

Submit Job

<script type="text/javascript" src="/socket.io/socket.io.js"></script>
<script type="text/javascript" src="/socket.io/mapred.io.js"></script>
<script type="text/javascript" >

var input = [
	['frase primera', 'primer trozo de informacion para procesado primer trozo'],
	['segunda frase', 'segundo trozo de informacion trozo de'],
	['cacho 3', 'otro trozo para ser procesado otro otro otro trozo'],
	['cuarta frase', 'primer trozo de informacion para procesado primer trozo'],
	['frase 5', 'segundo trozo de informacion trozo de']
], inputs = input, i;
//for ( i = 0 ; i &lt; 20000 ; i ++ ) inputs = inputs.concat(input);

socket.emit('job', { map: (function(key, value){
    var list = [], aux = {};
        value = value.split(' ');
        value.forEach(function(w){
            aux[w] = (aux[w] || 0) + 1;
        });
        for(var k in aux){
            list.push([k, aux[k]]);
        }
        return list;
    }).toString(), reduce: (function(key, values){
        var sum = 0;
        values.forEach(function(e){
            sum += e;
        });
        return sum;
    }).toString(), inputs:inputs)

change log

2013-11-29 update mapred.io-client.js can be using in browser and command line, add client.js can run as a node.

To do

  1. Performance Test
  2. Client program (the standalone client not on the browser).
  3. Stored the datas (the server do not have enough memory to handle large data, Need a fast persistent storage framework. Just using the store of socket.io default is "MemoryStore", you can using "RedisStore")

screenshot screenshot update the screeshot

mapred.io's People

Contributors

lloydzhou avatar

Stargazers

DF.K avatar Arvind Gupta avatar  avatar

Watchers

 avatar  avatar

Forkers

wqw547243068

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.