Two years ago, Spotify introduced Scio, an open-source Scala framework to develop data pipelines and deploy them on Google Dataflow. In this talk, we will discuss the evolution of Scio, and share the highlights of running Scio in production for two years. We will showcase several interesting data processing workflows ran at Spotify, what we learned from running them in production, and how we leveraged that knowledge to make Scio faster, and safer and easier to use.
Two years ago, Spotify introduced Scio, an open-source Scala framework to develop data pipelines and deploy them on Google Dataflow. In this talk, we will discuss the evolution of Scio, and share the highlights of running Scio in production for two years. We will showcase several interesting data processing workflows ran at Spotify, what we learned from running them in production, and how we leveraged that knowledge to make Scio faster, and safer and easier to use.
8. 2011/4/27 アルゴリズムとデータ構造 11 8
部分順序付き木( partially ordered
tree )
? 最大値(最小値)を求めるのに適したデータ構造
? 以下の制約を満たす木(2分木)
? 子は親より常に小さいか等しい(大きいか等しい)
? 子要素間の大小関係に制約は無い
25
15 23
13 8 9
5 12 1
根は常に最
大値となる
19
20
a b
c d
b
a c
d
b>a, c>d の場合の
木の組み替え
11. 2011/4/27 アルゴリズムとデータ構造 11 11
ヒープの組み替え
? 入力:配列 A ,インデックス i
? left_child(i) と right_child(i) はそれぞれヒープ
? A[i] は,子より小さいかもしれない
? ヒープ条件が満たされていないかもしれない
def max_heapify_down(A, i, heap_size):
l = left_child(i)
r = right_child(i)
if l < heap_size and A[l] > A[i]:
largest = l
else:
largest = i
if r < heap_size and A[r] > A[largest]:
largest = r
if largest != i:
swap(A, i, largest)
max_heapify_down(A, largest, heap_size)
heap_size はヒープ
の要素数を保持する
ものとする
19. 2011/4/27 アルゴリズムとデータ構造 11 19
リストのマージ
def merge(n, m):
dummy = node()
tail = dummy
while n != None and m != None:
if n.elem <= m.elem:
tail.next = n; tail = n
n = n.next
else:
tail.next = m; tail = m
m = m.next
if n != None: tail.next = n
else: tail.next = m
return dummy.next
3 6 7
n
1 5 8 12
m
tail, dummy
dummy
1
tail
5 8 12
m
dummy
1
tail
3 6 7
n
5 8 12
m
3 6 7
n
20. 2011/4/27 アルゴリズムとデータ構造 11 20
マージソート(リスト版)の実現
? リストを 2 つに分割し,それぞれのリストに対して,再帰的にマー
ジソートを行い,それらを再びマージする.
def merge_sort(n):
if n != None and n.next != None:
p = n; q = n.next
while q != None and q.next != None:
p = p.next; q = q.next.next
m = p.next
p.next = None
return merge(merge_sort(n), merge_sort(m))
else:
return n
リストの中央を見つける巧妙
なテクニック.
p がリストの末尾に到達した
時点で, q は半分ほど進んで
いる