• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

delete record

 
James Clarke
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

The interface we have to implement for URLYBird has this method:

// Deletes a record, making the record number and associated disk
// storage available for reuse.
// Throws SecurityException if the record is locked with a cookie
// other than lockCookie.
public void deleteRecord(long recNo, long lockCookie)
throws RecordNotFoundException, SecurityException;

My interpretation of "making the associated disk storage available for reuse" is that the data has to be completely removed from the file and all records below have to be moved up to take up the space. Is this correct?

Also is anyone aware of any standard method of doing this in the file(im using randomaccessfile)? Also im using the hashcode of the object for the cookie, would there be any issue with this?

thanks,

J.C
 
Herman Schelti
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi James,

I'm only UrlyBird as well.
You just have to set the 'deleted' flag, you don't have to remove anything.

The create method could reuse this record, but you can also add the new records at the end of file. (that's what I choose, recNo 10 remains number 10)


Herman
 
James Clarke
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Herman,

"You just have to set the 'deleted' flag, you don't have to remove anything."

Well this doesn't free up disk space(the record data is still in file), as specified in the comments in the interface:

"Deletes a record, making the record number and associated disk storage available for reuse."

Also if the record numbers remain the same, when you display the results to the client you have to check which records are current(not deleted) and modify the record numbers accordingly. And when a user specifies a record number for deletion/modification, you again have to go through the process of finding the right record number.

Any suggestions on the above?

J.C
 
Huan Niu
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi James,

I agree with Herman.

The requirement says "Deletes a record, making the record number and associated disk storage available for reuse", which doesn't mean you will free up disk space, and just reuse the deleted records.

In this case, before every operation (update, delete ...), I always check if records are deleted or not.

I'm working on UrlyBird as well.

Hope this will help.

Huan
[ November 07, 2007: Message edited by: Huan Niu ]
 
Peter Hat
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Deletes a record, making the record number and associated disk storage available for reuse."

If you just mark it as deleted, the disk space becomes available for reuse by your own program, but you're right that it's not available for other programs.

Just document how you interpret it and what you choose.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic