Skip to Content
数据库系统内幕
book

数据库系统内幕

by Alex Petrov
May 2020
Beginner to intermediate
319 pages
7h 3m
Chinese
China Machine Press
Content preview from 数据库系统内幕
138
|
第
7
章
数据文件
图
7-11
:
Bitcask
中
keydir
和数据文件之间的映射(实线表示从键到与其关联的最新值的指针,
遮蔽的键值对以浅灰色显示)
7.4.2 WiscKey
范围查询对于许多应用程序都很重要,如果有一种存储结构既有无序存储的写入和空间
优势,同时还支持执行范围扫描就好了。
WiscKey[LU16] 通过在 LSM 树中保存键排序并在称为
vLog
(值日志)的无序仅追加文
件中保存数据记录,来将排序与垃圾收集解耦。这种方法可以解决讨论 Bitcask 时提到
的两个问题:需要将所有键保留在内存中,以及需要在启动时重新构建哈希表。
图 7-12 展示了 WiscKey 的关键组件,以及键和日志文件之间的映射。vLog 文件保存无
序数据记录。键存储在排序的 LSM 树中,指向日志文件中最新的数据记录。
由于键通常比与其相关联的数据记录小得多,所以压实它们的效率要高得多。这种方法对
于更新和删除较少的场景特别有用,在这种情况下,垃圾收集不会释放太多的磁盘空间。
这里的主要挑战是,由于 vLog 数据是未排序的,所以范围扫描需要随机 I/O。WiscKey
在范围扫描时使用固态硬盘的内部并行性来并行预取数据块,以减少随机 I/O 的开销。
在数据块传输方面,其成本仍然很高:在范围扫描期间,要获取一条的数据记录,必须
读取该数据记录所在的整个页。
在压实过程中,vLog 文件的内容被顺序读取,并在合并后写入新的位置。指针(键
LSM 树中的值)被更新以指向这些新位置。为了避免扫描整个 vLog ...
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