CMU15-445/645学习笔记
CMU15-445/645
src/common.
channel.h
- 实际上是一个线程安全队列.
rid.h
- Record Identifier = page_id_ << 32 | slot_num_
rwlatch.h
- 读写锁(std::shared_mutex)
src/type.
abstract_pool.h
- 抽象内存池接口
type_id.h
- type枚举
1
enum TypeId { INVALID = 0, BOOLEAN, TINYINT, SMALLINT, INTEGER, BIGINT, DECIMAL, VARCHAR, TIMESTAMP };
type.h
- 类型基类.
- 定义了类型比较,运算,序列化,转换类型等虚接口.
boolean_type.h
- 实例化boolean类型比较,运算,序列化,转换类型等接口.
numeraic_type.h
- number value的基类,可以是整数和小数.必须提供运算操作.
integer_parent_type.h
- 为整数提供具有鲁棒性的四则运算.
tinyint_type.h,smallint_type.h,bigint_type.hinteger_type.h
- integer_parent_type的子类,为整数提供了比较,运算,序列化,转换类型等接口.
timestamp_type.h
- 为timestamp类型提供比较等接口.
decimal_type.h
- 为小数提供类型比较,运算,序列化,转换类型等接口.
value.h
- 实际管理数据内容的地方.
- 存储着type和数据内容.
- value比较,运算,序列化,转换类型等操作都是调用type提供的虚接口.
1
Type::GetInstance(type_id_)->
value_factory.h
- value工厂类,方便构造value.
src/catalog.
column.h
- 记录column的name,type,fixed_length,variable_length,offset.
schema.h
- 存储着std::vector
columns. 记录数据库tuple的元信息.
catalog.h
- 处理表创建、表查找、索引创建和索引查找.
src/storage.
table/tuple.h
- 存储RID rid_{},std::vector
data_. - 定义了tuple的存储格式,前面部分存储inline数据,然后存储uninline数据.
- 可以通过schema和column_idx得到数据.
table/table_heap.h
- BufferPoolManager *bpm_,page_id_t first_page_id_,page_id_t last_page_id_.
- 通过BufferPoolManager操作table,提供了一系列操作table中tuple的接口.
table/table_iterator.h
- table中page的迭代器.
disk/disk_manager.h
- 封装了写文件操作.
- file_name_,log_name_.
- 通过page_id计算offset,然后往文件读写内容.
disk/disk_scheduler.h
- 内部保存DiskManager.
- Channel<std::optional
> request_queue_,使用channel依次处理请求.
page/page.h
- 数据库存储的基本单元.提供了对真实数据页的一层包装.
- data_,page_id_,pin_count_,is_dirty_,rwlatch_.
page/page_guard.h
- 为page提供RAII.
page/table_page.h
- 一个page是怎么存储tuple的.
page/extendible_htable_header_page.h
- page_id_t directory_page_ids_[512],uint32_t max_depth_;
- 固定大小,可以认为是第一层hash,有一个常量max_depth_.
page/extendible_htable_directory_page.h
- uint32_t max_depth_,uint32_t global_depth_,uint8_t local_depths_[512],page_id_t bucket_page_ids_[512];
- 不固定大小,可以认为是第二层hash,有一个变量depth.
page/extendible_htable_bucket_page.h
- uint32_t size_,uint32_t max_size_,MappingType array_[HTableBucketArraySize(sizeof(MappingType))];
- 保存实际value的地方.
index/index.h
- std::unique_ptr
metadata_; - IndexMetadata
1
2
3
4
5
6
7
8
9
10/** The name of the index */
std::string name_;
/** The name of the table on which the index is created */
std::string table_name_;
/** The mapping relation between key schema and tuple schema */
const std::vector<uint32_t> key_attrs_;
/** The schema of the indexed key */
std::shared_ptr<Schema> key_schema_;
/** Is primary key? */
bool is_primary_key_; - 索引的抽象基类.
index/extendible_hash_table_index.h
- class ExtendibleHashTableIndex : public Index;
- 根据extendible_hash_table构建的索引表.
src/buffer.
lru_k_replacer.h
- 实现了lru_k替换算法.
buffer_pool_manager.h
- 缓存池.通过pool_size,disk_manager(file_name_),replacer_k初始化.
src/container.
disk/hash/disk_extendible_hash_table.h
- std::string index_name_;BufferPoolManager *bpm_;KC cmp_;HashFunction
hash_fn_;uint32_t header_max_depth_;uint32_t directory_max_depth_;uint32_t bucket_max_size_;page_id_t header_page_id_; - 结合BufferPoolManager,extendible_htable_header_page,extendible_htable_directory_page,extendible_htable_bucket_page,建立一个可动态扩展/收缩的HashTable,对外提供增、删、查的的服务接口.
execution
executors/abstract_executor.h
- 执行器的抽象基类.