Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

UrlyBird data file header access frequency

 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 759
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
reply
    Bookmark Topic Watch Topic
  • New Topic