package org.apache.jdbm; import java.util.*; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentNavigableMap; /** * Database is root class for creating and loading persistent collections. It also contains * transaction operations. * //TODO just write some readme *
* * @author Jan Kotek * @author Alex Boisvert * @author Cees de Groot */ public interface DB { /** * Closes the DB and release resources. * DB can not be used after it was closed */ void close(); /** @return true if db was already closed */ boolean isClosed(); /** * Clear cache and remove all entries it contains. * This may be useful for some Garbage Collection when reference cache is used. */ void clearCache(); /** * Defragments storage so it consumes less space. * It basically copyes all records into different store and then renames it, replacing original store. * * Defrag has two steps: In first collections are rearranged, so records in collection are close to each other, * and read speed is improved. In second step all records are sequentially transferred, reclaiming all unused space. * First step is optinal and may slow down defragmentation significantly as ut requires many random-access reads. * Second step reads and writes data sequentially and is very fast, comparable to copying files to new location. * * * This commits any uncommited data. Defrag also requires free space, as store is basically recreated at new location. * * @param sortCollections if collection records should be rearranged during defragment, this takes some extra time */ void defrag(boolean sortCollections); /** * Commit (make persistent) all changes since beginning of transaction. * JDBM supports only single transaction. */ void commit(); /** * Rollback (cancel) all changes since beginning of transaction. * JDBM supports only single transaction. * This operations affects all maps created or loaded by this DB. */ void rollback(); /** * This calculates some database statistics such as collection sizes and record distributions. * Can be useful for performance optimalisations and trouble shuting. * This method can run for very long time. * * @return statistics contained in string */ String calculateStatistics(); /** * Copy database content into ZIP file * @param zipFile */ void copyToZip(String zipFile); /** * Get aMap
which was already created and saved in DB.
* This map uses disk based H*Tree and should have similar performance
* as HashMap
.
*
* @param name of hash map
*
* @return map
*/