diff --git a/CMakeLists.txt b/CMakeLists.txt index 89f53c3..7307acd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,4 +8,4 @@ include_directories(./invodb) add_executable(InvoDB invodb/main.cpp - invodb/main.h invodb/file/page_manager.cpp invodb/file/page_manager.h invodb/models/json.cpp invodb/models/json.h invodb/invodb.cpp invodb/invodb.h invodb/models/collection.cpp invodb/models/collection.h invodb/file/storage_page.cpp invodb/file/storage_page.h invodb/utils/logger.h invodb/utils/uuid.h) + invodb/main.h invodb/file/page_manager.cpp invodb/file/page_manager.h invodb/models/json.cpp invodb/models/json.h invodb/invodb.cpp invodb/invodb.h invodb/models/collection.cpp invodb/models/collection.h invodb/file/storage_page.cpp invodb/file/storage_page.h invodb/utils/logger.h invodb/utils/uuid.h invodb/btree/btree_node.cpp invodb/btree/btree_node.h) diff --git a/invodb/btree/btree_node.cpp b/invodb/btree/btree_node.cpp new file mode 100644 index 0000000..2991488 --- /dev/null +++ b/invodb/btree/btree_node.cpp @@ -0,0 +1,5 @@ +// +// Created by i on 2021/10/24. +// + +#include "btree_node.h" diff --git a/invodb/btree/btree_node.h b/invodb/btree/btree_node.h new file mode 100644 index 0000000..a55bb43 --- /dev/null +++ b/invodb/btree/btree_node.h @@ -0,0 +1,28 @@ +// +// Created by i on 2021/10/24. +// + +#ifndef INVODB_BTREE_NODE_H +#define INVODB_BTREE_NODE_H + +#include +#include + +/** + * m = 16 + * value string max 56 + * (56 + 4)*16 + 4 * 16 = 1024 + */ + +class BTreeNode { +public: + BTreeNode() { memset(arr, 0, sizeof(arr)); } +private: + struct NodeValue { + char key[56]; + int value; + }; + std::pair arr[127]; +}; + +#endif //INVODB_BTREE_NODE_H diff --git a/invodb/file/storage_page.cpp b/invodb/file/storage_page.cpp index a6612d3..784dd2b 100644 --- a/invodb/file/storage_page.cpp +++ b/invodb/file/storage_page.cpp @@ -47,7 +47,6 @@ void StoragePage::setStringStartFrom(const int &index, const char *str) { for(int i=0; i(json.ToString()); + Logger::info("INSERT ", json.ToString()); } diff --git a/invodb/utils/logger.h b/invodb/utils/logger.h index 22d2afd..b9f9ab3 100644 --- a/invodb/utils/logger.h +++ b/invodb/utils/logger.h @@ -10,10 +10,8 @@ class Logger { public: - template static void info(const T& msg); - template static void info(const T& first, const K& second); template diff --git a/invodb/utils/uuid.h b/invodb/utils/uuid.h index 8c6d8e8..1c3bc63 100644 --- a/invodb/utils/uuid.h +++ b/invodb/utils/uuid.h @@ -8,16 +8,12 @@ #include #include -std::string generateUUID() { +void generateUUID(char *uuid) { srand(time(NULL)); - std::string uuid; for(int i=0; i<32; i++) { int randn = rand() % 36; - //0~35; - uuid += (randn < 26 ? ('a' + randn) : ('0' + (randn - 26))); + uuid[i] = (randn < 26 ? ('a' + randn) : ('0' + (randn - 26))); } - std::cout << uuid << std::endl; - return uuid; } #endif //INVODB_UUID_H