17#include "common/types.h"
18#include "common/sys/rc.h"
19#include "common/lang/span.h"
20#include "common/lang/string.h"
21#include "storage/index/bplus_tree.h"
59 explicit LogOperation(
int type) : type_(static_cast<
Type>(type)) {}
61 Type type()
const {
return type_; }
62 int index()
const {
return static_cast<int>(type_); }
64 string to_string()
const;
88 PageNum page_num()
const;
89 void set_page_num(PageNum page_num) {
page_num_ = page_num; }
114 virtual string to_string()
const;
136 Frame *frame_ =
nullptr;
169 string to_string()
const override;
193 string to_string()
const override;
197 PageNum root_page_num()
const {
return root_page_num_; }
200 PageNum root_page_num_ = -1;
201 PageNum old_page_num_ = -1;
218 string to_string()
const override;
222 PageNum parent_page_num()
const {
return parent_page_num_; }
225 PageNum parent_page_num_ = -1;
226 PageNum old_parent_page_num_ = -1;
243 string to_string()
const override;
245 static RC deserialize(
248 int index()
const {
return index_; }
249 int item_num()
const {
return item_num_; }
250 const char *items()
const {
return items_.data(); }
251 int32_t item_bytes()
const {
return static_cast<int32_t
>(items_.size()); }
292 string to_string()
const override;
296 PageNum new_page_num()
const {
return new_page_num_; }
299 PageNum new_page_num_ = -1;
300 PageNum old_page_num_ = -1;
336 string to_string()
const override;
340 PageNum first_page_num()
const {
return first_page_num_; }
341 PageNum page_num()
const {
return page_num_; }
342 const char *key()
const {
return key_.data(); }
343 int32_t key_bytes()
const {
return static_cast<int32_t
>(key_.size()); }
346 PageNum first_page_num_ = -1;
347 PageNum page_num_ = -1;
365 string to_string()
const override;
369 int index()
const {
return index_; }
370 const char *key()
const {
return key_.data(); }
371 int32_t key_bytes()
const {
return static_cast<int32_t
>(key_.size()); }
376 vector<char> old_key_;
B+树的实现
Definition: bplus_tree.h:450
B+树使用的事务辅助类
Definition: bplus_tree_log.h:170
BufferPool的实现
Definition: disk_buffer_pool.h:189
IndexNode 仅作为数据在内存或磁盘中的表示IndexNodeHandler 负责对IndexNode做各种操作。 作为一个类来说,虚函数会影响“结构体”真实的内存布局,所以将数据存储与操作分开
Definition: bplus_tree.h:267
初始化B+树文件头日志处理类
Definition: bplus_tree_log_entry.h:160
RC serialize_body(common::Serializer &buffer) const override
序列化日志内容。所有子类应该实现这个函数
Definition: bplus_tree_log_entry.cpp:193
RC rollback(BplusTreeMiniTransaction &mtr, BplusTreeHandler &tree_handler) override
回滚
Definition: bplus_tree_log_entry.cpp:218
RC redo(BplusTreeMiniTransaction &mtr, BplusTreeHandler &tree_handler) override
重做
Definition: bplus_tree_log_entry.cpp:224
创建新的根节点日志处理类
Definition: bplus_tree_log_entry.h:327
RC serialize_body(common::Serializer &buffer) const override
序列化日志内容。所有子类应该实现这个函数
Definition: bplus_tree_log_entry.cpp:456
RC rollback(BplusTreeMiniTransaction &mtr, BplusTreeHandler &tree_handler) override
回滚
Definition: bplus_tree_log_entry.h:333
RC redo(BplusTreeMiniTransaction &mtr, BplusTreeHandler &tree_handler) override
重做
Definition: bplus_tree_log_entry.cpp:494
初始化内部节点日志处理类
Definition: bplus_tree_log_entry.h:308
RC serialize_body(common::Serializer &buffer) const override
序列化日志内容。所有子类应该实现这个函数
Definition: bplus_tree_log_entry.h:313
RC redo(BplusTreeMiniTransaction &mtr, BplusTreeHandler &tree_handler) override
重做
Definition: bplus_tree_log_entry.cpp:433
RC rollback(BplusTreeMiniTransaction &mtr, BplusTreeHandler &tree_handler) override
回滚
Definition: bplus_tree_log_entry.h:314
更新内部节点的key日志处理类
Definition: bplus_tree_log_entry.h:356
RC serialize_body(common::Serializer &buffer) const override
序列化日志内容。所有子类应该实现这个函数
Definition: bplus_tree_log_entry.cpp:511
RC rollback(BplusTreeMiniTransaction &mtr, BplusTreeHandler &tree_handler) override
回滚
Definition: bplus_tree_log_entry.cpp:547
RC redo(BplusTreeMiniTransaction &mtr, BplusTreeHandler &tree_handler) override
重做
Definition: bplus_tree_log_entry.cpp:557
叶子节点初始化日志处理类
Definition: bplus_tree_log_entry.h:264
RC serialize_body(common::Serializer &buffer) const override
序列化日志内容。所有子类应该实现这个函数
Definition: bplus_tree_log_entry.h:269
RC redo(BplusTreeMiniTransaction &mtr, BplusTreeHandler &tree_handler) override
重做
Definition: bplus_tree_log_entry.cpp:363
RC rollback(BplusTreeMiniTransaction &mtr, BplusTreeHandler &tree_handler) override
回滚
Definition: bplus_tree_log_entry.h:270
设置叶子节点的兄弟节点日志处理类
Definition: bplus_tree_log_entry.h:283
RC serialize_body(common::Serializer &buffer) const override
序列化日志内容。所有子类应该实现这个函数
Definition: bplus_tree_log_entry.cpp:384
RC rollback(BplusTreeMiniTransaction &mtr, BplusTreeHandler &tree_handler) override
回滚
Definition: bplus_tree_log_entry.cpp:409
RC redo(BplusTreeMiniTransaction &mtr, BplusTreeHandler &tree_handler) override
重做
Definition: bplus_tree_log_entry.cpp:419
B+树日志处理辅助类
Definition: bplus_tree_log_entry.h:76
RC serialize_header(common::Serializer &buffer) const
序列化日志头
Definition: bplus_tree_log_entry.cpp:68
static RC from_buffer(function< RC(PageNum, Frame *&)> frame_getter, common::Deserializer &buffer, unique_ptr< LogEntryHandler > &handler)
从buffer中反序列化出一个LogEntryHandler
Definition: bplus_tree_log_entry.cpp:109
virtual RC serialize_body(common::Serializer &buffer) const =0
序列化日志内容。所有子类应该实现这个函数
PageNum page_num_
page num本来存放在frame中。但是只有在运行时才能拿到frame,为了强制适配 解析文件buffer时不存在运行时的情况,直接记录page num
Definition: bplus_tree_log_entry.h:140
virtual RC redo(BplusTreeMiniTransaction &mtr, BplusTreeHandler &tree_handler)=0
重做
LogOperation operation_type() const
日志操作类型
Definition: bplus_tree_log_entry.h:92
Frame * frame()
返回日志对应的frame
Definition: bplus_tree_log_entry.h:85
RC serialize(common::Serializer &buffer) const
序列化日志
Definition: bplus_tree_log_entry.cpp:59
virtual RC rollback(BplusTreeMiniTransaction &mtr, BplusTreeHandler &tree_handler)=0
回滚
B+树日志操作类型
Definition: bplus_tree_log_entry.h:39
Type
Definition: bplus_tree_log_entry.h:42
@ INTERNAL_INIT_EMPTY
设置叶子节点的兄弟节点
@ MAX_TYPE
在节点中间(也可能是末尾)删除一些元素
@ LEAF_SET_NEXT_PAGE
初始化叶子节点
@ UPDATE_ROOT_PAGE
初始化B+树文件头
@ INTERNAL_UPDATE_KEY
创建新的根节点
@ INTERNAL_CREATE_NEW_ROOT
初始化内部节点
@ NODE_REMOVE
在节点中间(也可能是末尾)插入一些元素
节点相关的操作
Definition: bplus_tree_log_entry.h:148
插入或者删除一些节点上的元素
Definition: bplus_tree_log_entry.h:234
RC serialize_body(common::Serializer &buffer) const override
序列化日志内容。所有子类应该实现这个函数
Definition: bplus_tree_log_entry.cpp:285
RC rollback(BplusTreeMiniTransaction &mtr, BplusTreeHandler &tree_handler) override
回滚
Definition: bplus_tree_log_entry.cpp:326
RC redo(BplusTreeMiniTransaction &mtr, BplusTreeHandler &tree_handler) override
重做
Definition: bplus_tree_log_entry.cpp:339
设置父节点日志处理类
Definition: bplus_tree_log_entry.h:209
RC serialize_body(common::Serializer &buffer) const override
序列化日志内容。所有子类应该实现这个函数
Definition: bplus_tree_log_entry.cpp:238
RC rollback(BplusTreeMiniTransaction &mtr, BplusTreeHandler &tree_handler) override
回滚
Definition: bplus_tree_log_entry.cpp:263
RC redo(BplusTreeMiniTransaction &mtr, BplusTreeHandler &tree_handler) override
重做
Definition: bplus_tree_log_entry.cpp:272
更新根节点日志处理类
Definition: bplus_tree_log_entry.h:184
RC rollback(BplusTreeMiniTransaction &mtr, BplusTreeHandler &tree_handler) override
回滚
Definition: bplus_tree_log_entry.cpp:598
RC redo(BplusTreeMiniTransaction &mtr, BplusTreeHandler &tree_handler) override
重做
Definition: bplus_tree_log_entry.cpp:603
RC serialize_body(common::Serializer &buffer) const override
序列化日志内容。所有子类应该实现这个函数
Definition: bplus_tree_log_entry.cpp:573
反序列化工具
Definition: serializer.h:63
序列化工具
Definition: serializer.h:29