All Projects → bhhbazinga → BPlusTree

bhhbazinga / BPlusTree

Licence: other
A simple persistent kv store based on B+Tree.

Programming Languages

C++
36643 projects - #6 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to BPlusTree

Pomegranate
🌳 A tiny skiplist based log-structured merge-tree written in Rust.
Stars: ✭ 20 (+11.11%)
Mutual labels:  kv
duck db
c/c++ build a simple b+tree RDMS(利用c/c++ 开发基于B+树的小型关系型数据库 )
Stars: ✭ 247 (+1272.22%)
Mutual labels:  bplustree
zedis
A tiny embedded, lock free, redis-like, pub+sub, brokerless, key value datastore. ømq+sled
Stars: ✭ 33 (+83.33%)
Mutual labels:  kv
CMU-15445
https://www.jianshu.com/nb/36265841
Stars: ✭ 220 (+1122.22%)
Mutual labels:  bplustree
Tendis
Tendis is a high-performance distributed storage system fully compatible with the Redis protocol.
Stars: ✭ 2,295 (+12650%)
Mutual labels:  kv
Sled
the champagne of beta embedded databases
Stars: ✭ 5,423 (+30027.78%)
Mutual labels:  kv
pickledb-rs
PickleDB-rs is a lightweight and simple key-value store. It is a Rust version for Python's PickleDB
Stars: ✭ 116 (+544.44%)
Mutual labels:  kv
hidalgo
High-level Database Abstraction Layer for Go
Stars: ✭ 43 (+138.89%)
Mutual labels:  kv
orbit-db-kvstore
Key-Value database for orbit-db
Stars: ✭ 24 (+33.33%)
Mutual labels:  kv
Bplustree
A minimal but extreme fast B+ tree indexing structure demo for billions of key-value storage
Stars: ✭ 1,598 (+8777.78%)
Mutual labels:  bplustree
algorithm-structure
2021年最新总结 500个常用数据结构,算法,算法导论,面试常用,大厂高级工程师整理总结
Stars: ✭ 590 (+3177.78%)
Mutual labels:  bplustree
cmu15-445
💾 CMU 15-445/645: Intro to Database Systems (Fall 2017). A course on the design and implementation of database management systems.
Stars: ✭ 115 (+538.89%)
Mutual labels:  bplustree

BPlusTree

A 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.
The 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.
In 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.

Feature

  • Use mmap to read and write to disk.
  • Use LRU to cache mapped blocks.

Benchmark

Magnitude Put Get Delete
10K 72ms 28ms 52ms
100K 900ms 507ms 777ms
1000K 10333ms 4726ms 8154ms

The above data was tested on my 2013 macbook-pro with Intel Core i7 4 cores 2.3 GHz.
Each record has a value length of 100 bytes and I set cache size to 5MB. See also test.

Build

make && ./test

API

BPlusTree(const char* path);
void Put(const std::string& key, const std::string& value);
bool Delete(const std::string& key);
bool Get(const std::string& key, std::string& value) const;
std::vector<std::string> GetRange(const std::string& left, const std::string& right) const;
bool Empty() const;
size_t Size() const;

TODO List

  • Support for variable key-value length.
  • When Dealloc is executed, put block into reuse-pool.
  • Defragment db file.
  • Add WAL(Write Ahead Log).
  • Data compression.

Reference

[1] https://en.wikipedia.org/wiki/B%2B_tree
[2] https://www.cnblogs.com/nullzx/p/8729425.html
[3] http://man7.org/linux/man-pages/man2/mmap.2.html

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].