Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

UrlyBird data file header access frequency

 
Bartender
Posts: 3648
16
Mac OS X Firefox Browser 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.
 
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.
 
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)
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • 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)
 
Those who dance are thought mad by those who hear not the music. This tiny ad plays the bagpipes:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic