1

stxxl::vector has a constructor where you can provide a stxxl::file *. This ties the vector to that specific file:

typedef stxxl::VECTOR_GENERATOR<int>::result stxxl_vector_int;
{
    stxxl::syscall_file f("some_vec.bin", stxxl::file::RDWR | stxxl::file::CREAT);
    stxxl_vector_int vec = stxxl_vector_int(&f);
    vec.push_back(1);
}
{
    stxxl::syscall_file f("some_vec.bin", stxxl::file::RDWR | stxxl::file::CREAT);
    stxxl_vector_int vec = stxxl_vector_int(&f);
    std::cout << vec.size() << std::endl;
}

This outputs 1 on the first run, 2 on the second run (if the file wasn't deleted), etc.

How can I do the same for an stxxl::map? I don't see any functions in the docs which have anything to do with stxxl::files.

Specifically, I want to specify a location on disk where the map is stored, instead of wherever stxxl usually does it, so that I can destruct the instance, create a new one, and have it already contain the same data as the destructed instance (i.e. persist the stxxl::map's data using stxxl's already-existing disk storage mechanisms).

Claudiu
  • 224,032
  • 165
  • 485
  • 680
  • According to the docs, it doesn't seem to support it. But if that library comes with source code, perhaps you can look at how they do it with vector and copy the methodology. – Anon Mail Dec 08 '15 at 18:32
  • @AnonMail: According to [one of the devs](https://github.com/stxxl/stxxl/issues/24#issuecomment-162966041) it looks like the request doesn't make sense. I've asked if there's a way to use stxxl's already-existing disk-store mechanisms to preserve an `stxxl::map`'s data across different instances... will see what they say! – Claudiu Dec 08 '15 at 20:12

0 Answers0