3. B-Link Tree とは (history) A variant of B*-Tree (they call) actually.. a B+-tree? (data stored in leaf only) 1981 年 PHILIP.L. LEHMAN , S.BING YAO ” Efficient Locking for Concurrent Operations on B-Trees ” という論文で発表 当時,複数の プロセス で同時実効性を持つデータベースの構築が流行りだった ( らしい 論文の主眼は如何に効率のよく高い同時実効性を有する索引を構築するか.
4. B*-Tree an elegant(?) variant on B+-tree keep pages at least 2/3 full, guaranteed . The benefit over B+-trees is not large, a worst case reduction in page usage of 16.67% メモリが安く早くなりつつあるので、メモリスペースを節約するアルゴリズムから脱却すべきではないだろうか. 沢山のメモリを利用することで、レイテンシーが問題がなることがある.よりエレガントなアルゴリズムが必要になってくる. これは既に、バスのキャパシティを CPU スピードが追い越すことで起こっていることである. http://www.cise.ufl.edu/~jhammer/classes/b_star.html
5. B-Link-Tree (Key issue) No Read-Lock !! 複数のプロセスが同時に更新した場合に,少数のノードをロックする ロックの競合は稀である ロックの粒度が高く,開放が早い (non-2PL) ロック自体は update 時に Binary Lock (simple) デッドロックはないが,分散システムを考えるとよくないかも (? Additional Value to B*-Tree right-link , high key Breadth-first search (横型探索 ) が可能 . ノードにたどり着く Alternative way が存在する . Tree traversing operation search: top-down, left-to-right insert: bottom-up
13. 更新時の処理 (basis) x: 物理ページ (Logical ノードと呼んでいる ) Lock(x); // ページ X を更新する際にマーキング // もし既にロックされていたら wait() A <- get(x); // Disk からメモリに読み込む Modify data in A // メモリ内の A を更新 Put(A, x) // メモリから Disk の sync Unlock(x); // ロックを解除
15. Rightmost-link B-link-Tree は各ノードに Single Link Pointer を持つ. 各レベルが単方向リスト . 目的 目的のノードに到達するための Alternative way を提供する どのノードもたどり着く為の 2 つの Pointer を持つ Overflow Replaced by two New node. (usually, the two nodes Are on the same physical page) Essentially same as A single node until the Parent pointer is added.
16. Use high-key 74 74 63 HighKey HighKey Split 直後 ( 親へのリンクポインタが修正されていない ) 72 を探すケースを考えてみる. ここの中に High Key があるはずだが, Split されてない. この時, Link Pointer を辿る必要がある. この条件を High-Key と Search Key の比較によって行う. Search key が High key 以上ならポインタを辿る
17. An structure example of B-link-Tree Additional advantage: level-major order での取得が早い (Leaf をすべて取得する場合など )
18. Search Algorithm current = root; /* root の pointer を設定 */ A = get(current); /* ノードを memory に読み込む */ while (current is not a leaf) /* leaf に到達するまでループ */ current = scannode1(v, A); /* v をキーに memory bloak A を走査 */ /* リンクポインタを返す */ A = get(current); /* リンク先のノード読み込み */ / * now reached to leaves * / * leaf 内の線形探索 */ while ((t = scannode(v,A)) == link pointer of A) current = t; A = get(current); // 値 v を持つ leaf が見つかったか ? if (v is in A) return(success); else return(failure); Simple! Only trick is to have scannode know about high-keys and right-links. Right-link か Child-link かは 問わない
20. Insert(1) initialize stack; /* to remember ancestors */ current = root; A = get(current); /* scan down the tree */ while (current is not a leaf) { t = current; current = scannode(v,A); if (current not link pointer in A) push t; /* remember node at the level */ A = get(current); } /* reached to leaf */ lock(current); A = get(current); move_right(); /* if required, move right and lock the neighbor */
21. // current node の update. // Split Node // for locking.. Remember the oldnode and the parent. // lock parent, oldnode, and the next-sibling.
22. A B C D E F G H splited A Bottom-up Stack (right-most-link) B E Leaf Found G
23. D E G H Leaf A Bottom-up Stack (right-most-link) B E If need to Split Flush Flush B Lock Flush Un Lock Finish! G I ’ G’ I ’ G’ E E
24. P A C Leaf Insert algorithm(Write lock / no read lock) B ’ A ’ P Bottom-up Stack Insert(Split) A ’ Flush Lock A B ’ Flush
25. Delete Too simple (leaf のエントリが K 以下なら,この論文は primary index を前提 ) Just remove keys from a leaf node. (never do deletion from internal nodes) Delete が続くとノードのエントリが k エントリ以下に なることがある. (starvation?)
26. problems Livelock multiprocesser system, where one process runs indenfinitely ( 特に processing speed に差がある時 ) Following link pointer が別プロセスで作られると極端に遅くなることがある