摘要: 一般情况下,一个客户端指定一个集群,但是存在一个客户端指定多个集群的情况,这种情况下,需要动态调整配置文件 //配置文件可以通过传参或者数据库进行读取 package com.cslc import org.apache.hadoop.conf.Configuration import org.ap 阅读全文
posted @ 2021-01-11 20:39 bioamin 阅读(1174) 评论(0) 推荐(0) 编辑
摘要: 累加器原理图: 累加器创建: sc.longaccumulator("") sc.longaccumulator sc.collectionaccumulator() sc.collectionaccumulator sc.doubleaccumulator() sc.doubleaccumulat 阅读全文
posted @ 2021-01-11 18:58 bioamin 阅读(317) 评论(0) 推荐(0) 编辑
摘要: 如何理解广播变量? 适用场景:大变量,比如100M以上的大集合。算子函数中使用到外部变量时,默认情况下,Spark会将该变量复制多个副本,通过网络传输到task中,此时每个task都有一个变量副本。如果变量本身比较大的话(比如100M,甚至1G),那么大量的变量副本在网络中传输的性能开销,以及在各个 阅读全文
posted @ 2021-01-11 17:02 bioamin 阅读(89) 评论(0) 推荐(0) 编辑
摘要: countByKey 和 countByValue都是 action算子 ,结果集均在driver端,输出时不需要单独做collect spark.sparkContext.setLogLevel("error") val bd=spark.sparkContext.parallelize(List 阅读全文
posted @ 2021-01-11 16:44 bioamin 阅读(262) 评论(0) 推荐(0) 编辑
摘要: zip transformation算子,将两个RDD中的元素(KV格式/非KV格式)变成一个KV格式的RDD,两个RDD的每个分区元素个数必须相同。 spark.sparkContext.setLogLevel("error") spark.sparkContext.setLogLevel("er 阅读全文
posted @ 2021-01-11 16:34 bioamin 阅读(319) 评论(0) 推荐(0) 编辑
摘要: mapPartitionWithindex transformation算子,每次输入是一个分区的数据,并且传入数据的分区号 spark.sparkContext.setLogLevel("error")val kzc=spark.sparkContext.parallelize(List(("hi 阅读全文
posted @ 2021-01-11 15:11 bioamin 阅读(226) 评论(0) 推荐(0) 编辑
摘要: foreachPartition action 算子,与foreach相比,foreach每次输入的是一行数据,而foreachPartition每次输入的是一个分区的数据(iterator) result2.foreachPartition(x=>{ println("**********") w 阅读全文
posted @ 2021-01-11 14:14 bioamin 阅读(498) 评论(0) 推荐(0) 编辑
摘要: mapPartition 是一个transformation 算子,主要针对需要建立连接的程序,比如数据写入数据库。 val kzc=spark.sparkContext.parallelize(List(("hive",8),("apache",8),("hive",30),("hadoop",1 阅读全文
posted @ 2021-01-11 10:28 bioamin 阅读(434) 评论(0) 推荐(0) 编辑