views:

54

answers:

2

I need a muti index container based on red-black trees (something like boost::multi_index::multi_index_container) for the case of the harddisk storage. All data must be store on hard disk rather than in memory.

Is there an open source container such that described conditions hold?

Note. I use C++.

A: 

If you have an in-memory solution, you can use a memory-mapped file and a custom allocator to achieve persistent storage.

Michael J
It is not true. First of all in-memory solution is stable with respect to a fragmentation because there are exist memory pages in the OS. You have many problems with dynamic memory allocations and deallocations in the file storage. Secondly there is a restriction of 2Gb on the 32bit systems.
Alexey Malistov
@alexey Any file-based solution will be prone to fragmentation, but a suitable custom allocator can minimise that. The 2GB limit may be a problem, if you expect a bigger data set than that. You can use multiple mapped files, but that may become too complex to be feasible. The question didn't say that you need more than 2GB on a 32-bit system. Maybe it was implied by the need for file storage, but I didn't understand it that way. (Sorry).
Michael J
Another problem is how to attach existing file with data to multi index container.
Alexey Malistov
+1  A: 

I am afraid I don't know any.

For hard-disk storage I can only recommend a look to STXXL, which proposes STL containers and algorithms adapted to data that can only fit on disk. They have implemented many things to allow for a smoother manipulation, essentially by caching in memory as much as possible and delaying disk access when possible.

Now that won't get you a multi index, but at least you'll have a STL :)

Then, if you are determined, you can port multi-index to use the facilities provided by STXXL: they have decorrelated the IO access / memory caching from the containers themselves.

Or you can simply write what you need based on their STL-compliant containers.

Matthieu M.