{"id":13713927,"url":"https://github.com/naoto0822/go-b-plus-tree","last_synced_at":"2026-01-14T21:18:28.466Z","repository":{"id":59044077,"uuid":"521154516","full_name":"naoto0822/go-b-plus-tree","owner":"naoto0822","description":"B+Tree implementation in Go :deciduous_tree:","archived":false,"fork":false,"pushed_at":"2022-08-23T05:45:45.000Z","size":1075,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-07T00:36:58.281Z","etag":null,"topics":["b-plus-tree","database","go"],"latest_commit_sha":null,"homepage":"","language":"Go","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/naoto0822.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}},"created_at":"2022-08-04T06:44:29.000Z","updated_at":"2022-09-07T08:07:05.000Z","dependencies_parsed_at":"2022-09-11T04:23:23.899Z","dependency_job_id":null,"html_url":"https://github.com/naoto0822/go-b-plus-tree","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/naoto0822/go-b-plus-tree","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naoto0822%2Fgo-b-plus-tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naoto0822%2Fgo-b-plus-tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naoto0822%2Fgo-b-plus-tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naoto0822%2Fgo-b-plus-tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/naoto0822","download_url":"https://codeload.github.com/naoto0822/go-b-plus-tree/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naoto0822%2Fgo-b-plus-tree/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28434758,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T18:57:19.464Z","status":"ssl_error","status_checked_at":"2026-01-14T18:52:48.501Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["b-plus-tree","database","go"],"created_at":"2024-08-02T23:01:47.869Z","updated_at":"2026-01-14T21:18:28.448Z","avatar_url":"https://github.com/naoto0822.png","language":"Go","funding_links":[],"categories":["Repositories"],"sub_categories":[],"readme":"# B+Tree implementation in Go\n\n[![CI](https://github.com/naoto0822/go-b-plus-tree/actions/workflows/ci.yml/badge.svg)](https://github.com/naoto0822/go-b-plus-tree/actions/workflows/ci.yml)\n[![Go Report Card](https://goreportcard.com/badge/github.com/naoto0822/go-b-plus-tree)](https://goreportcard.com/report/github.com/naoto0822/go-b-plus-tree)\n[![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/naoto0822/go-b-plus-tree/blob/main/LICENSE)\n\n## Overview\n\n`go-b-plus-tree` is B+Tree implemented in Go.\nIt is a toy project, aimed at an InnoDB-like storage engine.\n\n## Feature\n\n- [x] Get\n- [x] Insert\n- [x] RangeScan (ASC)\n- [ ] Delete\n- [x] Split Node\n- [ ] Merge Node\n\n## Design\n\n### Layer\n\n- `Tree`\n- `BufferPoolManager`\n- `BufferPool`\n- `DiskManager`\n\n```mermaid\nsequenceDiagram\n    participant T AS Tree\n    participant BPM AS BufferPoolManager\n\tparticipant BP AS BufferPool\n\tparticipant DM AS DiskManager\n\n    T-\u003e\u003eDM: Handling `Node` and `Page`\n```\n\n### Tree / Node\n\n- InternalNode\n\t- Key and PageID\n- LeafNode\n\t- Key and Value\n\t- Connected horizontal nodes\n\n![node_tree](./docs/node_tree.png)\n\n### Page Layout\n\nUsing `gob` for serialization and deserialization.\n\n```go\ntype Page struct {\n\tID       int64\n\tNodeType NodeType\n\tPrevID   int64\n\tNextID   int64\n\tRecords  []KeyValue\n}\n```\n\n## Usage\n\n```go\npath := \"./test.btr\"\ndisk, err := bplustree.NewDiskManager(path)\nif err != nil {\n\tpanic(err)\n}\ndefer disk.Close()\n\nbufferPoolManager := bplustree.NewBufferPoolManager(disk)\ntree := bplustree.NewTree(bufferPoolManager)\n\n// Get\ngot, err := tree.Get([]byte(`m`))\nif err != nil {\n\tfmt.Printf(\"error: %+v\\n\", err)\n} else {\n\tfmt.Printf(\"got: key: %v, value: %v\\n\", string(got.Key), string(got.Value))\n}\n\n// Insert\nerr := tree.Insert([]byte(`o`), []byte(`ooo`))\nif err != nil {\n\tfmt.Printf(\"error: %+v\\n\", err)\n}\n\n// RangeScan\nstart := []byte(`h`)\nend := []byte(`o`)\ngot, err := tree.RangeScan(start, end)\nif err != nil {\n\tfmt.Printf(\"error: %+v\\n\", err)\n} else {\n\toutFmt := \"\"\n\tfor _, kv := range got {\n\t\toutFmt += fmt.Sprintf(\" {%s: %s} \", string(kv.Key), string(kv.Value))\n\t}\n\tfmt.Printf(\"got startKey: %v, endKey: %v \\n records: %v \\n\", string(start), string(end), outFmt)\n}\n```\n\n## TODO\n\n### Slotted Page Layout\n\n- [CMU Database Systems - 03 Database Storage I (Fall 2018)](https://www.youtube.com/watch?v=uuX4PQXBeos)\n- [CMU Database Systems - 04 Database Storage II (Fall 2018)](https://www.youtube.com/watch?v=NXRgIsH83xE)\n\n### Clock-Sweep\n\n- [CS 537 Notes, Section #20: Clock Algorithm, Thrashing](https://pages.cs.wisc.edu/~bart/537/lecturenotes/s20.html)\n\n### Memcomparable Format\n\n- [MyRocks record format](https://github.com/facebook/mysql-5.6/wiki/MyRocks-record-format)\n- [pingcap/tidb bytes.go](https://github.com/pingcap/tidb/blob/master/util/codec/bytes.go)\n\n### Searching Min Key\n\nMax(now) -\u003e Min(want)  \nhttps://github.com/naoto0822/go-b-plus-tree/blob/main/node.go#L79\n\n### etc\n\n- [ ] arrange `Tree` reciever name\n- [ ] update error message\n- [ ] fix error handling\n- [ ] delete `NodeTypeRoot`\n- [ ] more test code\n\n## Test\n\n```\n$ make test\n```\n\n## Reference\n\n- [riywo/b-plus-tree](https://github.com/riywo/b-plus-tree)\n- [KOBA789/relly](https://github.com/KOBA789/relly)\n- [totechite/b_plus_tree](https://github.com/totechite/b_plus_tree)\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaoto0822%2Fgo-b-plus-tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnaoto0822%2Fgo-b-plus-tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaoto0822%2Fgo-b-plus-tree/lists"}