close

Apache Spark 以 RDD(彈性分布式數據集)形式轉換數據。RDD 不可變而且輸入是確定性的。RDD 並不是真正的數據集合,而只是從其他數據生成數據的方法,為什麼RDD設計為不可變?大致原因如下:

•高並發:不可變是實現高並發的基礎,多線程更新需要精細的並發控制,在分布式環境很難做到;•快速重建:分區失敗後可快速重新構建RDD(依靠血緣);如果可變血緣關係很難追蹤;•數據共享:跨進程共享不可變數據是絕對安全的,有助於數據的移動;

由於RDD不可變,因此Spark比較適合進行分析 OLAP 型操作,而不是像數據庫或鍵值存儲那樣的實時 OLTP 事務。

最後貼一段論文Resilient Distributed Datasets: A Fault-Tolerant Abstraction for In-Memory Cluster Computing[1]關於RDD的描述

Although individual RDDs are immutable, it is possible to imple- ment mutable state by having multiple RDDs to represent multiple ver- sions of a dataset. We made RDDs immutable to make it easier to de- scribe lineage graphs, but it would have been equivalent to have our abstraction be versioned datasets and track versions in lineage graphs.

翻譯如下

儘管單個 RDD 是不可變的,但可以通過使用多個 RDD 來表示數據集的多個版本來實現可變狀態。我們使 RDD 不可變,以便更容易地描述血緣關係,等同於將我們的抽象化為版本化數據集並跟蹤譜系圖中的版本。

Ref

https://medium.com/nerd-for-tech/why-is-rdd-immutable-7503ddcbbd24

https://www.linkedin.com/pulse/why-apache-spark-rdd-immutable-sudhanshu-sharma

https://www.edureka.co/community/11986/don-understand-the-reason-behind-spark-rdd-being-immutable

引用鏈接

[1]論文Resilient Distributed Datasets: A Fault-Tolerant Abstraction for In-Memory Cluster Computing:https://www.usenix.org/system/files/conference/nsdi12/nsdi12-final138.pdf

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 鑽石舞台 的頭像
    鑽石舞台

    鑽石舞台

    鑽石舞台 發表在 痞客邦 留言(0) 人氣()