dcsimg
Question about indexing objects
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   George_Lin
Posted On:   Monday, March 21, 2005 06:53 PM

Hello everyone, I want to use indexing technology to speed up searching operation of my application. I have found that Java built-in type Hashtable can only have one key for each object. But my requirement is that an object can have multiple keys for an object. For example, the objects may be arranged in the following model, Object (key1, key2, value) and the related instances maybe John ("male", "single", ) Smith ("male", "married", ) When given key1 (or key2, or key1 and key2 altogether), I want to find out matched objects. For example, when given "male", John and Smith are both matched. When given "single", only Joh   More>>
			
Hello everyone,


I want to use indexing technology to speed up searching operation of my application. I have found that Java built-in type Hashtable can only have one key for each object. But my requirement is that an object can have multiple keys for an object. For example, the objects may be arranged in the following model,

Object (key1, key2, value)

and the related instances maybe

John ("male", "single", )
Smith ("male", "married", )

When given key1 (or key2, or key1 and key2 altogether), I want to find out matched objects. For example, when given "male", John and Smith are both matched. When given "single", only John is matched. When given "female" and "single", no records are matched.


Thanks in advance,
George
   <<Less

Re: Question about indexing objects

Posted By:   srini_vasan  
Posted On:   Wednesday, March 23, 2005 01:14 AM

usually when we are going to search something,we need a key which should be unique.
but in your case, keys are repeatble.


To solve your problem, you can store a values in following way

Hashtable ht=new Hashtable();

ht.put(new Hashtable(personal inforamtion about john,single)),married)




normally we should store any item in Hashtable in the format of (key,value) pair.
but in our case keys are "male","single" like that. they are rpeatable.



that's why in the above example, i reversly stored obj,key.

becoz,each object has one idetification mark to diffreretiate from others.



Finally you should collect values from Hashtable. and findout which are all the keys are "male" ,"female" etc.
after that You can have appropriate object corresponding to
what you search.



For example if you want to search "married" means
first collect the values and keys from hashtable as a collection objects.
findout which keys map to "married".
findout corresponding HashTable object.
after that you can easily find out "male" or "female" based on Hashtable object
that you have found in previous search.



and The better way is You can store your informations into DataBase.
and You can retrieve the information you want from
DataBase using JDBC

About | Sitemap | Contact