Here is my situation. I have a table with below data.
Property_name Property_value
--------------------------------------
prob_name_1 ,sdfsdf@ce.o,jfgj@ce.o,
prob_name_2 ,sdfsf@ce.o,dsf@ce.o,
prob_name_3 ,sdfsfss@ce.o,sdfsdf@ce.o,
. .
. .
. .
prob_name_n ,sdfsfss@ce.o,sdfsdf@ce.o,
There can be many rows in this table and emails will be stored as comma separated. Property_value will hold data update its maximum (2k). I don’t have “n” in last property and I need to find if required.
My Query is,
I need to search for an email in this data. As we use memcache tool to cache this data (It is stored in Hashtable<String, String>), we don’t use queries. I have few ideas. Please suggest me a better one.
- HashMap – key pair value of property_name and property value. Iterate it and check value until it is found.
- Iterate all rows and search until it is found.
Since e-mail addreses are not numericly orderable, your second option will be the way to go. If what you are saying is that you need to find the property_name to a given property_value, that is.
If your list was orderable in any way, you could use the binary search method. However, the only way to order your e-mail addreses would be alphabetical, and I think that will take even longer.