// TODO

var GlueMapReduce = ( function () {
	return function () {
		var self = this;

		self.mapper = function () {};

		self.reducer = function () {};

		self.run = function () {};

		self.mode = null;

		Object.preventExtensions( this );
	};
}() );

exports = module.exports = GlueMapReduce;

var _     = require( 'lodash' ),
    async = require( 'async' );

var GlueMapReduce = ( function () {
    return function () {
        var self = this;
        self.mode = null;
        self.mapSeparator    = '\t';
        self.reduceSeparator = '\t';

        self.mapper = function () {};

        self.reducer = function () {};

        self.run = function ( data, callback ) {
            var subrun = null;
            switch ( self.mode ) {
                case 'mapper':
                case 'map':
                    subrun = self._runMapper;
                    break;
                case 'reducer':
                case 'red':
                    subrun = self._runReducer;
                    break;
                default:
                    subrun = self._runLocal;
                    break;
            }
            return subrun( data, callback );
        };

        // Hadoop streaming mapper mode
        self._runMapper = function ( data, callback ) {
            async.eachSeries( data, function ( datum, next ) {
                self.mapper( datum, function ( error, results ) {
                    self._logMapResults( results );
                    return next( error );
                } );
            }, function ( error ) {
                return callback( error );
            } );
        };

        // Hadoop streaming mapper output
        self._logMapResults = function ( results ) {
            _.each( results, function ( result ) {
                var line = result.k + self.mapSeparator + result.v;
                console.log( line );
            } );
        };

        // Hadoop streaming reducer mode
        self._runReducer = function ( data, callback ) {
            // body...
        };

        // local Map-Reduce mode
        self._runLocal = function ( data, callback ) {
            // body...
        };

        // optional
        self.shuffler = function () {
            // body...
        };

        Object.preventExtensions( this );
    };
}() );

exports = module.exports = GlueMapReduce;

Implement Hadoop streaming mapper mode
Implement Hadoop streaming mapper mode
