4 #include "buffer/buffer_manager.h"
5 #include "share/config.h"
9 #define KEY_VALUE_T_DECLARE template<typename key_t, typename value_t>
10 #define MAPPING_T std::pair<key_t, value_t>
12 #define LEAF_HEADER_SIZE 24
13 #define INTERNAL_HEADER_SIZE 24
14 #define MAX_LEAF_SIZE ((BLOCKSIZE - LEAF_HEADER_SIZE) / sizeof(std::pair<key_t, value_t>) - 1)
15 #define MAX_INTERNAL_SIZE ((BLOCKSIZE - INTERNAL_HEADER_SIZE) / sizeof(std::pair<key_t, value_t>) - 1)
16 #define INVALID_BLOCK_ID -1
46 void init(blockId_t myBId, blockId_t parentId){
47 _blockType = INVALID_BLOCK;
48 _parent_block_id = parentId;
53 return _blockType == LEAF_BLOCK;
56 blockType_t _blockType;
57 blockId_t _parent_block_id;
61 blockId_t _next_block_id;
77 void init(blockId_t myBId, blockId_t parentId, blockId_t next_block_id){
79 bpTree_Block::_blockType = LEAF_BLOCK;
80 bpTree_Block::_next_block_id = next_block_id;
81 bpTree_Block::_size = 0;
82 bpTree_Block::_max_size = MAX_LEAF_SIZE;
96 int right = _size - 1;
99 mid = (left + right) / 2;
111 return (db_size_t)left;
129 void init(blockId_t myBId, blockId_t parentId){
131 bpTree_Block::_blockType = INTERNAL_BLOCK;
133 bpTree_Block::_size = 0;
134 bpTree_Block::_max_size = MAX_INTERNAL_SIZE;
144 db_size_t right = _size - 1;
146 while(left <= right){
147 mid = (left + right + 1) / 2;