• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

UrlyBird data file header access frequency

 
K. Tsang
Bartender
Posts: 3583
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, about the magic cookie value at the beginning of the data file, does every method (read, update, delete etc) need to check this value? Similarly does every method need to read the file header (cookie value + field name length, field names etc)? Or can I just check it once every time a client connects?

I asked this because if I don't need to check every time, I technically read it once, store the needed values into instance vars and directly jump to the particular record using the instance vars values in subsequent read, update etc.
 
christian combarel
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I just parse once the file header. I do that when constructing the database management system. At this moment, I also check that the cookie value is matching the one I have hard-coded.
 
Jeffry Kristianto Yanuar
Ranch Hand
Posts: 759
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just checked once the file is being opened. Checking the magic cookie every time we access the database is not practical and can reduce the performance and (perhaps) your score.


Jeffry Kristianto Yanuar (Java Instructor) SCJP 5.0, SCJA, SCJD (UrlyBird 1.3.2)
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my case, when the application starts, I load all records to the memory. So I check this value two times: when the application starts, and when the application finishes (if the valid file was exchanged by a non-valid file, the records aren't persisted back).
 
Jeffry Kristianto Yanuar
Ranch Hand
Posts: 759
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Roberto Perillo:
In my case, when the application starts, I load all records to the memory. So I check this value two times: when the application starts, and when the application finishes (if the valid file was exchanged by a non-valid file, the records aren't persisted back).


In my case, I didn't load all the records, I just used a particular formula to go to the particular record number.

Whatever your choice, just document it along with your reason.


Jeffry Kristianto Yanuar (Java Instructor) SCJP 5.0, SCJA, SCJD (UrlyBird 1.3.2)
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic