{"id":19020699,"url":"https://github.com/bhhbazinga/bplustree","last_synced_at":"2025-08-27T03:17:29.793Z","repository":{"id":158612876,"uuid":"252466083","full_name":"bhhbazinga/BPlusTree","owner":"bhhbazinga","description":"A simple persistent kv store based on B+Tree.","archived":false,"fork":false,"pushed_at":"2021-03-28T10:31:05.000Z","size":95,"stargazers_count":23,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-01T06:18:20.888Z","etag":null,"topics":["algorithm","bplustree","cplusplus","kv"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bhhbazinga.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-04-02T13:39:47.000Z","updated_at":"2025-05-29T22:14:25.000Z","dependencies_parsed_at":"2023-08-22T20:50:12.407Z","dependency_job_id":null,"html_url":"https://github.com/bhhbazinga/BPlusTree","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bhhbazinga/BPlusTree","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhhbazinga%2FBPlusTree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhhbazinga%2FBPlusTree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhhbazinga%2FBPlusTree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhhbazinga%2FBPlusTree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bhhbazinga","download_url":"https://codeload.github.com/bhhbazinga/BPlusTree/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhhbazinga%2FBPlusTree/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272284293,"owners_count":24906859,"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","status":"online","status_checked_at":"2025-08-27T02:00:09.397Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["algorithm","bplustree","cplusplus","kv"],"created_at":"2024-11-08T20:18:13.565Z","updated_at":"2025-08-27T03:17:29.699Z","avatar_url":"https://github.com/bhhbazinga.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BPlusTree\nA B+ tree is an m-ary tree with a variable but often large number of children per node. A B+ tree consists of a root, internal nodes and leaves. The root may be either a leaf or a node with two or more children.\\\nThe primary value of a B+ tree is in storing data for efficient retrieval in a block-oriented storage context — in particular, filesystems(In my repo, I use mmap.). This is primarily because unlike binary search trees, B+ trees have very high fanout (number of pointers to child nodes in a node, typically on the order of 100 or more), which reduces the number of I/O operations required to find an element in the tree.\\\nIn theory, if the size of the index node in B+ tree is close to the size of the disk block(eg.4k bytes page size in linux), a query operation needs to access the disk logb(N) times.\n## Feature\n  * Use mmap to read and write to disk.\n  * Use LRU to cache mapped blocks.\n## Benchmark\n  Magnitude     | Put         | Get        | Delete     |\n  :-----------  | :-----------| :----------|:-----------|\n  10K           | 72ms        | 28ms       | 52ms       |\n  100K          | 900ms       | 507ms      | 777ms      |\n  1000K         | 10333ms     | 4726ms     | 8154ms     |\n  \nThe above data was tested on my 2013 macbook-pro with Intel Core i7 4 cores 2.3 GHz.\\\nEach record has a value length of 100 bytes and I set cache size to 5MB.\nSee also [test](test.cc).\n## Build\n```\nmake \u0026\u0026 ./test\n```\n## API\n```C++\nBPlusTree(const char* path);\nvoid Put(const std::string\u0026 key, const std::string\u0026 value);\nbool Delete(const std::string\u0026 key);\nbool Get(const std::string\u0026 key, std::string\u0026 value) const;\nstd::vector\u003cstd::string\u003e GetRange(const std::string\u0026 left, const std::string\u0026 right) const;\nbool Empty() const;\nsize_t Size() const;\n```\n## TODO List\n- [ ] Support for variable key-value length.\n- [ ] When Dealloc is executed, put block into reuse-pool.\n- [ ] Defragment db file.\n- [ ] Add WAL(Write Ahead Log).\n- [ ] Data compression.\n## Reference\n[1] https://en.wikipedia.org/wiki/B%2B_tree \\\n[2] https://www.cnblogs.com/nullzx/p/8729425.html \\\n[3] http://man7.org/linux/man-pages/man2/mmap.2.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbhhbazinga%2Fbplustree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbhhbazinga%2Fbplustree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbhhbazinga%2Fbplustree/lists"}