lookup table or hash table - Best approach

Hi All,

   I have a name value pair list of 40,000 items. I pass in a name and get its corresponding value. The issue is:

   What is the best approach to go with (lookup table/hash table/DB table) or is there a better way ?

My approach as of now is to have a config file, load it into memory when package loads. Convert it to a string table and pass it as input to lookup service. Any help would be appreciated.

Thank you
Dave

For best performance, i’d think a hashMap/hashTable will be the choice, if the name/value pairs are not too big.
Just write a few lines of java code for definition and getting method.
You just initiallize it at loading and create get service to retrieve the value by name. At lease you don’t need to loop it through every time.

Take a look at memory requirements of your current approach: i believe webMethods IData structures use up a significant multiple (2x, 5x, 10x?) of the memory required by ‘bare’ Java data structures - though the WM string table implementation may be particularly efficient.

My natural tendency with this number of records is to take the DB table approach, especially if the data changes a fair bit.

It all depends on your needs. What’s more important to you? Speed? Memory footprint?

If you’re already using JDBC adapters elsewhere in your project, it seems like a no-brainer to use a DB table. Since the data is pretty static, enable cacheing for the service.

If you want to roll your own Java service, have your class initialise a static TreeMap (or hashmap if your objects aren’t Comparable), and make a getter method that reads from it.

Hello, do not use lookupTable service. The implementation uses a 2-D String array which is not efficient (of course java string operations sucks). Its better to go for DB table as the data volume is more. Or else a hashmap will do good.

Cheers
Guna

I am interested to hear from the Veterans - RMG, reamon… ?