• 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

UrlyBird with data file record deletions

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't understand why a 00 at the beginning of a record means the record is not deleted, but a 0x8000 means the record is deleted. Hey, either you delete a record, in which case the data file gets shortened. The record NO longer exists, or the record is NOT deleted, it exists.

Any explanations?

2 byte flag. 00 implies valid record, 0x8000 implies deleted record
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You would not want to shorten the file, there are no primary keys so you have to use a logical pk (the record number), if someone has a record they are working on (lets say recno 75) and you delete 74 and shorten the file, the user in now on (old 76), also it is specified that you need to check for deleted records when adding, and if found, recycle it, also it would mess up the locking scheme, how would the program know which physical row they were on if someone else is shortening the file? All xBase like languages use a delete flag and delete filter, they also use a header that describes the field layout. I'm sure Sun didn't want to have to grade this exam if people were using an RDBMS, so they when to an old tried and true paradigm.

Tom
 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi...
Your question is interesting, shortening the file may cause successive data access calls to corrupt the file. But, what if we reconfigure the file at startup? we could scan the file for deleted entries, then physically delete them and ADJUST THE FILE HEADER ACCORDINGLY?
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do it as following:


I think a deleted flag always holds 2 bytes.
 
Look! It's Leonardo da Vinci! And he brought a 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