Search efficiency problem
I have to search for a particular String from a large number of String(Number of Strings may go in thousands or lakhs.).So I decide to use a HashMap for storing the Strings, which would be fast because of Hashing. For few thousand records, this technique works very good. But when the number of records goes in lakhs it really takes a lot of time to add and get a record.
Is there any way using which I can arrange my data in a better way which would reduce search time?
Problem can be:
1) implementation -When colections contain huge amount of data, operations as size( ), remove( ) ... etc are VERY slow. Try to implement your own class.
But I DON'T think,that this is your problem
2) Take closer look on your hashing function. Does disperse your strings properly?
How full is your table? If over cca 80%, problem can be there.
When collision occure, hashMap will start linear search from that place. Keep it in your mind.
3) you can use array of HashMap e.g. first letter will be index
(or other way. Split it to as many tables, as you know, it will be enough fast)
P.S.: I hope you will perform search repeatively on your datas