This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
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 Introducing JavaFX 8 Programming this week in the JavaFX 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: 1399
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
Rancher

Joined: Mar 22, 2005
Posts: 42958
    
  73
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: 13018
    
    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
 
It's not a secret anymore!