I have an array of objects (say, images) that is too large to fit in memory (e.g. 40 GB). But my code should be able to randomly access these objects at runtime.
What is the best way to do this?
From my code point of view, of course, it does not matter if some of the data is on disk or temporarily stored in memory; It must have transparent access:
container.getObject(1242)->process(); container.getObject(479431)->process();
But how do I implement this container? Should it just send queries to the database? If so, which one would be the best option? (If the database, then it should be free and not too complicated administration, maybe Berkeley DB or sqlite?)
Should I just implement it myself, memoizing objects after acces of sand clearing memory when it is full? Or are there good libraries (C ++) for this?
The requirements for the container are that it minimizes access to the disk (some elements can be accessed most often by my code, so they should be stored in memory) and provides quick access.
UPDATE: I will find out that STXXL does not work for my problem, because the objects stored in the container have a dynamic size, that is, my code can update them (increase or decrease the size of some objects) at runtime. But STXXL cannot handle this:
STXXL containers assume that the data types that they store are plain old data types (PODs). http://algo2.iti.kit.edu/dementiev/stxxl/report/node8.html
Could you comment on other solutions? How about using a database? And which?
c ++ database memory data-structures random-access
Frank
source share