spark Reparation和Coalesce 区别
来源:互联网 发布:套路网络用语 编辑:程序博客网 时间:2024/06/07 17:42
val conf = new SparkConf().setMaster("local[*]").setAppName("colseTest")val sc = new SparkContext(conf)val rdd1 = sc.parallelize(Seq("1", "2", "3"))//如果重分区的数目大于原来的分区数,那么必须指定shuffle参数为tru//从源码可以看出,repartition()方法就是coalesce()方法shuffle为true的情况。val rdd2 = rdd1.coalesce(8, true)val rdd3 = rdd1.repartition(8)println("RDD2:" + rdd2.partitions.size)println("RDD3:" + rdd3.partitions.size)
打印结果:
RDD2:8RDD3:8
另外:
coalesce 在spark SQL function中有类似 oracle中nvl2点作用,如下解释
* For example, `coalesce(a, b, c)` will return a if a is not null,* or b if a is null and b is not null, or c if both a and b are null but c is not null.如 coalesce(null,null,4) 结果返回4
val df = Seq( ("1", "ll"), ("2", "ll"), (null, "lk")).toDF("id", "name")res.select(coalesce($"id", lit(9))).show() //动态SQL表达res.selectExpr("coalesce(id,'9')").show() //静态SQL表达
0 0
- spark Reparation和Coalesce 区别
- spark reparation和coalesce
- spark coalesce和repartition区别
- spark coalesce和repartition的区别
- 【Spark】Spark中repartition和coalesce的区别
- Spark 重分区函数:coalesce和repartition区别与实现,可以优化Spark程序性能
- Spark中repartition和coalesce的用法
- Spark中repartition和coalesce的用法
- spark算子(repartition和coalesce)
- Spark中repartition和coalesce的用法
- Spark Rdd coalesce()方法和repartition()
- Spark Rdd coalesce()方法和repartition()方法
- Spark RDD算子【二】coalesce 和 repartition
- Spark中repartition和coalesce的用法
- Spark RDD coalesce()方法和repartition()方法
- Spark重新分区—repartition和coalesce的用法
- Spark 重分区coalesce和repartition,合并小文件
- Spark函数讲解:coalesce
- Java新特性:函数式接口
- 解除 GPU 进程(减少显卡占用)
- HDU 5658 CA Loves Palindromic (回文树)
- Oracle中的序列(sequence、自增字段)
- 欢迎使用CSDN-markdown编辑器
- spark Reparation和Coalesce 区别
- spring注解的好处
- 1.开发模式接入(微信公众号开发实战)
- JMS基础
- Eclipse中关于maven配置文件setting的一点学习
- Cocos2d-x3.8.1网络编程(Socket)
- hrbust1073并查集应用
- Oracle数据导出与导入
- Java新特性:接口新特性