• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

End of the Data file

 
sree visu
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ranchers,
I am working on B&S assignment.I understood the file format and i have printed the start of the file and the schema description and also the first record.But how do I know in advance how many records are there in the file.Thanks for your reply and your time
 
Alecsandru Cocarla
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can apply an algorithm like the following:



But you won't be able to know how many valid/deleted records you have in that file, only the total number of records.
 
sree visu
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Alecsandru Cocarla for your reply
 
mohamed sulibi
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi;

how do I know in advance how many records are there in the file.


simply,
- read the start of data section or the location of first record in the database and put it in dbStart integer variable.
- read the length of the hole file and put it in dbFileLength integer variable.
- In advance you know the size of the one record. as you calculate this size during the looping on the fields name and size of each field, so put the size of one record in recordSize integer variable.
- So numOfRecordInDB = (dbFileLength - dbStart) / recordSize; .......... ;-)


best regards.
Mohamed Sulibi.
 
Carlos Lacerda
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sree,

see this post: http://www.coderanch.com/t/424600/Developer-Certification-SCJD/start-position-of-data-db

 
sree visu
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you
Carlos Lacerda and mohamed sulibi for your reply
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic