4
votes

Is it possible with java that a hashtable can map the same keys to different values? .. How can I retrieve both value from hashtable...

2
Got Similar error when using TF 1 tf.contrib.lookup.index_table_from_file(vocabulary_file="vocab_file.txt"). Error was FailedPreconditionError: HashTable has different value for same key. The issue was input Vocab_file.txt had duplicate data. - sakeesh

2 Answers

8
votes

you cannot, unless you store the key's value as a list of values.

take a look at google's Multimap: http://google-collections.googlecode.com/svn/trunk/javadoc/index.html?com/google/common/collect/Multimap.html

1
votes

You cant do that, All the keys in the Hash map or Hash Table should be unique.

Else then you need to consider a different Collection