当前位置: 首页 > news >正文

2345中国最好的网址站如何做微信官方网站

2345中国最好的网址站,如何做微信官方网站,wordpress 卡,重庆建设工程造价信息网官网查询本博文的主要内容是#xff1a; 1、rdd基本操作实战 2、transformation和action流程图 3、典型的transformation和action RDD有3种操作#xff1a; 1、 Trandformation 对数据状态的转换#xff0c;即所谓算子的转换 2、 Action 触发作业#xff0c;即所谓得结果…本博文的主要内容是 1、rdd基本操作实战 2、transformation和action流程图 3、典型的transformation和action       RDD有3种操作 1、  Trandformation      对数据状态的转换即所谓算子的转换 2、  Action    触发作业即所谓得结果的 3、  Contoller  对性能、效率和容错方面的支持如cache、persist、checkpoint Contoller包括cache、persist、checkpoint。   /** * Return a new RDD by applying a function to all elements of this RDD. */def map[U: ClassTag](f: T U): RDD[U] withScope { val cleanF sc.clean(f) new MapPartitionsRDD[U, T](this, (context, pid, iter) iter.map(cleanF))} 传入类型是T返回类型是U。       元素之间为什么reduce操作要符合结合律和交换律答因为交换律不知哪个数据先过来。所以必须符合交换律。 在交换律基础上想要reduce操作必须要符合结合律。/** * Reduces the elements of this RDD using the specified commutative and * associative binary operator. */def reduce(f: (T, T) T): T withScope { val cleanF sc.clean(f) val reducePartition: Iterator[T] Option[T] iter { if (iter.hasNext) { Some(iter.reduceLeft(cleanF)) } else { None } } var jobResult: Option[T] None val mergeResult (index: Int, taskResult: Option[T]) { if (taskResult.isDefined) { jobResult jobResult match { case Some(value) Some(f(value, taskResult.get)) case None taskResult } } } sc.runJob(this, reducePartition, mergeResult) // Get the final result out of our Option, or throw an exception if the RDD was empty jobResult.getOrElse(throw new UnsupportedOperationException(empty collection))} RDD.scala源码 这里新建包com.zhouls.spark.cores package com.zhouls.spark.cores/** * Created by Administrator on 2016/9/27. */object TextLines {}下面开始编代码本地模式 自动 会写好 源码来看 所以 val lines sc.textFile(C:\\Users\\Administrator\\Desktop\\textlines.txt) //通过HadoopRDD以及MapPartitionsRDD获取文件中每一行的内容本身     val lineCount lines.map(line (line,1)) //每一行变成行的内容与1构成的Tuple val textLines lineCount.reduceByKey(__) textLines.collect.foreach(pair println(pair._1 : pair._2))  成功  现在将此行代码 textLines.collect.foreach(pair println(pair._1 : pair._2))改一改 textLines.foreach(pair println(pair._1 : pair._2)) 总结 本地模式里 textLines.collect.foreach(pair println(pair._1 : pair._2))改一改 textLines.foreach(pair println(pair._1 : pair._2)) 运行正常因为在本地模式下是jvm但这样书写是不正规的。     集群模式里 textLines.collect.foreach(pair println(pair._1 : pair._2))改一改 textLines.foreach(pair println(pair._1 : pair._2)) 运行无法通过因为结果是分布在各个节点上。 collect源码 /** * Return an array that contains all of the elements in this RDD. */def collect(): Array[T] withScope { val results sc.runJob(this, (iter: Iterator[T]) iter.toArray) Array.concat(results: _*)}得出collect后array中就是一个元素只不过这个元素是一个Tuple。 Tuple是元组。通过concat合并 foreach源码 /** * Applies a function f to all elements of this RDD. */def foreach(f: T Unit): Unit withScope { val cleanF sc.clean(f) sc.runJob(this, (iter: Iterator[T]) iter.foreach(cleanF))}      rdd实战rdd基本操作实战至此          rdd实战transformation流程图  拿wordcount为例   启动hdfs集群 sparkSparkSingleNode:/usr/local/hadoop/hadoop-2.6.0$ sbin/start-dfs.sh      启动spark集群 sparkSparkSingleNode:/usr/local/spark/spark-1.5.2-bin-hadoop2.6$ sbin/start-all.sh     启动spark-shell sparkSparkSingleNode:/usr/local/spark/spark-1.5.2-bin-hadoop2.6/bin$ ./spark-shell --master spark://SparkSingleNode:7077 --executor-memory 1g     scala val partitionsReadmeRdd  sc.textFile(hdfs://SparkSingleNode:9000/README.md).flatMap(_.split( )).map(word (word,1)).reduceByKey(__,1).saveAsTextFile(~/partition1README.txt)  或者  scala val readmeRdd sc.textFile(hdfs://SparkSingleNode:9000/README.md)  scala  val partitionsReadmeRdd readmeRdd.flatMap(_.split( )).map(word (word,1)).reduceByKey(__,1) .saveAsTextFile(~/partition1README.txt)   注意~目录不是这里。        为什么我的不是这样的显示呢       RDD的transformation和action执行的流程图     典型的transformation和action 转载于:https://www.cnblogs.com/zlslch/p/5913334.html
http://wiki.neutronadmin.com/news/188059/

相关文章:

  • wordpress建博客网站旅游网站建设价格
  • 网站媒体给房开做内容推广徐州市新沂市建设局网站
  • 在微信上做彩票网站有哪些公司建设网站的案例分析
  • 网站建设运营服务商网站源码和模板的区别
  • 动漫制作专业什么电脑最适合如何做好网站针对搜索引擎的seo
  • 商城网站建设天软科技公共法律服务网站平台建设预算
  • 极速建站网站模板中国建设银行余额查询入口
  • 滁州市建设局网站wordpress主题添加设置页面
  • 怎样做免费外贸网站厦门今天刚刚发生的新闻
  • 功能型网站wordpress链接自定义后文章打不开
  • 佛山网站哪家最专业凡科网站建设怎么去掉极速建站
  • win8网站模板白云网站制作
  • 网站开发运行环境有哪些三河建设局网站
  • 建设部网站规范查询纺织网站制作123纺织网
  • 中国建设造价工程协会网站wordpress搜索中文插件
  • 网站建设可以抵扣吗开发板原理图
  • 南京网站制作设计7k7k小游戏在线玩
  • 网站建设j基本步骤农化网站建设
  • 南京网站建设价位本地推广平台有哪些
  • 买完域名网站怎么设计手机软件公司
  • 网站优化页面外贸移动商城网站建设
  • 摄影个人网站模板苏州集团网站制作公司
  • 免费创建app网站著名网站建设公司
  • 专业网站建设效果显著专业的网站建设企业网站
  • cms建设网站如何申请企业邮箱
  • 网站建立的意义wordpress图片缩略图不显示
  • 西安php网站开发培训班成品免费ppt网站
  • 响应式网站的组成公众号推广方法
  • 千万别学网络工程网站关键词优化工具
  • 中国建设会计协会网站首页网站备案 深圳