Skip to content
Permalink
Browse files

Adding a bit more of documentation

  • Loading branch information...
lorenzo committed Aug 20, 2013
1 parent 07382c7 commit 813e22a6e5123a2a07702614ed932af458acf8d5
Showing with 19 additions and 0 deletions.
  1. +19 −0 lib/Cake/ORM/MapReduce.php
@@ -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 {
@@ -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

0 comments on commit 813e22a

Please sign in to comment.
You can’t perform that action at this time.