MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
Public 成员函数 | 静态 Public 成员函数 | Protected 属性 | 所有成员列表
bplus_tree::LogEntryHandler类 参考abstract

B+树日志处理辅助类 更多...

#include <bplus_tree_log_entry.h>

类 bplus_tree::LogEntryHandler 继承关系图:
bplus_tree::InitHeaderPageLogEntryHandler bplus_tree::NodeLogEntryHandler bplus_tree::UpdateRootPageLogEntryHandler bplus_tree::InternalCreateNewRootLogEntryHandler bplus_tree::InternalInitEmptyLogEntryHandler bplus_tree::InternalUpdateKeyLogEntryHandler bplus_tree::LeafInitEmptyLogEntryHandler bplus_tree::LeafSetNextPageLogEntryHandler bplus_tree::NormalOperationLogEntryHandler bplus_tree::SetParentPageLogEntryHandler

Public 成员函数

 LogEntryHandler (LogOperation operation, Frame *frame=nullptr)
 
Frameframe ()
 返回日志对应的frame 更多...
 
const Frameframe () const
 
PageNum page_num () const
 
void set_page_num (PageNum page_num)
 
LogOperation operation_type () const
 日志操作类型
 
RC serialize (common::Serializer &buffer) const
 序列化日志
 
RC serialize_header (common::Serializer &buffer) const
 序列化日志头
 
virtual RC serialize_body (common::Serializer &buffer) const =0
 序列化日志内容。所有子类应该实现这个函数 更多...
 
virtual RC rollback (BplusTreeMiniTransaction &mtr, BplusTreeHandler &tree_handler)=0
 回滚 更多...
 
virtual RC redo (BplusTreeMiniTransaction &mtr, BplusTreeHandler &tree_handler)=0
 重做 更多...
 
virtual string to_string () const
 

静态 Public 成员函数

static RC from_buffer (function< RC(PageNum, Frame *&)> frame_getter, common::Deserializer &buffer, unique_ptr< LogEntryHandler > &handler)
 从buffer中反序列化出一个LogEntryHandler 更多...
 
static RC from_buffer (DiskBufferPool &buffer_pool, common::Deserializer &buffer, unique_ptr< LogEntryHandler > &handler)
 
static RC from_buffer (common::Deserializer &deserializer, unique_ptr< LogEntryHandler > &handler)
 

Protected 属性

LogOperation operation_type_
 
Frameframe_ = nullptr
 
PageNum page_num_ = BP_INVALID_PAGE_NUM
 page num本来存放在frame中。但是只有在运行时才能拿到frame,为了强制适配 解析文件buffer时不存在运行时的情况,直接记录page num
 

详细描述

B+树日志处理辅助类

每种操作类型的日志,都有一个具体的实现类。

成员函数说明

◆ frame()

Frame * bplus_tree::LogEntryHandler::frame ( )
inline

返回日志对应的frame

每条日志都对应着操作关联的页面。但是在日志重放时,或者只是想将日志内容格式化时,是没有对应的页面的。

◆ from_buffer()

RC bplus_tree::LogEntryHandler::from_buffer ( function< RC(PageNum, Frame *&)>  frame_getter,
common::Deserializer buffer,
unique_ptr< LogEntryHandler > &  handler 
)
static

从buffer中反序列化出一个LogEntryHandler

参数
frame_getter为了方便测试增加的一个接口。如果把BufferPool抽象的更好,或者把BplusTree日志的二进制数据与Handler解耦,也不需要这样的接口
buffer二进制Buffer
[out]handler返回结果

这里有个比较别扭的地方。一个日志应该有两种表现形式,一个是内存或磁盘中的二进制数据,另一个是可以进行操作的Handler。 但是这里实现的时候,只使用了handler,所以在反序列化时,有些场景下根本不需要Frame,但是为了适配,允许传入一个null frame。 在LogEntryHandler类中也做了特殊处理。就是虽然有frame指针对象,但是也另外单独记录了page_num。

◆ redo()

virtual RC bplus_tree::LogEntryHandler::redo ( BplusTreeMiniTransaction mtr,
BplusTreeHandler tree_handler 
)
pure virtual

◆ rollback()

virtual RC bplus_tree::LogEntryHandler::rollback ( BplusTreeMiniTransaction mtr,
BplusTreeHandler tree_handler 
)
pure virtual

◆ serialize_body()

virtual RC bplus_tree::LogEntryHandler::serialize_body ( common::Serializer buffer) const
pure virtual

该类的文档由以下文件生成: