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 スパーク定義ガイド

第21章. 構造化ストリーミングの基本

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

ストリーム処理の概要を簡単に説明したところで、次は構造化ストリーミングに飛び込もう。この章では、構造化ストリーミングの重要な概念のいくつかを説明し、それをいくつかのコード例で応用することで、このシステムがいかに使いやすいかを示す。

構造化ストリーミングの基本

Structured Streamingは、第20章の最後で説明したように、Spark SQLエンジン上に構築されたストリーム処理フレームワークである。別のAPIを導入するのではなく、Structured StreamingはSparkの既存の構造化API(DataFrames、Datasets、SQL)を使用する。つまり、Sparkでおなじみの演算子はすべてサポートされている。ユーザは、静的データに対するバッチ計算と同じようにストリーミング計算を表現する。これを指定し、ストリーミング先を指定すると、Structured Streamingエンジンは、新しいデータがシステムに到着するたびに、クエリをインクリメンタルかつ継続的に実行する。これらの計算のための論理命令は、クエリの最適化やコード生成など、本書のパートIIで説明したのと同じCatalystエンジンを使って実行される。コアとなる構造化処理エンジンの他にも、Structured Streamingにはストリーミングに特化した多くの機能が含まれている。例えば、Structured Streamingは、エンド・ツー・エンド、ジャスト・ワンス処理、およびチェックポイントとライト・アヘッド・ログによるフォールト・トレランスを保証する。

構造化ストリーミングの主な考え方は、データのストリームを テーブルとして扱い、そこに継続的にデータを追加することである。ジョブは定期的に新しい入力データをチェックし、それを処理し、必要であればデータストアにある内部状態を更新し、結果を更新する。このAPIの基本は、バッチ処理やストリーム処理を行う際にクエリのコードを変更する必要がないことである。内部的には、Structured Streamingは自動的にクエリを "インクリメント "する方法、つまり新しいデータが到着するたびにその結果を効率的に更新する方法を見つけ出し、フォールトトレラントな方法で実行する。

image
図21-1. 構造化ストリーミング入力

最も簡単に言えば、構造化ストリーミングは「DataFrameをストリーミングする」ものだ。このため、ストリーミング・アプリケーションを使い始めるのはとても簡単だ。おそらくそのためのコードはすでに持っていることだろう!しかし、構造化ストリーミングで実行できるクエリの種類にはいくつかの制限があり、またイベントタイムやアウトオブオーダーデータなど、ストリーミング特有の新しい概念についても考えなければならない。これらについては、この章と次の章で説明する。

最後に、 Sparkの他の部分とインテグレーションすることで、Structured Streamingはユーザが継続的アプリケーションと呼ぶものを構築することを可能にする。コンティニュアスアプリケーションとは、ストリーミングジョブ、バッチジョブ、ストリーミングデータとオフラインデータの結合、インタラクティブなアドホッククエリなど、様々なツールを組み合わせることでリアルタイムにデータに反応する ...

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