Link to home
Start Free TrialLog in
Avatar of wsyy
wsyy

asked on

How to make a very big dictionary available to every program?

Hi,

I need to use Java load a very big dictionary (tens of thousands of words) into some Java data type, and likely load it into memory so that all programs (some are web applications and the other are just back-end programs) can easily access to the dictionary.

One example is that when users input some keywords into an Input box on the web page, our program can use the dictionary to check if some keywords are spelled wrong and if some keywords are the most frequently used keywords.

The way that I am thinking of is to use hashset and load the dictionary into the hashset object. But how to make the object loaded once and how to make it available to all the other programs seem to be a challenge to me. Please help.

Thanks
SOLUTION
Avatar of mwochnick
mwochnick
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CEHJ
I would make the resource available via JNDI. It can then be used by java apps and java web apps alike
Avatar of wsyy
wsyy

ASKER

Thanks for replies.

CEHJ, could you please be specific about how to make JNDI work in my case? To my understanding JNDI is widely used in connection pool. Then how can this work in the dictionary which I assume that an hashset object is used?

mwochnick, I think singleton is an alternative whose purpose is to make a single dictionary available for all accesses. However, like accessing to a database connection, accessing to this singleton object may cause performance issue due to so many concurrent accesses in my case.

Now is it possible to combine the singleton solution and the JNDI solution?

>>To my understanding JNDI is widely used in connection pool. Then how can this work in the dictionary which I assume that an hashset object is used?

You can make any type of object available with JNDI. See the tutorial. This example uses a Hashtable, but HashSet would be exactly the same:

http://download.oracle.com/javase/jndi/tutorial/getStarted/examples/naming.html
Avatar of wsyy

ASKER

CEHJ, can I combined JNDI and singleton togather? Seem like each has unique, useful features.
If you use JNDI, it will automatically be a singleton - it's just ONE resource
Avatar of wsyy

ASKER

Is it loaded into memory at the very beginning?

If not, how is the performance of using JNDI compared with using something else that can be loaded into memory?

Sorry these questions just comes to my mind?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wsyy

ASKER

gordon_vt02: thanks a lot for such detailed suggestions.

The dictionary is most likely read only, and shared by both web services as well as back-end programs. For that case, will JNDI be a better way since non-web programs are using it too.

I have one additional questions forgive me:

1) How JNDI be accessible to web services and back-end programs at the same time? Do you know some posts that are helpful?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wsyy

ASKER

Excellent
:)