Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

B+ Tree Data Structure in Erlang

Is there any open source known implementation of the B+ Tree Data Structure in Erlang ?

like image 730
Muzaaya Joshua Avatar asked Nov 16 '12 12:11

Muzaaya Joshua


3 Answers

I would definitely recommend looking into the eleveldb application if you really need a B+ tree. The point being that you want to store data in leaves of a tree, off-line on disk, as this is where B+-trees are normally an option. There is also a variant in pure Erlang of LevelDB called hanoidb which also is pretty nice, written by Kresten Krab Thorup. Same area of use.

If you need in-memory storage, you should be looking at either ETS or Mnesia (the latter for distribution). In Erlang these tend to be the fastest solutions as you have the advantage of never hitting the disk. It is especially true if you can do standard key/value lookups on your data with no need to run inside the transactional context in Mnesia (doing dirty-reads). Typical lookup speed is then 5-10 nanoseconds.

like image 112
I GIVE CRAP ANSWERS Avatar answered Sep 19 '22 20:09

I GIVE CRAP ANSWERS


Just an alternative if you don't want to hack into open source database systems:

Chris Okasaki's Purely Functional Data Structures can give you some insight on implementing it by yourself. B+ tree itself is not that complicated from my experience.

I would recommend using gb_trees if you want both in-memory storage and something more low-level (in some sense) than ets and mnesia.

like image 26
Xiao Jia Avatar answered Sep 18 '22 20:09

Xiao Jia


There is not a stand-alone library available that I know of. However the CouchDB source code is very readable and well implemented.

like image 27
Jon Gretar Avatar answered Sep 20 '22 20:09

Jon Gretar