jdbm.htree
Class HashDirectory

java.lang.Object
  extended byjdbm.htree.HashNode
      extended byjdbm.htree.HashDirectory
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable

final class HashDirectory
extends HashNode
implements java.io.Externalizable

Hashtable directory page.

Version:
$Id: HashDirectory.java,v 1.4 2003/09/21 15:47:01 boisvert Exp $
Author:
Alex Boisvert

Nested Class Summary
 class HashDirectory.HDIterator
          Utility class to enumerate keys/values in a HTree
 
Field Summary
(package private) static int BIT_SIZE
          Number of significant bits per directory level.
(package private) static int MAX_CHILDREN
          Maximum number of children in a directory.
(package private) static int MAX_DEPTH
          Maximum number of levels (zero-based) (4 * 8 bits = 32 bits, which is the size of an "int", and as you know, hashcodes in Java are "ints")
(package private) static long serialVersionUID
           
 
Constructor Summary
  HashDirectory()
          Public constructor used by serialization
(package private) HashDirectory(byte depth)
          Construct a HashDirectory
 
Method Summary
(package private)  java.lang.Object get(java.lang.Object key)
          Returns the value which is associated with the given key.
(package private)  long getRecid()
          Get the record identifier used to load this hashtable.
(package private)  int hashMask()
          Calculates the hashmask of this directory.
(package private)  boolean isEmpty()
          Returns whether or not this directory is empty.
(package private)  FastIterator keys()
          Returns an enumeration of the keys contained in this
(package private)  java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Associates the specified value with the specified key.
 void readExternal(java.io.ObjectInput in)
          Implement Externalizable interface
(package private)  java.lang.Object remove(java.lang.Object key)
          Remove the value which is associated with the given key.
(package private)  void setPersistenceContext(RecordManager recman, long recid)
          Sets persistence context.
(package private)  FastIterator values()
          Returns an enumeration of the values contained in this
 void writeExternal(java.io.ObjectOutput out)
          Implement Externalizable interface
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values

MAX_CHILDREN

static final int MAX_CHILDREN
Maximum number of children in a directory. (Must be a power of 2 -- if you update this value, you must also update BIT_SIZE and MAX_DEPTH.)

See Also:
Constant Field Values

BIT_SIZE

static final int BIT_SIZE
Number of significant bits per directory level.

See Also:
Constant Field Values

MAX_DEPTH

static final int MAX_DEPTH
Maximum number of levels (zero-based) (4 * 8 bits = 32 bits, which is the size of an "int", and as you know, hashcodes in Java are "ints")

See Also:
Constant Field Values
Constructor Detail

HashDirectory

public HashDirectory()
Public constructor used by serialization


HashDirectory

HashDirectory(byte depth)
Construct a HashDirectory

Method Detail

setPersistenceContext

void setPersistenceContext(RecordManager recman,
                           long recid)
Sets persistence context. This method must be called before any persistence-related operation.


getRecid

long getRecid()
Get the record identifier used to load this hashtable.


isEmpty

boolean isEmpty()
Returns whether or not this directory is empty. A directory is empty when it no longer contains buckets or sub-directories.


get

java.lang.Object get(java.lang.Object key)
               throws java.io.IOException
Returns the value which is associated with the given key. Returns null if there is not association for this key.

Throws:
java.io.IOException

put

java.lang.Object put(java.lang.Object key,
                     java.lang.Object value)
               throws java.io.IOException
Associates the specified value with the specified key.

Throws:
java.io.IOException

remove

java.lang.Object remove(java.lang.Object key)
                  throws java.io.IOException
Remove the value which is associated with the given key. If the key does not exist, this method simply ignores the operation.

Throws:
java.io.IOException

hashMask

int hashMask()
Calculates the hashmask of this directory. The hashmask is the bit mask applied to a hashcode to retain only bits that are relevant to this directory level.


keys

FastIterator keys()
            throws java.io.IOException
Returns an enumeration of the keys contained in this

Throws:
java.io.IOException

values

FastIterator values()
              throws java.io.IOException
Returns an enumeration of the values contained in this

Throws:
java.io.IOException

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Implement Externalizable interface

Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Implement Externalizable interface

Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException


Cees de Groot (C) 2000-2001. All rights reserved http://jdbm.sourceforge.net