一、前述
SparkStreaming中的算子分为两类,一类是Transformation类算子,一类是OutPutOperator类算子。
Transformation类算子updateStateByKey,reduceByKeyAndWindow,transform
OutPutOperator类算子print,foreachRDD,saveAsTextFile
li { list-style: none; margin: 0 }
p { margin: 0 }
span.l { color: red; font-weight: bold }
a.mapnode:link { text-decoration: none; color: black }
a.mapnode:visited { text-decoration: none; color: black }
a.mapnode:active { text-decoration: none; color: black }
a.mapnode:hover { text-decoration: none; color: black; background: #eeeee0 }
本文讲解OutPutOperator类算子。
li { list-style: none; margin: 0 }
p { margin: 0 }
span.l { color: red; font-weight: bold }
a.mapnode:link { text-decoration: none; color: black }
a.mapnode:visited { text-decoration: none; color: black }
a.mapnode:active { text-decoration: none; color: black }
a.mapnode:hover { text-decoration: none; color: black; background: #eeeee0 }
li { list-style: none; margin: 0 }
p { margin: 0 }
span.l { color: red; font-weight: bold }
a.mapnode:link { text-decoration: none; color: black }
a.mapnode:visited { text-decoration: none; color: black }
a.mapnode:active { text-decoration: none; color: black }
a.mapnode:hover { text-decoration: none; color: black; background: #eeeee0 }
--
--> { }
li { list-style: none; margin: 0 }
p { margin: 0 }
span.l { color: red; font-weight: bold }
a.mapnode:link { text-decoration: none; color: black }
a.mapnode:visited { text-decoration: none; color: black }
a.mapnode:active { text-decoration: none; color: black }
a.mapnode:hover { text-decoration: none; color: black; background: #eeeee0 }
--
--> { }
二、具体
1、foreachRDD
可以拿到DStream中的一个个的RDD,对拿到的RDD可以使用Transformation类算子对数据进行转换,foreachRDD方法内,拿到的RDD Transformation类算子外的代码是在Driver端执行
原文地址:https://www.cnblogs.com/LHWorldBlog/p/8521574.html