始める無料で始める

ブロードキャスト結合と通常の結合を比較する

通常の結合とブロードキャスト結合の2種類を作成しました。次に、Spark の最適化を使うことでどの程度パフォーマンスが向上するかを、マネージャーに示す必要があります。結果が有望であれば、必要に応じて Spark の設定をさらに調整する機会が与えられます。

DataFrame normal_dfbroadcast_df は利用可能です。

この演習はコースの一部です

PySpark でデータをクレンジングする

コースを見る

演習の手順

  • 通常の DataFrame で .count() を実行します。
  • ブロードキャストした DataFrame で .count() を実行します。
  • 両方の件数と処理時間を出力し、違いに注目して記録します。

実践的なインタラクティブ演習

このサンプルコードを完成させて、この演習に挑戦してみましょう。

start_time = time.time()
# Count the number of rows in the normal DataFrame
normal_count = ____
normal_duration = time.time() - start_time

start_time = time.time()
# Count the number of rows in the broadcast DataFrame
broadcast_count = ____
broadcast_duration = time.time() - start_time

# Print the counts and the duration of the tests
print("Normal count:\t\t%d\tduration: %f" % (normal_count, normal_duration))
print("Broadcast count:\t%d\tduration: %f" % (broadcast_count, broadcast_duration))
コードを編集して実行