1

I need to implement a B-tree. I know how to do this.

But I want to restore my data structure(B-tree) if my application will crash. So I want to store my B-tree not only in memory but also on the hard disk. How to do this?

  • 1
    @Sinatr the duplicate marked question has no accepted answer – fubo Jul 06 '16 at 09:05
  • @fubo, SO let me to vote-close it, not my problem ;) It doesn't matter if user accept something (maybe he don't know he has to), point is there are answers, which could be useful. Also, see [this question](http://stackoverflow.com/q/2186825/1997232) (perhaps its answer could be of use). – Sinatr Jul 06 '16 at 09:06
  • @fubo there probably is no accepted answer because this question is actually too broad for SO. OP wants to write his btree to disk? well, do it. What is this question about? About writing data to a file or about the order in which the leafes have to be written? What has been tried so far and where is the problem? – René Vogt Jul 06 '16 at 09:09

1 Answers1

1

What you need is Serialization. This gives you a representation of the data structure that can be stored on disk, either in a binary format or, for instance, XML. De-serialization will restore the data structure. Note that all items in the tree need to be Serializable as well.

Data structures in the .Net Framework often support serialization out of the box, but there seems to be no public B-tree implementation.

You could go an look for an implementation in Code project. Alternatively, BPlusTree could be what you are looking for:

BPlusTree is a implementation of the generic IDictionary interface backed by a disk-based B+Tree.

But I haven't used it.

R. Schreurs
  • 8,587
  • 5
  • 43
  • 62