Skip to Content
数据库系统内幕
book

数据库系统内幕

by Alex Petrov
May 2020
Beginner to intermediate
319 pages
7h 3m
Chinese
China Machine Press
Content preview from 数据库系统内幕
日志结构存储
|
137
顺序的方式有所不同:B 树的页是原地更新的,FD 树的有序段是通过合并两个有序段来
创建的,而 SSTable 通过在内存中缓冲和排序数据记录而创建。
在本节中,我们将讨论按随机顺序存储数据记录的结构。无序存储一般不需要单独的日
志,并且允许我们按插入顺序存储数据记录以减少写入的开销。
7.4.1 Bitcask
Bitcask 是 Riak 中使用的存储引擎之一,它是一个无序的日志结构存储引擎 [SHEEHY10b]。
与此前讨论的日志结构存储实现不同,它不使用 memtable 进行缓冲,而是将数据记录
直接存储在日志文件中。
为了使值可被搜索,Bitcask 使用一种名为
keydir
(键目录)的数据结构,它保存与键相
应的
最新
数据记录的引用。旧的数据记录可能仍然在磁盘中,但不会被 keydir 引用,并
且它们会在压实过程中被垃圾收集。keydir 被实现为内存中的哈希表,并且在启动期间
必须从日志文件中重建。
在一次
写入
中,键和数据记录被顺序地追加到日志文件中,并且会在 keydir 中放入指向
新写入的数据记录位置的指针。
读取时会查看 keydir 以定位要搜索的键,并跟随指向对应日志文件的指针以定位数据记
录。由于在任何给定时刻都只能有一个值与 keydir 中的键相关联,所以点查询不必合并
来自多个数据源的数据。
图 7-11 展示了 Bitcask 的数据文件中键和记录之间的映射。日志文件保存数据记录,而
keydir 则指向与每个键相关联的最新
活动
数据记录。数据文件中被遮蔽的记录 ...
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