spark Parallel Computation log
来源:互联网 发布:js 切换embed视频播放 编辑:程序博客网 时间:2024/06/10 15:13
1. build a method to simulate a algorithm run (Do not use the thread technology to simulate)
import java.util.Random;public class TimerSimulate {Random r=new Random();public String test(String a) {String ret="";for (int i = 0; i < 1000; i++) {for (int j = 0; j < 10000; j++) {for (int x = 0; x < 10; x++) {long k = i * j * x;k = 888;ret=a+" "+k;}}}return ret;}public static void main(String[] args) {TimerSimulate t = new TimerSimulate();long begin = System.currentTimeMillis();for(int i=0;i<10;i++){String str=t.test("a");System.out.println(str);}long end = System.currentTimeMillis();System.out.println("Total Time in second:" + (end - begin) / 1000);}}
2. build the scala programe, please pay attention to the cluster number and the core, and the split
import org.apache.spark.SparkContextimport org.apache.spark.rdd.RDDimport java.lang.Threadimport java.util.Randomobject NTest { val t:TimerSimulate =new TimerSimulate() def nf(str:String):(String)= { val ret=t.test(str) (str+"--"+ret) } def main(args: Array[String]) { val r:Random=new Random(); val sc = new SparkContext("spark://ip:7077", "ntest", System.getenv("SPARK_HOME"), SparkContext.jarOfClass(this.getClass)) val arr = new Array[String](args(0).toInt) for (i <- 0 to arr.length - 1) { val a=r.nextInt(1000) arr(i)=a+"" } val dataset1:RDD[(String)]= sc.parallelize(arr,args(1).toInt).map(nf) dataset1.coalesce(1, true).saveAsTextFile("hdfs://ip:9000/test/ntest"); }}
0 0
- spark Parallel Computation log
- A demo for parallel computation based on yuan api technology log
- log file parallel write
- log file parallel write
- log file parallel write&&log buffer space
- log file sync and log file parallel wait event
- log buffer —— log file parallel write
- log file sync和log file parallel write的关系
- log file sync 与 log file parallel write 等待事件
- 文献:利用自驱动分子马达并行计算子集和问题 Parallel computation with molecular-motor-propelled agents...(PNAS)
- Parallel
- Oracle db file parallel write 和 log file parallel write 等待事件 说明
- Oracle db file parallel write 和 log file parallel write 等待事件 说明
- log file parallel write wait event(摘自sharklove)
- WAITEVENT: "log file parallel write" Reference Note (文档 ID 34583.1)
- spark 运行log cluster 模式
- log file sync(日志文件同步) 与 Log file parallel write 等待事件
- log file sync(日志文件同步) 与 Log file parallel write 等待事件
- Android WebView中的JavaScript和java代码的交互
- 高人对libsvm的经典总结
- [转载]Oracle EBS之Oracle Forms中的“WHEN-LEAVE-RECORD”触发器
- iframe实用操作
- 无项无权图的基本操作
- spark Parallel Computation log
- 谷歌招聘新职员的五大标准
- PHP在arm板子上的移植
- java Servlet和tomcat
- 分类算法之朴素贝叶斯分类(Naive Bayesian classification)
- 【梦幻连连连】源码分析(完)-寻路消除算法
- 移动支付创新公司Square亏损扩大 或被收购
- 解决JQuery EasyUI 加载两次url的问题
- IOS UIFont 字体大全