当前位置 : 主页 > 编程语言 > java >

Spark pipe PHP 实例

来源:互联网 收集:自由互联 发布时间:2022-07-20
package test import org.apache.spark.SparkConf import org.apache.spark.SparkContext object PipeTest def main(args: Array[String]) { val sparkConf = new SparkConf().setAppName("pipe Test") val sc = new SparkContext(sparkConf) val a = sc.para


package test

import org.apache.spark.SparkConf
import org.apache.spark.SparkContext

object PipeTest

def main(args: Array[String]) {
val sparkConf = new SparkConf().setAppName("pipe Test")
val sc = new SparkContext(sparkConf)
val a = sc.parallelize(1 to 9 , 3)
val result = a.pipe("php /home/gt/spark/bin/test.php").collect()//所以这里决定每台机子都装好php
result.foreach { x => println("!!!!!"+x) }
sc.stop()
}

}<?php
$in = fopen('php://stdin','r');
for ($x=0; $x<3; $x++){
$line += fgets($in);
}
echo $line;
echo " Hello world!";
?>

输出:
!!!!!6 Hello world!
!!!!!15 Hello world!
!!!!!24 Hello world!


上一篇:pyspark和spark pipe性能对比 用例程序
下一篇:没有了
网友评论