ozone API

org.ozoneDB.DxLib
Class DxDiskHashMap

java.lang.Object
  |
  +--org.ozoneDB.DxLib.DxObject
        |
        +--org.ozoneDB.DxLib.DxAbstractCollection
              |
              +--org.ozoneDB.DxLib.DxAbstractMap
                    |
                    +--org.ozoneDB.DxLib.DxDiskHashMap
All Implemented Interfaces:
java.lang.Cloneable, DxCollection, DxCompatible, DxMap, java.io.Externalizable, java.io.Serializable

public class DxDiskHashMap
extends DxAbstractMap

Version:
$Revision: 1.3 $Date: 2002/06/08 00:49:38 $
Author:
SMB
, Medium.net
See Also:
Serialized Form

Field Summary
 int bufferAccesses
           
 int bufferHits
           
 int cacheAccesses
           
 int cacheHits
           
static java.lang.String ROOT_TABLE_NAME
           
 int tableBitSize
           
 
Constructor Summary
DxDiskHashMap(java.lang.String _baseFileName, int _maxBufferSize, int _cacheBits, int _tableBitSize)
           
 
Method Summary
 boolean addForKey(java.lang.Object obj, java.lang.Object key)
           
 void cleanFiles()
          Delete all the files used by this hashtable.
 void clear()
           
 java.lang.Object clone()
          liefert eine kopie des objektes; sollte von subclasses ueberschrieben werden;
 void close()
          Close this hash map.
 boolean containsKey(java.lang.Object key)
           
 int count()
           
 void deleteRequest(DxDiskSubTable subTable)
          The specified sub-table was deleted from the tree.
 java.lang.Object elementForKey(java.lang.Object key)
          Gives the element for the specified key.
 java.io.File getFileForFilename(java.lang.String filename)
          Computes a File object which represents the DxDiskSubTable file denoted by the given filename.
 boolean isDirtyTable(DxDiskSubTable table)
           
 boolean isEmpty()
           
 DxIterator iterator()
           
 java.lang.Object keyForElement(java.lang.Object obj)
          Returns the key for the given object, which has to be the same object as stored in the map.
 DxKeyData newKeyData()
           
 DxDiskHashNodeBranch newNodeBranch()
           
 DxDiskHashNodeLeaf newNodeLeaf()
           
 java.io.File newSubTableFile()
          This method is synchronized because sub table filenames have to be unique.
 void printStatistics()
           
 void re_use()
          Reuse an existing table from disk.
 boolean remove(java.lang.Object obj)
          Remove the first occurence of an object that equals the the specified object.
 java.lang.Object removeForKey(java.lang.Object key)
           
 DxDiskSubTable rootTable()
           
 void setReusable(boolean flag)
           
 void writeAllTables()
           
 
Methods inherited from class org.ozoneDB.DxLib.DxAbstractMap
add, addAll, buildKey, clone, elementSet, equals, keySet, readExternal, removeAllKeys, valueClone, writeExternal
 
Methods inherited from class org.ozoneDB.DxLib.DxAbstractCollection
addAll, clone, contains, containsAll, removeAll, toArray
 
Methods inherited from class org.ozoneDB.DxLib.DxObject
isLess
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.ozoneDB.DxLib.DxCollection
addAll, contains, containsAll, removeAll, toArray
 
Methods inherited from interface org.ozoneDB.DxLib.DxCompatible
isLess
 

Field Detail

ROOT_TABLE_NAME

public static final java.lang.String ROOT_TABLE_NAME
See Also:
Constant Field Values

bufferAccesses

public int bufferAccesses

bufferHits

public int bufferHits

cacheAccesses

public int cacheAccesses

cacheHits

public int cacheHits

tableBitSize

public int tableBitSize
Constructor Detail

DxDiskHashMap

public DxDiskHashMap(java.lang.String _baseFileName,
                     int _maxBufferSize,
                     int _cacheBits,
                     int _tableBitSize)
Method Detail

clear

public void clear()

rootTable

public DxDiskSubTable rootTable()

newNodeLeaf

public DxDiskHashNodeLeaf newNodeLeaf()

newNodeBranch

public DxDiskHashNodeBranch newNodeBranch()

newKeyData

public DxKeyData newKeyData()

isDirtyTable

public boolean isDirtyTable(DxDiskSubTable table)

re_use

public void re_use()
            throws java.lang.Exception
Reuse an existing table from disk. To do so a previously created table has to be correctly closed. Once a hash map has been re-used it has to closed before opening again.

java.lang.Exception

close

public void close()
           throws java.lang.Exception
Close this hash map. Write all changed tables to the disk. Store also all information that are needed to re-initialize this object from the disk data.

java.lang.Exception

setReusable

public void setReusable(boolean flag)
                 throws java.io.IOException
java.io.IOException

clone

public java.lang.Object clone()
Description copied from class: DxObject
liefert eine kopie des objektes; sollte von subclasses ueberschrieben werden;

Specified by:
clone in interface DxCollection
Overrides:
clone in class DxObject

printStatistics

public void printStatistics()

deleteRequest

public void deleteRequest(DxDiskSubTable subTable)
The specified sub-table was deleted from the tree. So we have to delete it from the table buffer too.


newSubTableFile

public java.io.File newSubTableFile()
This method is synchronized because sub table filenames have to be unique.


getFileForFilename

public java.io.File getFileForFilename(java.lang.String filename)
Computes a File object which represents the DxDiskSubTable file denoted by the given filename.
There are two formats for the given filename:
  • The long format is a pathname relative to the current working directory of the Java application which wrote the table referring the DxDiskSubTable in question. It may also be an absolute pathname. This format is error prone as it does not allow changing the working directory of Java applications or changing the location of the table files within the filesystem. That's why the short format is used now.
  • The short format is only the last pathname component of the pathname to the referred DxDiskSubTable file. The other pathname components (e.g. the directory where the DxDiskSubTable file resides) are determined by the directory where the root table resides. This is possible because als DxDiskSubTable files reside in the same directory as the root table file does.
For compatibility with old tables, the long format is broken up into pathname components and only the last pathname component is used then as a directory entry of the directory of the root table file.


cleanFiles

public void cleanFiles()
Delete all the files used by this hashtable.


writeAllTables

public void writeAllTables()
                    throws java.lang.Exception
java.lang.Exception

addForKey

public boolean addForKey(java.lang.Object obj,
                         java.lang.Object key)

elementForKey

public java.lang.Object elementForKey(java.lang.Object key)
Gives the element for the specified key.

Note: This method is synchronized because the cache of subtables may change.


keyForElement

public java.lang.Object keyForElement(java.lang.Object obj)
Description copied from interface: DxMap
Returns the key for the given object, which has to be the same object as stored in the map.


remove

public boolean remove(java.lang.Object obj)
Description copied from class: DxAbstractCollection
Remove the first occurence of an object that equals the the specified object.

Specified by:
remove in interface DxCollection
Overrides:
remove in class DxAbstractCollection

removeForKey

public java.lang.Object removeForKey(java.lang.Object key)

iterator

public DxIterator iterator()

count

public int count()

isEmpty

public boolean isEmpty()

containsKey

public boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface DxMap
Overrides:
containsKey in class DxAbstractMap

ozone API

Copyright (C) The Ozone Database Project - www.ozone-db.org. All rights reserved.