I have 5 million key-value pairs. Kindly suggest a relevant data structure for storing such a huge data. What if my data can expand to 1 billion key-value pairs in future? Kindly suggest a data structure in Java which will accommodate this data.
I have 5 million key-value pairs. Kindly suggest a relevant data structure for storing
Share
You might want to use a TreeMap . To answer the question about doing this in memory, it cannot all be in memory at once (at least with todays standard technology on a desktop in 2011) you want to chunk in the data. Since the information is already sorted with a tree map you can effectively determine, using binary sort or one of its variants, where in the tree it falls. Trove will not fix an out of memory exception, that has to do with the JVM settings.