• 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

Delete Flag Empty -does this imply record valid?

 
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Background: At the moment I am implementing the 'find(cret)' method to build a list of records which match some criteria. This function invokes 'read(recNo)' to grab a record for some processing and catches any RecordNotFoundException's etc etc.

My Assignment:In my assignment '1' indicates deleted, '0' indicates valid record.

Question:When I read in the 'delete byte' the value is empty. Can I safely assume 'empty' implies record is valid, or do I have a bug to sort out? (I was expecting '0').



Thanks.
 
James Clinton
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
corrupt?

I'm not so sure because all the other details are read OK, theres a total of approx 29/30 records.

Anton, did you have the same assignment as mine?


URLyBird
Data file Format
The format of data in the database file is as follows:

Start of file
4 byte numeric, magic cookie value. Identifies this as a data file
4 byte numeric, total overall length in bytes of each record
2 byte numeric, number of fields in each record

Schema description section.
Repeated for each field in a record:
2 byte numeric, length in bytes of field name
n bytes (defined by previous entry), field name
2 byte numeric, field length in bytes
end of repeating block

Data section.
Repeat to end of file:
1 byte "deleted" flag. 0 implies valid record, 1 implies deleted record
Record containing fields in order specified in schema section, no separators between fields, each field fixed length at maximum specified in schema information

End of file



James
[ November 26, 2004: Message edited by: James Clinton ]
 
Ranch Hand
Posts: 531
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, James! Thanks for posting the code. This makes things easier. When a byte has the value -1, the String constructor does not know how to convert it. There is no error. Try the following:



If it is -1 or 0, it is ok.
[ November 26, 2004: Message edited by: Anton Golovin ]
 
He puts the "turd" in "saturday". Speaking of which, have you smelled this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic