Skip to Content
数据库系统内幕
book

数据库系统内幕

by Alex Petrov
May 2020
Beginner to intermediate
319 pages
7h 3m
Chinese
China Machine Press
Content preview from 数据库系统内幕
B
树的实现
|
61
≤
≤ ≥
图
4-2
:最右指针
这个额外的指针可以存储在头部,例如,其在 SQLite 中的具体实现便是如此。
如果最右侧的子树被拆分,并且新的单元格被追加到其父节点上,则必须对最右侧的子
指针重新赋值。如图 4-3 所示,拆分后追加到父节点的单元格(灰色)包含被提升的键,
并指向拆分节点。此时分配了一个指向新节点的指针来替代原先的最右指针。SQLite 描
述并实现了类似的方法。
注 1
拆分前 拆分后
图
4-3
:节点拆分期间最右指针的更新(被提升的键用灰色表示)
4.1.4
节点的高键
我们可以采用一种稍微不同的方法,将单元格中的最右指针与节点的
高键
(high key)存
储在一起。节点的高键表示当前节点下的子树中可能存在的最高的键。PostgreSQL 使用
了这种方法,称为 Blink 树(有关此方法隐含的并发含义,请参见 5.3.8 节 )。
B 树有 N 个 键 (用 K
i
表示)和 N+1 个指针(用 P
i
表示)。在每个子树中,键以 K
i-1
≤
K
s
<K
i
为
界。K
0
= - ∞是隐含的,并不在节点中表示。
Blink 树向每个节点添加一个 K
N+1
键。它指定了指针 P
N
指向的子树中所存储的键的上
注 1:你可以在项目仓库(
https://databass.dev/links/15
)中的 balance_deeper 函数中找到该算法。
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

解密金融数据

解密金融数据

Justin Pauley

Publisher Resources

ISBN: 9787111655169