Skip to content

Commit

Permalink
Adding a bit more of documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Aug 20, 2013
1 parent 07382c7 commit 813e22a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/Cake/ORM/MapReduce.php
Expand Up @@ -24,6 +24,8 @@
* like an iterator for the original passed data after each result has been
* processed, thus offering a transparent wrapper for results coming from any
* source.
*
*
*/
class MapReduce implements IteratorAggregate {

Expand Down Expand Up @@ -81,6 +83,23 @@ class MapReduce implements IteratorAggregate {
/**
* Constructor
*
* ## Example:
*
* Separate all unique odd and even number in an array
*
* {{{
* $data = new \ArrayObject([1, 2, 3, 4, 5, 3]);
* $mapper = function ($key, $value, $mr) {
* $type = ($value % 2 === 0) ? 'even' : 'odd';
* $mr->emitIntermediate($type, $value);
* };
*
* $reducer = function ($type, $numbers, $mr) {
* $mr->emit(array_unique($numbers), $type);
* };
* $results = new MapReduce($data, compact('mapper', 'reducer'));
* }}}
*
* @param \Traversable $data the original data to be processed
* @param array $routines containing the keys `mapper` and `reducer`
* and invokable objects as values
Expand Down

0 comments on commit 813e22a

Please sign in to comment.