2017 © Pedro Peláez
 

library phadoop

Simple library for writing map/reduce jobs for Hadoop in PHP

image

ihor/phadoop

Simple library for writing map/reduce jobs for Hadoop in PHP

  • Monday, January 4, 2016
  • by ihor
  • Repository
  • 2 Watchers
  • 16 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 8 % Grown

The README.md

Phadoop

Phadoop allows you to write map/reduce tasks for Hadoop in PHP. I created it to give a techtalk about Hadoop in the company I worked in. It is not ready for production use yet but can help you to play with Hadoop in PHP., (*1)

Installation

Define the following requirement in your composer.json file:, (*2)

"require": {
    "ihor/phadoop": "0.1.x-dev"
}

or simply execute the following in the command line:, (*3)

composer require ihor/phadoop

Usage

class Mapper extends \Phadoop\MapReduce\Job\Worker\Mapper
{
    protected function map($key, $value)
    {
        $this->emit('wordsNumber', count(preg_split('/\s+/', trim((string) $value))));
    }

}

class Reducer extends \Phadoop\MapReduce\Job\Worker\Reducer
{
    protected function reduce($key, \Traversable $values)
    {
        $result = 0;
        foreach ($values as $value) {
            $result += (int) $value;
        }

        $this->emit($key, $result);
    }
}

$mr = new \Phadoop\MapReduce('<path-to-hadoop>');

$job = $mr->createJob('WordCounter', 'Temp')
    ->setMapper(new Mapper())
    ->setReducer(new Reducer())
    ->clearData()
    ->addTask('Hello World')
    ->addTask('Hello Hadoop')
    ->putResultsTo('Temp/Results.txt')
    ->run();

echo $job->getLastResults();

You can find more examples in the examples directory., (*4)

The Versions

04/01 2016

dev-master

9999999-dev

Simple library for writing map/reduce jobs for Hadoop in PHP

  Sources   Download

MIT

The Requires

 

by Ihor Burlachenko

map hadoop reduce