Essential PySpark Chap1-1
業務で使用するためこの本を読みながらコードとか試していきます。 本のリンクはこちら
https://www.amazon.com/Essential-PySpark-Scalable-Data-Analytics/dp/1800568878
Distributed Computing
Data Parallel processing
基本的な考え方はデータが分散して保管されている各ストレージにコードを持っていて処理を実行する。この考え方をMapReduceという。
- MapReduceを利用した並列処理は大きく三段階ある
Distributed Computing with Apache Spark
Apache Sparkでできること
RDDがデータを保存する基本的な考え方(Resilient Distributed Dataset)
- 1つのRDDが複数のpartitionに分けられる
- partitionはバラバラに複数のマシン上に保存されている
Higher-order functionsを使うことでRDDに処理を加えることができる。
# テキストファイルの中身string単位でRDDに保存する lines = sc.textFile("/databricks-datasets/README.md") # flatMapによって中のlambda関数を各stringに適用 words = lines.flatMap(lambda s: s.split(" ")) # ('文字', 1)という形のタプルに変換 word_tuples = words.map(lambda s: (s, 1))
Apache Spark cluster architecture
- Driver データの準備、executorの実行計画、executorが事故った時の対処など心臓みたいに大事
- Executor データを処理する所。労働者。
- Cluster Manager リソースの提供、タスク進捗管理、executorの監視など。中間管理職。