Fastest and most efficient way of searching a key-value pair in Java?

0 votes
asked Jun 18, 2010 by mohit-deshpande

This question was not meant to be argumentative!

What is fastest and less memory draining way of searching a key-value pair? I will be storing items in a key-value like relation and I need to access them quickly. Should I use a SQLite database? A Map? A Hashtable? A HashMap? Please give some advantages/disadvantages of using whatever method of searching.

1 Answer

0 votes
answered Jun 18, 2010 by esko

Any hash-based Map structure is the way to go as long as your hash function for the key is efficient. You can use value id:s as the result for the lookup to conserve memory during search.

If your data is already in database though, you can leave this search entirely to the RDBMS, after all they're made for this stuff.

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter