zoukankan      html  css  js  c++  java
  • RDD的转换操作---RDD转换过程

    1) union(otherRDD)
    RDD-->UnionRDD
    2) groupByKey(numPartitions)
    RDD-->ShuffledRDD-->MapPartitionsRDD
    groupByKey() 只需要将 Key 相同的 records 聚合在一起,一个简单的 shuffle 过程就可以完成。
    3) reduceyByKey(func, numPartitions)
    reduceyByKey() 相当于传统的 MapReduce
    RDD-->MapPartitionsRDD-->ShuffledRDD-->MapPartitionsRDD
    4) distinct(numPartitions)
    RDD-->MappedRDD-->MapPartitionsRDD-->ShuffledRDD-->MapPartitionsRDD
    distinct() 功能是 deduplicate RDD 中的所有的重复数据。
    5) cogroup(otherRDD, numPartitions)
    RDD-->CogroupRDD-->MapPartitionsRDD
    与 groupByKey() 不同,cogroup() 要 aggregate 两个或两个以上的 RDD
    6) intersection(otherRDD)
    RDD-->MappedRDD-->CogroupRDD-->MappedValuesRDD-->FilteredRDD-->MappedRDD
    intersection() 功能是抽取出 RDD a 和 RDD b 中的公共数据。
    7) join(otherRDD, numPartitions)
    RDD-->CogroupRDD-->MappedValuesRDD-->FlatMappedValuesRDD
    join() 将两个 RDD[(K, V)] 按照 SQL 中的 join 方式聚合在一起。
    8) sortByKey(ascending, numPartitions)
    RDD-->ShuffledRDD-->MapPartitionsRDD
    sortByKey() 将 RDD[(K, V)] 中的 records 按 key 排序,ascending = true 表示升序,false 表示降序。
    9) cartesian(otherRDD)
    RDD-->CartesianRDD
    Cartesian 对两个 RDD 做笛卡尔集,生成的 CartesianRDD 中 partition 个数 = partitionNum(RDD a) * partitionNum(RDD b)。

  • 相关阅读:
    Mac下mysql出现错误:ERROR 1055 (42000)
    单表查询
    外键的变种 三种关系
    Java8中Lambda表达式详解
    Java中的比较器Comparable、Comparator
    Java创建线程的方法
    java日期格式化
    Docker容器如何修改hosts
    使用postman可以正常访问,但是在应用中返回415状态码
    使用tcpdump进行抓包
  • 原文地址:https://www.cnblogs.com/liutoutou/p/4063403.html
Copyright © 2011-2022 走看看