Description

Description

The HashTable object is created with a fixed number of bins per processor, and entries in the HashTable consist of fixed size keys and data. Keys are hashed and compared by user functions, and key collisions are resolved by chaining.

The HashTable object provides the dictionary operations HashTable_insert, HashTable_lookup and HashTable_delete. All of these operations can be registered with a Snapshot object specified upon object creation. Consequently, HashTable_insert and HashTable_delete may be invoked without unacknowledgement; the user assures completion of all operations by calling Snapshot_all_sync on the associated Snapshot object. The user may also specify a HashTable_DupKeyFn which is called to update entries in the case of duplicate keys. This allows the HashTable to function as a sparse distributed memory with a simple user controlled consistency protocol.

The HashTable object provides primitives to iterate over the set of local entries in some unspecified order. After initializing the iterator object, each local entry's key and data may be examined. Using the iterator, successive entries may be deleted, as well as clearing the entire set of local entries.

HashTable_all_create, HashTable_all_destroy, HashTable_insert, HashTable_lookup and HashTable_delete are split-phase operations. A split-phase operation returns OK if it has completed upon return (i.e., no need to create a thread to wait for the the result), and WAIT otherwise. HashTable_all_create and HashTable_all_destroy must be called by one thread per processor on all processors. The remaining primitives are not split-phase, and they return OK if they succeed, and FAIL if exceptions occur.

HashTable_all_create

Effect

Create a HashTable object with id id. If snapshotId is non-negative, the designated snapshot object is used to take snapshots of the HashTable with respect to the operations HashTable_insert, HashTable_lookup and HashTable_delete. The HashTable contains nbins bins per processor, and entries will consist of keys and data of sizes keySize and dataSize, respectively. The function cmpFn will be called to compare keys, and hashFn will be called to hash keys. The return value is stored in location flagPtr and counter ctr is incremented when the operation completes.

Post-Requires

The Snapshot object snapshotId must exist before the operations HashTable_insert, HashTable_lookup and HashTable_delete are called on any nodes.

HashTable_all_destroy

Effect

Deallocate the HashTable object id. Increment the counter ctr upon completion.

HashTable_dupKeyFn

Effect

Set the duplicate key update function to dupKeyFn in the local portion of HashTable object id.

Post-Requires

dupKeyFn will be called to update duplicate inserts on the local node only.

HashTable_insert

Effect

Insert entry consisting of key and data into the HashTable object id. Store the return value into flagPtr and increment counter ctr upon completion.

Requires

HashTable_all_create must be called on all nodes to allocate HashTable object id. If HashTable has an associated Snapshot object, it also must be created before any calls to HashTable_insert.

HashTable_lookup

Effect

Lookup the entry with key in the HashTable object id. If successful, the entry data will be copied into data on the calling node. Store the return value into flagPtr and increment counter ctr upon completion.

Requires

HashTable_all_create must be called on all nodes to allocate HashTable object id. If HashTable has an associated Snapshot object, it also must be created before any calls to HashTable_lookup.

HashTable_delete

Effect

Delete the entry with key in the HashTable object id. Store the return value into flagPtr and increment counter ctr upon completion.

Requires

HashTable_all_create must be called on all nodes to allocate HashTable object id. If HashTable has an associated Snapshot object, it also must be created before any calls to HashTable_delete.

HashTable_itrInit

Effect

Initialize the iterator itr to range over the entries in the local portion of HashTable object id.

HashTable_itrNext

Effect

If there is a next entry pointed to by iterator itr, store pointers to the key and for the entry in keyPtr and dataPtr, respectively, and return OK. If itr has ranged over all entries, return FAIL.

Requires

HashTable_itrInit must be called to initialize itr.

Post-Requires

The key and data pointed to by keyPtr and dataPtr must not be modified.

HashTable_itrDelete

Effect

If there is a current entry pointed to by iterator itr, delete the entry and return OK. If itr has ranged over all entries, return FAIL.

Requires

HashTable_itrInit must be called to initialize itr.

HashTable_clear

Effect

Delete all entries in the local portion of HashTable object id.

HashTable_count

Effect

Return the number of entries in the local portion of HashTable object id into the location pointed to by countPtr.



Chih-Po Wen
Wed Sep 13 23:57:28 PDT 1995