Reputation: 361
I've posted a question yesterday and I solved this by using multi_map: Having a composite key for hash map in c++
This works like a charm but the problem happens when the datasrt is big enough.
My data set is around 10M big, and it takes +350secs with ordered index, and 80secs with hashed index(unordered) for insertion.
This is a quite long time in comparison to map(pair, double) data structure which took only 25secs.
Does anyone have any idea improving the calc speed? Memory consumption is okay but the speed really matters to me.
Upvotes: 1
Views: 533
Reputation: 5658
Adding indices to a multi_index_container
comes at a price in insertion time: roughly speaking, if you have four indices insertion is as slow as inserting in four different one-index maps (in fact it's faster, as your figures show, since 80 < 4*25.)
In your particular case, you can get rid of the last index: just use the composite key stuff as your first index, since it will support lang1-only supports as well as (lang1,lang2) queries.
Upvotes: 1
Reputation: 473537
Have you considered using an actual database, like SQLite? When you get to wanting to have multiple indexes for elements and 10+million, that's generally the kind of thing you're looking for.
If an SQL-based database isn't useable, then you could use a non-SQL-based database. It's not the particular database that matters; just that you're using a database of some form.
Upvotes: 0