Reuse Deleted Blocks

Here are some observations about the new Strategy for Reuse Deleted Blocks

The Original post at sourceforge

At present, ODB doesn't seem to recover or reuse the space used by "deleted" objects, without manually invoking defragmentTo() or doing an XML export/import. When writing new entities, the ODB engine ought to look for
deleted blocks large enough to hold the entity before appending to the data file. This might help mitigate the 2GB issue, and make the need for expensive calls to defragmentTo() less frequent.

Some issues to think about:

  • The delete should organize the information on a list in a fast way
  • The delete should search the correct/better position in a fast way
  • The delete should be an expert to know identify when it is marking objects that are "neighbor", optimizing space to the insert and update

Important classes to look at:

ObjectWriter

  • protected int markAsDeleted(long currentPosition, OID oid, boolean writeInTransaction) throws IOException
  • protected void storeFreeSpace(long currentPosition, int blockSize)

Things to check/define:

  • Check if block size of an object can be computed before storing the object. Because this size will be used to search for available (deleted) spaces
  • What is the best/fastest way to store/search information about the deleted blocks.

Unit Tests for this feature

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License