• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ReadRecord

 
subu ananthram
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I startup I read all the records in my flatfile and maintain them in a map with the record number and string[] representation of the file.
Now when I read I shoudl just need to look at this map since whenever I update /or create I anyways update this map ?
Cheers
Subu
 
Jeffry Kristianto Yanuar
Ranch Hand
Posts: 759
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your approach is good, but I have another approach.

If I want to retrieve a record at a certain record number, I just need to calculate the position of the file based on the record number and start retrieving it. the same approach is same for the other database manipulation.

Jeffry Kristianto Yanuar
Java Instructor
SCJP 5.0
SCJA
SCJD (Working on UrlyBird 1.3.2) --> testing and documenting the assignment
 
Thomas Thevis
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

as far as I can see by reading the threads in this forum your two approaches are the two which are mostly used for data handling. I think none is better than the other as long as you know the advantages and disadvantages of your choice and document them properly.

Let me ask you some questions on your design choices:
@Subu: What if the customer has a database which is a lot larger than the tiny sample database provided with your assignment? How do you ensure that user changes are persistet in the database file?
@Jeffry Kristianto Yanuar: Do you use a singleton database file access? If so, is it possible for different client to gain database access in parallel? If you use no singleton database file access: how do you ensure that differnet clients working on different records access the database in parallel whereas clients working on the same record wait for each other?

The last question is the one I'm mostly interested in, since that's the approach I'm planning to implement.

Best Regards,
Thomas
 
subu ananthram
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Subu: What if the customer has a database which is a lot larger than the tiny sample database provided with your assignment? How do you ensure that user changes are persistet in the database file?

Hi Thomas

I am making the assumption that my database cannot be too big (this is afterall a prototype)since if it were I cannot store in may map the record and its record number .But I see where your coming from I could just add that if my record is not in the map go to the db and add it to my map.But if my map goes to a certain (huge) size how does hashmap work when it becomes too big and you add another entry to it --it would be good if it use LRU(least recently used) and kick the entry that hasnt been accessed for a while??
Any comments
Cheers
Subu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic