org.hsqldb.map
Class HashIndex
- java.lang.Object
-
- org.hsqldb.map.HashIndex
-
public class HashIndex extends java.lang.ObjectA chained bucket hash index implementation. hashTable and linkTable are arrays of signed integral types. This implementation uses int as the type but short or byte can be used for smaller index sizes (cardinality). hashTable[index] contains the pointer to the first node with (index == hash modulo hashTable.length) or -1 if there is no corresponding node. linkTable[{0,newNodePointer}] (the range between 0 and newNodePointer) contains either the pointer to the next node or -1 if there is no such node. reclaimedNodeIndex contains a pointer to an element of linkTable which is the first element in the list of reclaimed nodes (nodes no longer in index) or -1 if there is no such node. elemenet at and above linkTable[newNodePointer] have never been used as a node and their contents is not significant.- Since:
- 1.7.2
-
-
Constructor Summary
Constructors Constructor and Description HashIndex(int hashTableSize, int capacity, boolean fixedSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidclear()Reset the index as empty.intgetHashIndex(int hash)intgetLookup(int hash)Return the array index for a hash.intgetNextLookup(int lookup)This looks from a given node, so the parameter is always > -1.intlinkNode(int index, int lastLookup)Link a new node to the end of the linked for a hash index.booleanremoveEmptyNode(int lookup)Remove a node that has already been unlinked.voidreset(int hashTableSize, int capacity)Reset the structure with a new size as empty.voidresetTables()voidunlinkNode(int index, int lastLookup, int lookup)Unlink a node from a linked list and link into the reclaimed list.
-
-
-
Method Detail
-
reset
public void reset(int hashTableSize, int capacity)Reset the structure with a new size as empty.- Parameters:
hashTableSize-capacity-
-
resetTables
public void resetTables()
-
clear
public void clear()
Reset the index as empty.
-
getHashIndex
public int getHashIndex(int hash)
- Parameters:
hash-
-
getLookup
public int getLookup(int hash)
Return the array index for a hash.- Parameters:
hash- the hash value used for indexing- Returns:
- either -1 or the first node for this hash value
-
getNextLookup
public int getNextLookup(int lookup)
This looks from a given node, so the parameter is always > -1.- Parameters:
lookup- A valid node to look from- Returns:
- either -1 or the next node from this node
-
linkNode
public int linkNode(int index, int lastLookup)Link a new node to the end of the linked for a hash index.- Parameters:
index- an index into hashTablelastLookup- either -1 or the node to which the new node will be linked- Returns:
- the new node
-
unlinkNode
public void unlinkNode(int index, int lastLookup, int lookup)Unlink a node from a linked list and link into the reclaimed list.- Parameters:
index- an index into hashTablelastLookup- either -1 or the node to which the target node is linkedlookup- the node to remove
-
removeEmptyNode
public boolean removeEmptyNode(int lookup)
Remove a node that has already been unlinked. This is not required for index operations. It is used only when the row needs to be removed from the data structures that store the actual indexed data and the nodes need to be contiguous.- Parameters:
lookup- the node to remove- Returns:
- true if node found in unlinked state
-
-
DataMelt 3.0 © DataMelt by jWork.ORG