PHP's job is to make every word into an rdd.
$in = fopen('php://stdin','r');while(!feof($in)){ $temp = explode(" ",fgets($in)); for ($i=0;$i
<>
$temp
);$i++){ printf("%s\n",$temp[$i]); } }?>
package testimport org.apache.spark.SparkConfimport org.apache.spark.SparkContextobject PipeTest { def main(args: Array[String]) { val sparkConf = new SparkConf().setAppName("pipe Test") val sc = new SparkContext(sparkConf) val a = sc.textFile("/home/gt/wordcount.txt"3) val result = a.pipe("php /home/gt/spark/bin/test.php").map(x => (x1)).reduceByKey(_ + _) result.foreachx => println("!!!!! "x) } sc.stop() }}
'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
'). Text (i)); }; $numbering. FadeIn (1700); }); });
The above describes the spark Pipe + PHP WordCount implementation, including the aspects of the content, I hope the PHP tutorial interested in a friend helpful.