Dictionary: hard-coded vs. external file

I have a java application which is started and stopped multiple times per second over hundreds of millions of items (called from an external script).

Input: String key
Output: int value

The purpose of this application is to look for a certain key in a never ever ever changing Map (~30k keys) and to return the value. Very easy.

Question: what is more efficient when used multiple times per second:

  1. hard-coded dictionary in a Map
  2. Read an external file with a BufferedReader
  3. ...amaze me with your other ideas

I know hard-coding is evil but sometimes, you need to be evil to be efficient :-)

Answers


Read in the dictionary from file. Store it in a Map. Set up your Java application as a service that runs continuously (since you said it gets called many times per second). Then your Map will be cached in RAM.


Need Your Help

What is the inner difference between (MyType)SomeObj.Property1 and (MyType)(SomeObj.Property1) in C#?

c# syntax properties

It's probably very lame question, but I found no references in C# specification about round brackets. Please point me to spec or msdn if answer on that question will be obvious.

WinSock2 Error 10093 on recv

windows multithreading sockets winsock2

So I'm building a multithreaded socket library in windows and I'm getting the WSA Not Started error when I call recv, even though I successfully get a client to connect to the server. I also had it

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.