I need a large map of sets of numbers.
So i'm using stxxl and it's basically something like map<std::string, std::vector<int>>
.
The key is 3-letters identifier.
There are about 3k enteries in the map, and each of them can contain up to 500K numbers.
It is important to use vector in the value since i need to change it (add/remove numbers).
The problem is that after i insert all my data, when i try to access an element in the map, the vector is currupted.
#define MAX_STRING_IN_MAP ("ZZZZZZZ")
// String comparator.
struct CompareGreaterString
{
bool operator () (const std::string& a, const std::string& b) const {
return a > b;
}
static std::string max_value() {
return MAX_STRING_IN_MAP;
}
};
typedef stxxl::map<std::string, std::vector<int>, CompareGreaterString, DATA_NODE_BLOCK_SIZE, DATA_LEAF_BLOCK_SIZE> myMap;
...
ifstream input_file;
myMap map((mapBacteria::node_block_type::raw_size) * 5, (mapBacteria::leaf_block_type::raw_size) * 5);
...
unsigned int count = 0;
while (count < max_number) {
count++;
std::string name;
unsigned int length;
input_file >> name;
input_file >> length;
std::vector<int> iterationGroup = readNumbers(input_file);
myMap.insert(std::pair<std::string, std::vector<int>>(name, iterationGroup));
// If i am trying to access the data here, like this:
// auto result = myMap[name];
// It seems perfectely fine.
}
For example, if after the above insertion i will try to access the map:
auto result = myMap["aaa"];
Then i get a vector with the right size, but all it's elements have a value of 0xfeeefeee
instead of the numbers that were originally in the inserted vector.