Skip to Content
数据库系统内幕
book

数据库系统内幕

by Alex Petrov
May 2020
Beginner to intermediate
319 pages
7h 3m
Chinese
China Machine Press
Content preview from 数据库系统内幕
54
|
第
3
章
•
数据记录的数据(以字节表示)
0 1 5 ...
+--------------+----------------+
| [byte] flags | [int] key_size |
+--------------+----------------+
5 9 .. + key_size
+------------------+--------------------+----------------------+
| [int] value_size | [bytes] key | [bytes] data_record |
+------------------+--------------------+----------------------+
你可能已经注意到了
偏移量
和
页
ID 之间的区别。由于页大小是固定的,并且页由页缓
存来管理(参见 5.1 节),我们只需要存储页 ID 即可,使用时再通过查找表将其转换成
真正的文件偏移量。
单元格偏移量
是页局部的概念,它是相对于页起始位置的偏移量:
因此,我们可以使用比较小的整数基数,从而使格式更紧凑。
变长数据
单元格中的键和值不一定是定长的,它们都可以是变长的,其位置可以通过偏移量
从定长的单元格头部计算得到。
要找到一个键,我们需要跳过单元格的头部,读取 key_size 个字节。类似地,
要找到一个值,我们可以跳过单元格的头部再加上 key_size 个字节,然后读取
value_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

解密金融数据

解密金融数据

Justin Pauley

Publisher Resources

ISBN: 9787111655169