zoukankan      html  css  js  c++  java
  • reduceByKey、groupByKey和combineByKeyWithClassTag

    groupByKey

    • 没有 mergeValue 操作,即没有map端combine操作,增加网络传输次数
    • 生成CompactBuffer对象,占用资源
    • 可重新指定分区

    groupBy

    • 增加传输次数
    • 保存生成CompactBuffer对象并保存key占用资源

    reduceByKey

    • 有 mergeValue操作,即map端有预聚合,减少网络传输次数
    • 不能改变v的返回值类型
    • 可重新指定分区

    combineByKeyWithClassTag  //最根本方法

    def combineByKeyWithClassTag[C](
          createCombiner: V => C,  //map端,改变 v 的返回值类型
          mergeValue: (C, V) => C,  //map端,预聚合
          mergeCombiners: (C, C) => C,  //reduce端,聚合
          partitioner: Partitioner,  //分区对象
          mapSideCombine: Boolean = true,  //是否开启map端聚合,默认开启
          serializer: Serializer = null)
          
    def combineByKeyWithClassTag[C](
          createCombiner: V => C,
          mergeValue: (C, V) => C,
          mergeCombiners: (C, C) => C,
          numPartitions: Int)
    
    def combineByKeyWithClassTag[C](
          createCombiner: V => C,
          mergeValue: (C, V) => C,
          mergeCombiners: (C, C) => C)
    aggregateByKey
    def aggregateByKey[U: ClassTag](zeroValue: U, partitioner: Partitioner)(seqOp: (U, V) => U,
          combOp: (U, U) => U)
          
    def aggregateByKey[U: ClassTag](zeroValue: U, numPartitions: Int)(seqOp: (U, V) => U,
          combOp: (U, U) => U)
    
    def aggregateByKey[U: ClassTag](zeroValue: U)(seqOp: (U, V) => U,
          combOp: (U, U) => U)
    渐变 --> 突变
  • 相关阅读:
    原生js 实现 map
    前端安全学习
    前端性能优化
    前端的跨域请求方法使用场景及各自的局限性
    7-7 12-24小时制(15 分)
    7-4 BCD解密(10 分)
    7-2 然后是几点(15 分)
    厘米换算英尺英寸
    鸡兔同笼
    数组:经典计数
  • 原文地址:https://www.cnblogs.com/lybpy/p/9788472.html
Copyright © 2011-2022 走看看