{"id":18698737,"url":"https://github.com/chenningg/cz4031-b-plus-tree","last_synced_at":"2025-07-06T07:08:12.356Z","repository":{"id":99559200,"uuid":"295618712","full_name":"chenningg/cz4031-b-plus-tree","owner":"chenningg","description":"B+ tree implementation in C++ for NTU's CZ4031 course of Database Systems Principles. Supports duplicate keys.","archived":false,"fork":false,"pushed_at":"2020-10-24T16:24:34.000Z","size":8762,"stargazers_count":11,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T07:53:02.694Z","etag":null,"topics":["bplustree","cpp","database","database-systems-principles","index"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chenningg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-15T04:56:59.000Z","updated_at":"2024-10-07T17:14:40.000Z","dependencies_parsed_at":"2023-04-14T11:00:45.734Z","dependency_job_id":null,"html_url":"https://github.com/chenningg/cz4031-b-plus-tree","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/chenningg/cz4031-b-plus-tree","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenningg%2Fcz4031-b-plus-tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenningg%2Fcz4031-b-plus-tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenningg%2Fcz4031-b-plus-tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenningg%2Fcz4031-b-plus-tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chenningg","download_url":"https://codeload.github.com/chenningg/cz4031-b-plus-tree/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenningg%2Fcz4031-b-plus-tree/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263861950,"owners_count":23521356,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bplustree","cpp","database","database-systems-principles","index"],"created_at":"2024-11-07T11:29:32.024Z","updated_at":"2025-07-06T07:08:12.350Z","avatar_url":"https://github.com/chenningg.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# B+ Tree\n\nThis is a B+ tree implementation using C++ for NTU's CZ4031 course of Database Systems Principles. The data given is a list of movies, with each record containing the movie ID, its average rating and the number of votes.\n\n|  tconst   | averageRating | numVotes |\n| :-------: | :-----------: | :------: |\n| tt0000001 |      5.6      |   1645   |\n| tt0000002 |      6.1      |   198    |\n| tt0000003 |      6.5      |   1342   |\n\nThere are more than 1 million records in the data. Our goal is to build a B+ tree index on the average rating field, and query the data based on the index for efficient retrieval.\n\n## Implementation details:\n\n- Blocks are stored in a memory pool of up to 500MB in main memory.\n- Each block's size is 100B for the first implementation, and 500B for the second.\n- Each record (movie) has a fixed size of ~20B.\n- Multiple records can be stored per block.\n- B+ tree's memory is dynamically allocated on creation.\n- Each B+ tree node is the size of one block.\n- Leaf nodes are linked in a doubly linked list.\n- Leaf nodes maintain pointers to the actual data address in memory pool.\n\n## Setup\n\n- Ensure that you have a C++ compiler (we suggest [mingw](https://sourceforge.net/projects/mingw-w64/) for Windows).\n- Setup your environment and ensure all C++ files are included in compilation.\n\n  For example, if we use the [code runner](https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner) extension for VSCode, we would add this in `settings.json`:\n\n  ```\n  \"code-runner.executorMap\": {\n    \"cpp\": \"cd $dir \u0026\u0026 g++ *.cpp -o $fileNameWithoutExt \u0026\u0026 $dir$fileNameWithoutExt\",\n  }\n  ```\n\n  If we were running C++ using VSCode directly, we would define the `tasks.json` file with corresponding `args` to include all C++ files:\n\n  ```\n  \"tasks\": [\n    {\n      \"args\": [\"-g\", \"${workspaceFolder}\\\\*.cpp\", \"-o\", \"${fileDirname}\\\\${fileBasenameNoExtension}.exe\"],\n    }\n  ]\n  ```\n\n- `cd` to `main.cpp` under the `src` folder and compile the executable.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenningg%2Fcz4031-b-plus-tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchenningg%2Fcz4031-b-plus-tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenningg%2Fcz4031-b-plus-tree/lists"}