0

I'm trying to implement B+ tree (in C language) with each key being some data(int/float/string) and corresponding value is a list, whose size is not fixed.

I want to store this tree in a file and access later on, when required. You may consider the implementation as follows:

  • Each search key corresponds to a page in the file and
  • Each page contains set of values corresponding to that key

The problem is: I cannot just assign a page to a key, as it may consume very little and waste the entire page. So I need a persistent way of implementing B+ tree in file system, instead of main-memory.

Chaithanya
  • 608
  • 1
  • 8
  • 29
  • There is no tag for B+Tree, so added B-Tree tag. But it is for B+Tree – Chaithanya May 02 '13 at 17:29
  • 1
    Have you considered simply using the SQLite database for this? That will allow you to store a database of key/value pairs on disk. – steveha May 02 '13 at 17:31
  • What sort of performance do you need for this? Could you just serialize your data in JSON? You mention a "page"... what do you have in mind for a "page"? – steveha May 02 '13 at 17:33
  • chaithanya, Note B+ Trees are distinct from B-Trees. – GRAYgoose124 May 02 '13 at 17:34
  • He was right, there wasn't a tag for B+ trees. I edited to add the "b-plus-tree" tag since the string "b+tree" wasn't permitted. – steveha May 02 '13 at 17:46
  • @GRAYgoose124 I do understand that they are different. So commented above. – Chaithanya May 02 '13 at 17:47
  • @steveha Page is a some contiguous amount of memory in a file, so that I can consider a file to be as set of pages, each page being referenced by a key – Chaithanya May 02 '13 at 17:47
  • Thanks for adding the tag. I have no sufficient score to create a new tag. I cannot use JSON or SQLite, as this code is part of a huge code written in C. – Chaithanya May 02 '13 at 17:52
  • I don't see a specific question. I don't see a description of what you tried to make it persistent, and why it didn't work. – jxh May 02 '13 at 18:21
  • My question is to find a strategy that will allow me to store the values of a key contiguously and to be able to retrive them later on. You can think of this problem as implementing B+tree on files – Chaithanya May 02 '13 at 18:37
  • @chaithanya Please note that the tag `b+-tree` is currently a synonym of `b-tree`. While they may be separate concepts, people in the past disagreed enough to make them synonyms. If you feel passionately that they're totally different things, you might want to head over to Meta and ask that the synonym be broken. – Charles May 03 '13 at 02:04

1 Answers1

2

Check this disk-based B-tree implementation out, it might be help.

And this paper titled Fully Persistent B+-Trees