UltraLite Static Java User's Guide
Adding Non Data Access Features to UltraLite Applications
Configuring and managing database storage
The UltraLite store is designed to efficiently reuse free space, so explicit defragmentation is not required under normal circumstances. This section describes a technique to explicitly defragment UltraLite databases, for use by applications with extremely strict space requirements.
UltraLite provides a defragmentation step function, which defragments a small part of the database. To defragment the entire database at once, call the defragmentation step function in a loop until it returns ul_true. This can be an expensive operation, and SQLCODE must also be checked to detect errors (an error here usually indicates a file I/O error).
Explicit defragmentation occurs incrementally under application control during idle time. Each step is a small operation.
For more information, see Class JdbcDefragIterator.
To defragment an UltraLite database
Cast a Connection to a JdbcConnection object. For example,
... Connection conn = db.connect(); JdbcConnection jconn = (JdbcConnection)conn ;
UltraLite provides a defragmentation step function, which defragments a small part of the database. To defragment the entire database at once, call the defragmentation step function in a loop until it returns ul_true. This can be an expensive operation, and SQLCODE must also be checked to detect errors (an error here usually indicates a file I/O error).
Call getDefragIterator() to obtain a JdbcDefragIterator object. For example:
JdbcDefragIterator defrag = jconn.getDefragIterator();
During idle time, call ulStoreDefragStep() to defragment a piece of the database.
defrag.ulStoreDefragStep();