MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
Public 成员函数 | Private 成员函数 | Private 属性 | 友元 | 所有成员列表
InternalIndexNodeHandler类 参考final

内部节点的操作 更多...

#include <bplus_tree.h>

类 InternalIndexNodeHandler 继承关系图:
IndexNodeHandler

Public 成员函数

 InternalIndexNodeHandler (BplusTreeMiniTransaction &mtr, const IndexFileHeader &header, Frame *frame)
 
RC init_empty ()
 
RC create_new_root (PageNum first_page_num, const char *key, PageNum page_num)
 
RC insert (const char *key, PageNum page_num, const KeyComparator &comparator)
 insert one entry 更多...
 
char * key_at (int index)
 
PageNum value_at (int index)
 
int value_index (PageNum page_num)
 
void set_key_at (int index, const char *key)
 
void remove (int index)
 
int lookup (const KeyComparator &comparator, const char *key, bool *found=nullptr, int *insert_position=nullptr) const
 
RC move_to (InternalIndexNodeHandler &other)
 把当前节点的所有数据都迁移到另一个节点上 更多...
 
RC move_first_to_end (InternalIndexNodeHandler &other)
 
RC move_last_to_front (InternalIndexNodeHandler &other)
 
RC move_half_to (InternalIndexNodeHandler &other)
 move half of the items to the other node ends
 
bool validate (const KeyComparator &comparator, DiskBufferPool *bp) const
 
- Public 成员函数 继承自 IndexNodeHandler
 IndexNodeHandler (BplusTreeMiniTransaction &mtr, const IndexFileHeader &header, Frame *frame)
 
void init_empty (bool leaf)
 初始化一个新的页面 更多...
 
bool is_leaf () const
 是否叶子节点
 
virtual int key_size () const
 存储的键值大小
 
virtual int value_size () const
 存储的值的大小。内部节点和叶子节点是不一样的,但是这里返回的是叶子节点存储的大小 更多...
 
virtual int item_size () const
 存储的键值对的大小。值是指叶子节点中存放的数据 更多...
 
void increase_size (int n)
 
int size () const
 
int max_size () const
 
int min_size () const
 
RC set_parent_page_num (PageNum page_num)
 
PageNum parent_page_num () const
 
PageNum page_num () const
 
bool is_safe (BplusTreeOperationType op, bool is_root_node)
 判断对指定的操作,是否安全的 更多...
 
bool validate () const
 验证当前节点是否有问题
 
Frameframe () const
 
RC recover_insert_items (int index, const char *items, int num)
 
RC recover_remove_items (int index, int num)
 

Private 成员函数

RC insert_items (int index, const char *items, int num)
 
RC append (const char *items, int num)
 
RC append (const char *item)
 
RC preappend (const char *item)
 
char * __item_at (int index) const override
 获取指定元素的开始内存位置 更多...
 
int value_size () const override
 存储的值的大小。内部节点和叶子节点是不一样的,但是这里返回的是叶子节点存储的大小 更多...
 
int item_size () const override
 存储的键值对的大小。值是指叶子节点中存放的数据 更多...
 

Private 属性

InternalIndexNodeinternal_node_ = nullptr
 

友元

string to_string (const InternalIndexNodeHandler &handler, const KeyPrinter &printer)
 

额外继承的成员函数

- Protected 成员函数 继承自 IndexNodeHandler
virtual char * __item_at (int index) const
 获取指定元素的开始内存位置 更多...
 
char * __key_at (int index) const
 
char * __value_at (int index) const
 
- Protected 属性 继承自 IndexNodeHandler
BplusTreeMiniTransactionmtr_
 
const IndexFileHeaderheader_
 
Frameframe_ = nullptr
 
IndexNodenode_ = nullptr
 

详细描述

内部节点的操作

成员函数说明

◆ __item_at()

char * InternalIndexNodeHandler::__item_at ( int  index) const
overrideprivatevirtual

获取指定元素的开始内存位置

注解
这并不是一个纯虚函数,是为了可以直接使用 IndexNodeHandler 类。 但是使用这个类时,注意不能使用与这个函数相关的函数。

重载 IndexNodeHandler .

◆ append()

RC InternalIndexNodeHandler::append ( const char *  items,
int  num 
)
private

copy items from other node to self's right

◆ insert()

RC InternalIndexNodeHandler::insert ( const char *  key,
PageNum  page_num,
const KeyComparator comparator 
)

insert one entry

the entry to be inserted will never at the first slot. the right child page after split will always have bigger keys. @NOTE We don't need to set child's parent page num here. You can see the callers for details It's also friendly to unittest that we don't set the child's parent page num.

◆ item_size()

int InternalIndexNodeHandler::item_size ( ) const
overrideprivatevirtual

存储的键值对的大小。值是指叶子节点中存放的数据

重载 IndexNodeHandler .

◆ lookup()

int InternalIndexNodeHandler::lookup ( const KeyComparator comparator,
const char *  key,
bool *  found = nullptr,
int *  insert_position = nullptr 
) const

与Leaf节点不同,lookup返回指定key应该属于哪个子节点,返回这个子节点在当前节点中的索引 如果想要返回插入位置,就提供 insert_position 参数

参数
[in]comparator用于键值比较的函数
[in]key查找的键值
[out]found如果是有效指针,将会返回当前是否存在指定的键值
[out]insert_position如果是有效指针,将会返回可以插入指定键值的位置

lookup the first item which key <= item

返回
unlike the leafNode, the return value is not the insert position, but only the index of child to find.

◆ move_to()

RC InternalIndexNodeHandler::move_to ( InternalIndexNodeHandler other)

把当前节点的所有数据都迁移到另一个节点上

参数
other数据迁移的目标节点

◆ value_index()

int InternalIndexNodeHandler::value_index ( PageNum  page_num)

返回指定子节点在当前节点中的索引

◆ value_size()

int InternalIndexNodeHandler::value_size ( ) const
overrideprivatevirtual

存储的值的大小。内部节点和叶子节点是不一样的,但是这里返回的是叶子节点存储的大小

重载 IndexNodeHandler .


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