File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Handling Deleted Records

 
Anton Golovin
Ranch Hand
Posts: 476
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, guys. I was wondering if anyone knows of a good, efficient way to handle deleted records. It's the only thing I honestly cannot come up with a good solution for. It breaks the uncoupling of my code completely, because to reuse deleted records, I would have to make details of my io code available to higher-level code, instead of keeping the details hidden.

Does anyone have any advice?

Thanks!
 
mike acre
Ranch Hand
Posts: 197
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anton,

I think you had a similar backend strategy to myself.

My Data class is the highest level of my .db package, I think that is what everyone has.

Below that the data handling classes implement a DataAccess interface. This interface specifies an isDeleted(int recNo) method. But Data never needs to call it.

Both classes that implement that interface implement that method in different ways, DataCache asks a Set that tracks deleted records if it contains the requested record. DataFile (RAFwrapper) seeks to the requested row and reads the flag.

The highest use of this method is within DataCache when it builds the cache of deleted records.

My Data class, does little more than proxy for DataCache, apart from the addition of find and locking functionality.

HTH
 
Anton Golovin
Ranch Hand
Posts: 476
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got some major re-thinking going about the schematics. I am implementing a DBRecord class for every record, to be kept in a DBCache. Before, I just could not figure out how to handle record numbers in the context where some records are deleted. So my schematic now looks the following:

Data (the data-access class)
contains
> DBCache (the cached data)
>> contains DBRecord
> DBRecordManager (the record manipulating class)
contains
>> DBSchema (the data-file schema)
>> DBIOManager (the IO class)
makes
>> DBRecord (the logical representation of a record)
> DBLockManager (the lock-manager class)


and exceptions, etc...

I also have a DBUtilities class to take care of conversions, etc. I am not implementing a DataAccess interface, although it is a great idea to "synchronize" different ways of getting at data.

I am sure of everything except the memory requirements of DBRecord.

Perhaps it's doing more than necessary...
[ August 16, 2004: Message edited by: Anton Golovin ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic