• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

About Interpreting data format of DB file

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,
I am confused about DB.DB file data format. Actually, I can�t interpret it correctly.
My DB.DB file format is as follows
Start of the file
Magic cookie (4 byte)
Record length (4 byte)
Number of fields (2 byte)
I understand this portion, but following is confusing me:
Scheme Description Section
Repeated for each field in record:
2 byte numeric, length in byte of field name
n bytes (defined by previous entry),filed name
2 byte numeric, field length in bytes
end of repeating block.

My problem is that I don�t understand what these two refers
1) n bytes (defined by previous entry),filed name
2) 2 byte numeric, field length in bytes
 
Ranch Hand
Posts: 493
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Manoj,
Welcome to JavaRanch. You wrote:


I understand this portion, but following is confusing me:
Scheme Description Section
Repeated for each field in record:
2 byte numeric, length in byte of field name
n bytes (defined by previous entry),filed name
2 byte numeric, field length in bytes
end of repeating block.

My problem is that I don�t understand what these two refers
1) n bytes (defined by previous entry),filed name
2) 2 byte numeric, field length in bytes


I am not sure which assignment are you doing. I am doing URLy Bird 1.3.1. What I am about to explain to you works well for me. It should apply to your assignment as well.
1) 2 byte numeric, length in byte of field name - The first field in my file is called "name" as shown in my instructions. If you read the two bytes field as a "int" numeric, it should give you a value of 4 since name is 4 bytes long.
2) n bytes (defined by previous entry),filed name - Based on the fact the value just read is 4 bytes long, you read the next four bytes, but this time using another method which will read it as ASCII bytes but not a numeric. This should give you the value as "name". Here n = 4.
3) 2 byte numeric, field length in bytes - The next two bytes you should read as "int" using an appropriate method. In my assignment the name field is defined as 64 US-ASCII bytes wide. When you print the value that you have read here, it should yeild 64.
Doe it help?
Regards.
Bharat
 
Manoj Dixit
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thnks Bharat,
What a great explanation.
Thanks once again.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic