Skip to Content
数据库系统内幕
book

数据库系统内幕

by Alex Petrov
May 2020
Beginner to intermediate
319 pages
7h 3m
Chinese
China Machine Press
Content preview from 数据库系统内幕
文件格式
53
空间回收:通过对页进行碎片整理和重写,就可以回收空间。
动态布局:从页外部,只能通过槽 ID 来引用槽,而确切的位置是由页内部决定的。
3.6
单元格布局
有了标志位、枚举值和原始类型,我们就可以开始设计单元格布局了。之后将单元格组
合成页,再将页组合成树。单元格分为键单元格和键值单元格两种。键单元格包含一个
分隔键和一个指针,该指针指向两个相邻键
之间
的页。键值单元格包含键和相关联的数
据记录。
我们假定单个页内所有单元格是统一的(例如,要么全是键单元格,要么全是键值单元格;
类似地,要么全都包含定长数据,要么全都包含变长数据,但不能是二者的混合)。这样一
来,单元格的元数据只要在每个页上保存一份即可,而不用让每个单元格都保存一份。
构成一个键单元格需要以下信息:
单元格类型(可以从页的元数据推断出来)
键的长度
该单元格指向的子页的 ID
键的数据(以字节表示)
一个变长键的单元格布局可能看起来像这样(对于定长键,不用在每个单元格上保存键
的长度):
0 4 8
+----------------+---------------+-------------+
| [int] key_size | [int] page_id | [bytes] key |
+----------------+---------------+-------------+
我们将定长的字段放在一起,之后是 key_size 个字节。严格来说这不是必需的,但这
可以简化偏移量的计算,因为所有定长字段都可以通过静态的、预先计算好的偏移量来 ...
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

流畅的Python

流畅的Python

Luciano Ramalho

Publisher Resources

ISBN: 9787111655169