示例#1
0
 public function testScenario1()
 {
     $counter = new CharCounter();
     $counter->count('abca');
     $this->assertEquals(3, count(CharCounter::$char_count));
     $this->assertEquals(1, count(CharCounter::$char_count['a']));
     $this->assertEquals(1, count(CharCounter::$char_count['b']));
     $this->assertEquals(1, count(CharCounter::$char_count['c']));
     $this->assertEquals(2, $counter->getCharCount('a'));
     $this->assertEquals(1, $counter->getCharCount('b'));
     $this->assertEquals(1, $counter->getCharCount('c'));
 }
示例#2
0
 public function count($target)
 {
     self::$char_count = array();
     $map = new MapTask();
     $map->execute($target);
     $reduce_task = new ReduceTask();
     $input_list = ReduceInputListFactory::createInstance($map->getList());
     foreach ($input_list as $input) {
         $reduce_task->execute($input);
     }
 }
示例#3
0
<?php

require_once dirname(__FILE__) . '/lib/CharCounter.php';
$counter = new CharCounter();
$counter->count('abcaba');
echo 'a:' . $counter->getCharCount('a') . "\n";
echo 'b:' . $counter->getCharCount('b') . "\n";
echo 'c:' . $counter->getCharCount('c') . "\n";
示例#4
0
 public function execute(ReduceInput $input)
 {
     $this->count = count($input->getList());
     CharCounter::emit($input, $this->count);
 }