I am trying to write a code for a custom hashmap (array of linked lists) which can store 500 millions of values (keys are linked list array number) and can save the index to the disk. The code is following:
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is how I would implement it
Note: there is no additional step to load or save the data. This means when you return from
put(key, value)the data is saved even if you program crashes (assuming your OS doesn’t crash)This adds 500m entries. run with
-ea -verbosegc -mx16mThat’s a maximum heap of 16 MB.Note: it only GCed because I called
System.gc();and look at the size of the heap used!I would use a
int[]instead of a linked list of nodes.