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

商城网站建设专业公司云梦主城区核酸检测

商城网站建设专业公司,云梦主城区核酸检测,广州网页设计美工培训,网站接口需求本博文的主要内容是#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://www.pierceye.com/news/448679/

相关文章:

  • 怎么免费建立自己网站扁平化网站设计
  • 可以自己做漫画的网站北仑营销型网站制作
  • 免费网站统计代码有什么样的网站开发
  • 文山微网站建设湖南人工智能建站系统软件
  • 做网站时候编代码wordpress 技术博客主题
  • 成立网站建设工作领导小组seo网站关键词优化软件
  • 怎么兼职做网站网站建设 运维 管理包括
  • 乐清市住房和城乡建设规划局网站专业做家居的网站
  • 做3d打印网站苏州建设工程人才招聘网信息网站
  • 网站建设丂金手指科杰wordpress中logo大小
  • 微餐饮网站建设被老板抓到用公司产品做自己的网站
  • 软件公司网站模板下载定制搭建网站
  • 网站建设实训报告要求怎么做公司门户网站
  • 深圳规划建设局网站wordpress改变访问目录
  • dw怎么做购物网站o2o平台都有哪些
  • 阿里云备案多个网站吗应用商店下载app软件
  • 响应式网站手机端尺寸网站开发培训心得
  • 徐州手机网站开发公司电话江苏五星建设网站
  • 网站建设全包广做短视频素材哪里找
  • 做网站为什么每年都要续费企业官网建站步骤
  • 培训行业门户网站建设方案专业网站运营制作
  • 百度网站两两学一做心得体会江苏专业网站建设费用
  • 做企业网站的架构图网站上的销售怎么做
  • 网站开发思维导图内容淘宝客在百度推广网站么做
  • 国外美容网站crm开发
  • 辽宁建设资质申报网站wordpress提示插件安装
  • 做网站用什么软件语言wordpress绑定域名后乱码
  • 网站建设邀请函郑州网站搭建的公司
  • 网站制作论文优帮云广州网站设计首选柚米
  • 唐山建设厅官方网站我有一个网站怎么做外贸