Skip to Content
数据库系统内幕
book

数据库系统内幕

by Alex Petrov
May 2020
Beginner to intermediate
319 pages
7h 3m
Chinese
China Machine Press
Content preview from 数据库系统内幕
60
|
第
4
章
齐是否正确,在写入期间,我们可以将魔数 50 41 47 45(“ PAGE”(页)的十六进制
表示)放入头部。在读取过程中,我们通过把从头部读取的四个字节与预期的字节序列
进行比较来校验页。
4.1.2
同级指针
一些实现存储了前序和后继指针,指向左、右同级页。这些指针有助于定位相邻节点,
而不必返回父节点。这种方法为分裂和合并操作增加了一些复杂度,因为同级偏移量也
必须同时更新。例如,当一个非最右边的节点被拆分时,其同级右节点的后向指针(之
前指向被拆分的节点)必须被重新绑定以指向新创建的节点。
在图 4-1 中可以看到,要定位一个同级节点,除非有指针指向同级节点,否则我们必须
通过父节点才能定位。这个操作可能一直上升到根节点,因为直接父节点只能帮助找到
它自己的子一级节点。如果在页头中存储直接连接同级节点的指针,我们便可以方便地
通过这些指针来定位同一层上的前序或后继节点。
a) b)
图
4-1
:通过跟随父节点(
a
)或同级指针(
b
)来定位同级节点
存储同级指针的缺点之一是在分裂和合并期间必须更新它们。由于更新必须在同级节点
中进行,而不是在分裂 / 合并节点中进行,所以可能需要额外的锁。我们将在 5.3.8 节中
讨论同级指针在并发 B 树的实现中是如何发挥作用的。
4.1.3
最右指针
B 树分隔键有严格的不变式:它用于将树拆分为子树并对这些子树进行遍历,因此指向
子页的指针总是比键的个数指针多一个。这就是 2.3.5 节中提到的 +1 的来源。
在 2.3.2 节中,我们描述了分隔键不变式。在许多实现中,节点看起来更像图 ...
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