I'm not sure I understand your question. Perhaps this might help?
Example: You have 6 records in your database and at this precise moment records 2 and 4 are locked. You need a way to associate the record number with the locking Client (Map) or you ignore who is locking the record and just store the locked records (Set).
I'll try and draw it diagramatically as a picture saves a thousand words..
Richard, This subject have been discussed many times in this forum. In general, there are two different methodlogy on how to read the db file.
The first method is to read the db file once, and then store all the information in a collection, so that all record will be available in memory. Of course, you have to make sure that it is in sync with the actual db file.
The second method is to leave everything in the db file, and access the file as needed. Similare to RDB access.
Both methods has its advantage and disadvantage. When the data is in memeory, you will have light speed performance. However, this approach in not scalable. If the data in the db file is too larg, the program will run out of memory. Also, you have to implement a good synchronizaiton technique to make sure that the data in memory is the same as in the db file.
When you access the db file on demand, i.e. search, update, delete, you have slower performance- not noticable for this project. However, this approach is more scalable, because one is not bound with the size of the db file.
YOu have to choose which method you are more comfortable with, because you have to explain it in you choice document.
SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
My friend said that he used StringBuffer to store records and return them in readRecords() method.And he used HashMap to store lock synchoronized records.
I am always confused about that. Would please give me some methods to clarify that?
[B]Hanna[B/] :-) The first method is to read the db file once, and then store all the information in a collection, so that all record will be available in memory. ... :-) The second method is to leave everything in the db file, and access the file as needed. Similare to RDB access.
As you said,I want to select the first method to access the records into that .db file. So I am correct if I select Map to store them?
Joined: Aug 20, 2003
Richard, I cannot tell you what did your friend do about using StringBuffer. Maybe he used different methodology.
Using a Map to store the data should be fine. Any collection should do as far as you know the limitation of each type of collection. If you are going with that approach, you should consider using value objects to represents each record.
Personally, I prefere the second approach-accessing the db file on demand. It is what I did in my project, but there were big debate about that, and many people prefere the first approach.