如何使用php在mapper中获取输入文件名?
答案 0 :(得分:0)
如上所述here,对于php,map-reduce的模板是:
01 function map ($filename, $content) {
02 foreach (explode('', $content) as $word) {
03 collect($word, 1);
04 }
05 }
06
07 function reduce($word, $values) {
08 $numWordCount = 0;
09
10 foreach ($values as $value) {
11 $numWordCount += $value;
12 }
13
14 collect($word, $numWordCount);
现在,$filename
的值不能是printed inside a php function吗?