Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Performance and the fly likes HashTable - performance issue for millions of values stored Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "HashTable - performance issue for millions of values stored" Watch "HashTable - performance issue for millions of values stored" New topic
Author

HashTable - performance issue for millions of values stored

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1371
a). I choose HashTable to store millions of quantity values from DB. Key is String and value is float. I choose HashTable than HashMap for not storing null values in key and value. So i have to compromise retrieval speed. I am not assigned initial capacity and load factor for Hashtable. Hence hash table grows double. Is it right approach for good performance?

b). If i do not implement equals() and hashCode() for the HashTable, may i get wrong values for the particular key?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41089
    
  44
I choose HashTable than HashMap for not storing null values in key and value.

This doesn't sound like a good reason to prefer Hashtable over HashMap. If the map is not supposed to contain null keys or values, then that's a rule that should be enforced (and handled) by the application code.

If i do not implement equals() and hashCode() for the HashTable, may i get wrong values for the particular key?

I'm confused. You said the keys are String objects (a class which implements these methods), so where do you see a potential problem?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12760
    
    5
Using the automatic size increase in HashTable will cause a real performance hit as the size grows. I would certainly try for an initial size which is sufficient. I dont think you are going to get "millions" of Strings and Float objects in any reasonable memory.

Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HashTable - performance issue for millions of values stored
 
Similar Threads
Question about clone a Hashtable
How to merge two hashtables elements in another hashtable?
basic difference HashMap & HashTable
Is Hashtable deprecating?
plz explain the difference........