Esempio n. 1
0
 public function testScenario1()
 {
     $entries = array(new MapEntry('a', 1), new MapEntry('a', 2), new MapEntry('a', 3));
     $input = new ReduceInput();
     $input->setKey('a');
     $input->setList($entries);
     $this->assertEquals('a', $input->getKey());
     $this->assertType('array', $input->getList());
     $this->assertEquals(3, count($input->getList()));
 }
 public static function createInstance($entries)
 {
     $list = array();
     $current = null;
     $reduce_input = null;
     foreach ($entries as $entry) {
         if (!$entry->equals($current)) {
             $current = $entry;
             $reduce_input = new ReduceInput();
             $reduce_input->setKey($entry->getKey());
             $list[] = $reduce_input;
         }
         $reduce_input->addToList($entry);
     }
     return $list;
 }