zoukankan      html  css  js  c++  java
  • 4.3 高效的算子、分区算子

    groupByKey和reduceByKey

    1.groupByKey是没有combine过程
        combineByKeyWithClassTag[CompactBuffer[V]](createCombiner, mergeValue, mergeCombiners, partitioner, mapSideCombine = false)
    2.reduceByKey有combine过程
        combineByKeyWithClassTag[V]((v: V) => v, func, func, partitioner) //mapSideCombine默认是true
        1、如果v是数字运算,如wordcount减少网络传输次数
        2、如果v是List[],对v进行收集,因为只收集v所以可以节省空间

    注意:reduceByKey不能改变 v 的返回值类型

              两者都可重新指定分区

    repartition 和 coalesce

    rdd.repartition(n)调用的就是coalesce,始终进行shuffle操作。 
    如果是减少分区,推荐使用coalesce,可以指定是否进行shuffle操作,默认是false即不分区
    通过coalesce增加分区时,必须指定shuffle为true,否则分区数不变。
    渐变 --> 突变
  • 相关阅读:
    Kettle学习(2)
    kettle学习(1)
    Quartz在Spring中的使用
    JVM垃圾收集简介
    快速排序

    20190827最新论文
    GNN
    Multimodal Machine Learning
    Wasserstein距离 及两多元高斯分布间的W距离
  • 原文地址:https://www.cnblogs.com/lybpy/p/9774863.html
Copyright © 2011-2022 走看看