Spark开发笔记(2017-05-04)
来源:互联网 发布:网络配置出现问题 编辑:程序博客网 时间:2024/06/05 21:54
在一个rdd操作中是不能同时操作另一个rdd的。你是想 valuesRdd 里面每个值 对于dicRdd 进行过滤,但是在分布式系统里面,每个RDD数据集都切割分发到各个分布式机器虚拟机jvm里,每一个jvm里的数据集不一样,所以,从jvm的角度来看,它是没办法在一块数据集里面操作另外一个整体的RDD
valuesRdd.foreach { i =>val samevalueKeys = dicRdd.filter { d => d._2.equals(i) }.map(d => d._1).collect()}//错误信息:Caused by: org.apache.spark.SparkException: This RDD lacks a SparkContext. It could happen in the following cases: (1) RDD transformations and actions are NOT invoked by the driver, but inside of other transformations; for example, rdd1.map(x => rdd2.values.count() * x) is invalid because the values transformation and count action cannot be performed inside of the rdd1.map transformation. For more information, see SPARK-5063.(2) When a Spark Streaming job recovers from checkpoint, this exception will be hit if a reference to an RDD not defined by the streaming job is used in DStream operations. For more information, See SPARK-13758.
- foreach 的意思 是 对于每一个元素 做一个操作 没有返回值
filter 的意思是 对于每一个元素 做判断 符合条件便留下来 不符合 便过滤掉
fileRdd.foreach 这个操作对 fileRdd 本身不会产生任何改变 函数式编程中有个约束是,不可变量就是定义为 val 的,它就永远不会变了,所以你的filedata map操作之后 要定义一个新的变量
val new_rdd = filedata.map( **************************** )
查看文件时报错No such file or directory,注意是否文件名后边有空格
[myhadoop@sunlight100 ~]$ hadoop fs -du /test/spark/hyp/nulllabelurl/test/baike du: `/test/spark/hyp/nulllabelurl/test/baike': No such file or directory
0 0
- Spark开发笔记(2017-05-04)
- spark应用开发---Spark学习笔记6
- Spark开发笔记(二)
- Spark 学习笔记二开发环境
- (一)spark学习笔记-开发环境
- Spark笔记
- spark笔记
- Spark笔记
- spark笔记
- spark 笔记
- SPARK笔记
- Spark笔记
- spark笔记
- Spark笔记
- spark笔记
- spark笔记
- spark开发
- spark开发
- 友元函数
- swift3 删除main.storyboard之后(纯代码做项目)
- 跨平台远程框架Remoting SDK发布v9新版本,增加新的Code First服务器等功能
- 什么是高内聚、低耦合?
- 多线程执行父类和子类中的同步方法的结论
- Spark开发笔记(2017-05-04)
- mysql sql语句大全
- Android屏幕values-sw适配
- 实时监控系统
- Android项目中嵌套unity出现your hardware does not support this application,sorry!
- input required字段;django input输入框不填写会自动变红如何修改
- 关于图片加载框架Glide
- 类装载
- ES6 -- 最佳代理:Proxy