Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
fs2で始める関数型ストリーミング処理入門
Search
Kazunari Mori
October 08, 2016
Programming
750
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
fs2で始める関数型ストリーミング処理入門
関数型ストリーミング処理に出会ったときにこわくない程度の感覚を掴むために
Kazunari Mori
October 08, 2016
Other Decks in Programming
See All in Programming
JAWS-UG 東京支部が始める、JAWS-UG支部コラボ / JAWS-UG lunchtime LT Collaboration
y0hgi
0
280
GemmaをJevのように使ってみる / Use Gemma like Jev
kishida
5
800
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
750
ChromeでローカルLLM
ryu1013
0
140
Kotlinの15年とServer-Side Kotlin
n_takehata
1
150
[2026-10-14](C)Re:ゼロから始める異世界生活〜始まりの終わりと終わりの始まり〜
tosite
0
100
AmebaブログはKMPから卒業します
kmars0605
0
200
全ての永続トークンを、生まれる前に消し去りたい!
sylph01
2
970
IBM Bob Dojo #1 仕様駆動開発入門
oniak3ibm
PRO
0
400
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
690
現場と育てるRailsモデリング 〜Spreadsheetから始めたモデル設計〜
siroemk
2
630
TechTown - Creating Composable Callables in Contemporary C++
rollbear
0
130
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
41
2.8k
The untapped power of vector embeddings
frankvandijk
2
1.9k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.5k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
570
HDC tutorial
michielstock
2
960
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
360
What the history of the web can teach us about the future of AI
inesmontani
PRO
2
740
The Cost Of JavaScript in 2023
addyosmani
55
10k
Automating Front-end Workflow
addyosmani
1369
210k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
270
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.5k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Transcript
None
None
None
None
None
• 昨今のバズワード「ビッグデータ」とも戦える!!
• データは次々流れてくる • 自分のところにデータが来たら、自分の やるべき処理を実行 • 処理済みデータは次の担当の元へ • def work(p:
Pet): Pet = if (p.fallen) raise(p) else p • 1データを処理する関数を作るだけ! • (12本ためて箱に詰める、なども。)
None
fs2 Stream class Stream F _ O • O •
F _ • fs2 util Catchable F fs2 Task Catchable F Task F O
• Stream ファイル DB Web ファイル DB Web fs2.Stream
• Stream List A def O2 O O2 Stream F
O2 def O2 O Stream F O2 Stream F O2 def F2 O2 Stream F O Stream F2 O2 Stream F2 O2 Stream Stream Task java sql Connection • Stream Stream Stream
None
Stream F Byte Stream F String • ascii文字しか無いならば、すべて1文字1バイト。 • でも、半角カタカナはutf-8では3バイト・・・
• こういうときにChunkという概念が便利。 trait Chunk[+A] • ChunkはA型のデータの幾つかの塊というイメージ
• Stream O2 Chunk Chunk O2 • Chunk A Vector
A Vector A Chunk Chunk A • 以下の点には注意が必要 • Chunkにはいくつデータが入っているのかわからない。 • どこかChunkに入ったデータは、次のChunkには入らない。 • Chunkのうち使いきれなかった分をキャッシュして、 次のChunkの先頭にくっつける処理が必要になる事が多い。 • Pipe型、Handle型やPull型を参照。 • fs2.textにutf8Decodeなどがあるので、ソースを読めば・・・。
Stream def f[F[_], A]: fs2.Pipe[F, A, (A, A)] = {
s => for { a <- s.take(1) b <- s.tail.take(1) c <- f(s.tail).cons1((a, b)) } yield c }
None
• 例えば、ソート処理。 データの中で最小の値をはじめに持ってくる。 データをすべて見ないと最小の値がわからない。 ⇒ すべてのデータを見るまで値をキャッシュする? • 無限に終わりが来ないストリームも簡単に作成可能。
• ランダムアクセスが必要な処理全般が不可能。 一度使用した値は意図的にキャッシュしない限りは残らない。 • Lengthを取得するだけですべての値の走査が必須
None