1. 程式人生 > >Spark RangeDependency 區間依賴關係

Spark RangeDependency 區間依賴關係

Spark RangeDependency 區間依賴關係

  • Represents a one-to-one dependency between ranges of partitions in the parent and child RDDs.

更多資源

youtub視訊演示

輸入資料

c.txt

a bc
a  

a.txt

a b
c a

處理程式scala

package com.opensource.bigdata.spark.local.rdd.operation.dependency.narrow.n_02_RangeDependency

import com.opensource.bigdata.spark.local.rdd.operation.base.BaseScalaSparkContext

object Run3 extends BaseScalaSparkContext{

  def main(args: Array[String]): Unit = {
    val sc = pre()
    val rdd1 = sc.textFile("/opt/data/2/c.txt",2)
    val rdd2 = sc.textFile("/opt/data/2/a.txt",2)
    val rdd3 = rdd1.union(rdd2)

    println(rdd3.collect().mkString("\n"))

    sc.stop()
  }

}

資料處理圖

RangeDependency依賴關係圖