// // Created by i on 2021/10/24. // #ifndef INVODB_BTREE_NODE_H #define INVODB_BTREE_NODE_H #include #include #include #include #include "file/page_manager.h" /** * m = 28 * value string max * (32 + 4)*28 + 5 = 1013 */ class BTreeNodeUUID { public: static BTreeNodeUUID* getNode(const int& address); BTreeNodeUUID(const int& address):address(address) { clear(); StoragePage page = PageManager::Instance().getPage(address); for(int i=0; i<28; i++) { for(int j=0; j<32; j++) { key[i] += page[i * 32 + j]; } } int p = 28 * 32; for(int i=0; iparent; child.parent = address; child.save(); } } int size() { return n_size; } int insert(const std::string uuid) { // static int cnt = 0; // if(!isLeaf() && size() >= 27) { // if(cnt) throw "fuck"; // cnt++; // } int pos = 0; while(pos < n_size && uuid > key[pos]) pos++; val[n_size + 1] = val[n_size]; for(int i=n_size; i>pos; i--) { val[i] = val[i - 1]; key[i] = key[i - 1]; } key[pos] = uuid; n_size++; return pos; } void print() { printf("---------BTreeNode---------\n"); for(int i=0; i map; int address; int n_size; bool leaf; }; #endif //INVODB_BTREE_NODE_H