|
MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
|
内部节点的操作 更多...
#include <bplus_tree.h>
Public 成员函数 | |
| InternalIndexNodeHandler (const IndexFileHeader &header, Frame *frame) | |
| void | init_empty () |
| void | create_new_root (PageNum first_page_num, const char *key, PageNum page_num) |
| void | insert (const char *key, PageNum page_num, const KeyComparator &comparator) |
| RC | move_half_to (LeafIndexNodeHandler &other, DiskBufferPool *bp) |
| 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, DiskBufferPool *disk_buffer_pool) |
| RC | move_first_to_end (InternalIndexNodeHandler &other, DiskBufferPool *disk_buffer_pool) |
| RC | move_last_to_front (InternalIndexNodeHandler &other, DiskBufferPool *bp) |
| RC | move_half_to (InternalIndexNodeHandler &other, DiskBufferPool *bp) |
| bool | validate (const KeyComparator &comparator, DiskBufferPool *bp) const |
Public 成员函数 继承自 IndexNodeHandler | |
| IndexNodeHandler (const IndexFileHeader &header, Frame *frame) | |
| void | init_empty (bool leaf) |
| bool | is_leaf () const |
| int | key_size () const |
| int | value_size () const |
| int | item_size () const |
| void | increase_size (int n) |
| int | size () const |
| int | max_size () const |
| int | min_size () const |
| void | 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 |
Private 成员函数 | |
| RC | copy_from (const char *items, int num, DiskBufferPool *disk_buffer_pool) |
| RC | append (const char *item, DiskBufferPool *bp) |
| RC | preappend (const char *item, DiskBufferPool *bp) |
| char * | __item_at (int index) const |
| char * | __key_at (int index) const |
| char * | __value_at (int index) const |
| int | value_size () const |
| int | item_size () const |
Private 属性 | |
| InternalIndexNode * | internal_node_ = nullptr |
友元 | |
| std::string | to_string (const InternalIndexNodeHandler &handler, const KeyPrinter &printer) |
额外继承的成员函数 | |
Protected 属性 继承自 IndexNodeHandler | |
| const IndexFileHeader & | header_ |
| PageNum | page_num_ |
| IndexNode * | node_ |
内部节点的操作
|
private |
copy items from other node to self's right
| void 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.
| 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
| int InternalIndexNodeHandler::value_index | ( | PageNum | page_num | ) |
返回指定子节点在当前节点中的索引