Skip to Content
スパーク定義ガイド
book

スパーク定義ガイド

by Bill Chambers, Matei Zaharia
March 2025
Intermediate to advanced
606 pages
9h
Japanese
O'Reilly Media, Inc.
Content preview from スパーク定義ガイド

第16章 Sparkアプリケーションの開発 Sparkアプリケーションを開発する

この作品はAIを使って翻訳されている。ご意見、ご感想をお待ちしている:translation-feedback@oreilly.com

第15章では、 、Sparkがクラスタ上でコードを実行する方法について学んだ。ここでは、スタンドアロンのSparkアプリケーションを開発し、それをクラスタ上にデプロイするのがいかに簡単かを紹介する。 ビルドツールや単体テストのセットアップなど、アプリケーションをどのように構成するかの簡単なヒントを共有するシンプルなテンプレートを使ってこれを行う。このテンプレートは、この本のコード・リポジトリで入手できる。ゼロからアプリケーションを書くのは難しくないので、このテンプレートは本当に必要ではないが、役に立つ。さっそく最初のアプリケーションを作ってみよう。

Sparkアプリケーションを書く

Spark アプリケーションは、Sparkクラスタとあなたのコードという2つのものの組み合わせである。この場合、クラスタはローカルモードで、アプリケーションは定義済みのものになる。それぞれの言語でのアプリケーションを見ていこう。

Scalaベースのシンプルなアプリ

ScalaはSparkの "自然言語 "であり、当然アプリケーションを書くのに適している。Scalaアプリケーションを書くのと何ら変わりはない。

チップ

Scala 、バックグラウンドによっては敷居が高く感じるかもしれないが、Sparkを少しでも理解するためであれば学ぶ価値はある。基本的なことから始めれば、Scalaですぐに生産的になれることがわかるだろう。Scalaを使うことで、多くの扉が開かれる。少し練習すれば、Sparkのコードベースをコードレベルでトレースすることは難しくない。

sbtまたはApache Mavenという2つのJavaバーチャルマシン(JVM)ベースのビルドツールを使ってアプリケーションをビルドすることができる。どのビルド・ツールにも言えることだが、それぞれに癖がある。sbtはsbtのWebサイトでダウンロード、インストール、学習できる。MavenもそれぞれのWebサイトからインストールできる。

Scalaアプリケーションのsbtビルドを構成するには、build.sbtファイルを指定してパッケージ情報を管理する。build.sbtファイルの中には、いくつかの重要な項目がある:

  • プロジェクトのメタデータ(パッケージ名、パッケージのバージョン情報など)

  • 依存関係を解決する場所

  • ライブラリに必要な依存関係

指定できるオプションは他にもたくさんあるが、本書の範囲を超えている(これに関する情報はウェブやsbtのドキュメントで発見できる)。また、このテーマに関する本もいくつか出ているので、自明なこと以外であればすぐに参考になる。Scalaのbuilt.sbtファイルのサンプルはこんな感じだ(テンプレートにも含まれている)。Sparkのバージョンだけでなく、Scalaのバージョンも指定しなければならない:

name := "example" organization := "com.databricks" version := "0.1-SNAPSHOT" scalaVersion := "2.11.8" // Spark Information val sparkVersion = "2.2.0" // allows us to include spark packages ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

高性能Spark

高性能Spark

Holden Karau, Rachel Warren
生成AIの可視化

生成AIの可視化

Priyanka Vergadia, Valliappa Lakshmanan
ソフトウェア工学の基礎

ソフトウェア工学の基礎

Nathaniel Schutta, Dan Vega

Publisher Resources

ISBN: 9798341627567